diff options
Diffstat (limited to 'MgaRepo/commands')
| -rw-r--r-- | MgaRepo/commands/buildrpm.py | 45 | ||||
| -rw-r--r-- | MgaRepo/commands/clone.py | 54 | ||||
| -rw-r--r-- | MgaRepo/commands/getsrpm.py | 3 | ||||
| -rw-r--r-- | MgaRepo/commands/github.py | 57 | ||||
| -rw-r--r-- | MgaRepo/commands/log.py | 12 | ||||
| -rw-r--r-- | MgaRepo/commands/maintdb.py | 3 | ||||
| -rw-r--r-- | MgaRepo/commands/rpmlog.py | 10 | ||||
| -rw-r--r-- | MgaRepo/commands/submit.py | 10 |
8 files changed, 182 insertions, 12 deletions
diff --git a/MgaRepo/commands/buildrpm.py b/MgaRepo/commands/buildrpm.py new file mode 100644 index 0000000..9caec45 --- /dev/null +++ b/MgaRepo/commands/buildrpm.py @@ -0,0 +1,45 @@ +#!/usr/bin/python +# +from MgaRepo.command import do_command +from MgaRepo.rpmutil import build_rpm +from optparse import * + +HELP = """\ +Usage: mgarepo buildrpm [OPTIONS] + +Builds the binary RPM(s) (.rpm) file(s) of a given package. + +Options: + -bX Build stage option, where X is stage, default is -bb + -I Don't automatically try install missing build dependencies + -L Disable rpmlint check of packages built + -P USER Define the RPM packager information to USER + -d Use DNF + -q Quiet build output + -s Jump to specific build stage (--short-circuit) + -l Use subversion log to build rpm %changelog + -F Do not use full name & email for packagers in %changelog + -- Options and arguments following will be passed to rpmbuild + +""" + +def parse_options(): + parser = OptionParser(HELP) + parser.add_option("-b", dest="build_cmd", default="a") + parser.add_option("-I", dest="installdeps", action="store_false", default=True) + parser.add_option("-L", dest="rpmlint", action="store_false", default=True) + parser.add_option("-P", dest="packager", default="") + parser.add_option("-d", "--dnf", dest="use_dnf", action="store_true", default=False) + parser.add_option("-q", "--quiet", dest="verbose", action="store_false", default=True) + parser.add_option("-s", "--short-circuit", dest="short_circuit", action="store_true", default=False) + parser.add_option("-l", dest="svnlog", action="store_true", default=False) + parser.add_option("-F", dest="fullnames", default=True, + action="store_false") + opts, args = parser.parse_args() + opts.rpmargs = parser.rargs + return opts + +def main(): + do_command(parse_options, build_rpm) + +# vim:et:ts=4:sw=4 diff --git a/MgaRepo/commands/clone.py b/MgaRepo/commands/clone.py new file mode 100644 index 0000000..86793c9 --- /dev/null +++ b/MgaRepo/commands/clone.py @@ -0,0 +1,54 @@ +#!/usr/bin/python +from MgaRepo import Error +from MgaRepo.command import * +from MgaRepo.rpmutil import clone +import getopt +import sys + +HELP = """\ +Usage: repsys co [OPTIONS] URL [LOCALPATH] + +Checkout the package source from the Mandriva repository. + +If the 'mirror' option is enabled, the package is obtained from the mirror +repository. + +You can specify the distro branch to checkout from by using distro/pkgname. + +Options: + -d The distribution branch to checkout from + -b The package branch + -M Do not use the mirror (use the main repository) + -h Show this message + -F Do not convert svn usernames to full name & email + +Examples: + repsys clone pkgname + repsys clone -d 2009.0 pkgname + repsys clone 2009.0/pkgame + repsys clone http://repos/svn/cnc/snapshot/foo + repsys clone http://repos/svn/cnc/snapshot/foo foo-pkg +""" + +def parse_options(): + parser = OptionParser(help=HELP) + parser.add_option("--distribution", "-d", dest="distro", default=None) + parser.add_option("--branch", "-b", dest="branch", default=None) + parser.add_option("-F", dest="fullnames", default=True, + action="store_false") + opts, args = parser.parse_args() + if len(args) not in (1, 2): + raise Error("invalid arguments") + # here we don't use package_url in order to notify the user we are + # using the mirror + opts.pkgdirurl = args[0] + if len(args) == 2: + opts.path = args[1] + else: + opts.path = None + return opts + +def main(): + do_command(parse_options, clone) + +# vim:et:ts=4:sw=4 diff --git a/MgaRepo/commands/getsrpm.py b/MgaRepo/commands/getsrpm.py index 82bd626..5eb630b 100644 --- a/MgaRepo/commands/getsrpm.py +++ b/MgaRepo/commands/getsrpm.py @@ -30,6 +30,7 @@ Options: -n Rename the package to include the revision number -l Use subversion log to build rpm %changelog -T FILE Template to be used to generate the %changelog + -F Do not use full name & email for packagers in %changelog -M Do not use the mirror (use the main repository) -h Show this message --strict Check if the given revision contains changes in REPPKGURL @@ -76,6 +77,8 @@ def parse_options(): parser.add_option("-n", dest="revname", action="store_true") parser.add_option("-l", dest="svnlog", action="store_true") parser.add_option("-T", dest="template", type="string", default=None) + parser.add_option("-F", dest="fullnames", default=True, + action="store_false") parser.add_option("-M", "--no-mirror", action="callback", callback=disable_mirror) parser.add_option("--strict", dest="strict", default=False, diff --git a/MgaRepo/commands/github.py b/MgaRepo/commands/github.py new file mode 100644 index 0000000..dece050 --- /dev/null +++ b/MgaRepo/commands/github.py @@ -0,0 +1,57 @@ +#!/usr/bin/python +from MgaRepo import Error +from MgaRepo.command import * +from MgaRepo.GitHub import GitHub +import getopt +import sys + +HELP = """\ +Usage: mgarepo github [OPTIONS] URL + +Import a git-svn cloned repository to github + +Options: + -h Show this message + +Examples: + mgarepo github import existingpkg + mgarepo github import svn://svn.mageia.org/svn/packages/cauldron/existingpkg +""" +def github_clone(pkg, **kwargs): + github = GitHub() + github.clone_repository(pkg) + +def github_import(target=".", **kwargs): + github = GitHub() + github.import_package(target) + +def github_delete(pkg, **kwargs): + github = GitHub() + github.delete_repository(pkg) + +def parse_options(): + parser = OptionParser(help=HELP) + opts, args = parser.parse_args() + if len(args) < 1: + raise Error("invalid arguments") + opts.func = globals().get("github_"+args[0], None) + if args[0] == "import": + if len(args) > 1: + opts.target = args[1] + elif args[0] == "delete" or args[0] == "clone": + opts.pkg = args[1] + else: + raise Error("invalid arguments: %s" % str(args)) + return opts + +def dispatch_cmd(*args, **kwargs): + func = kwargs.pop("func", None) + if func: + func(**kwargs) + else: + raise Error("invalid command: %s %s" % (sys.argv[0], sys.argv[1])) + +def main(): + do_command(parse_options, dispatch_cmd) + +# vim:et:ts=4:sw=4 diff --git a/MgaRepo/commands/log.py b/MgaRepo/commands/log.py index 2181125..330a96a 100644 --- a/MgaRepo/commands/log.py +++ b/MgaRepo/commands/log.py @@ -6,6 +6,8 @@ from MgaRepo.rpmutil import sync from MgaRepo.util import execcmd import sys import os +import subprocess +import shlex HELP = """\ Usage: mgarepo log [OPTIONS] [PACKAGE] @@ -57,9 +59,13 @@ def svn_log(pkgdirurl, verbose=False, limit=None, revision=None, releases=None): args.append("-r") args.append(revision) if os.isatty(sys.stdin.fileno()): - args.append("| less") - rawcmd = " ".join(args) - execcmd(rawcmd, show=True) + pager = shlex.split(os.environ.get("PAGER", "less")) + p = subprocess.Popen(args, stdout=subprocess.PIPE) + p2 = subprocess.Popen(pager, stdin=p.stdout) + p2.wait() + p.wait() + else: + execcmd(args, show=True) def main(): do_command(parse_options, svn_log) diff --git a/MgaRepo/commands/maintdb.py b/MgaRepo/commands/maintdb.py index 9a97be8..2aa2a4c 100644 --- a/MgaRepo/commands/maintdb.py +++ b/MgaRepo/commands/maintdb.py @@ -33,8 +33,7 @@ def parse_options(): def maintdb(maintdb_args): host = config.get("maintdb", "host", "maintdb.mageia.org") maintdb_helper = get_helper("maintdb") - cmd_args = ' '.join(maintdb_args) - command = "ssh %s %s %s" % (host, maintdb_helper, cmd_args) + command = ["ssh", host, maintdb_helper] + maintdb_args execcmd(command, show=True) sys.exit(0) diff --git a/MgaRepo/commands/rpmlog.py b/MgaRepo/commands/rpmlog.py index 88dfc4b..28d66f1 100644 --- a/MgaRepo/commands/rpmlog.py +++ b/MgaRepo/commands/rpmlog.py @@ -25,6 +25,7 @@ Options: -p Append changelog found in .spec file -s Sort changelog entries, even from the old log -M Do not use the mirror (use the main repository) + -F Do not use full name & email for packagers where available -h Show this message Examples: @@ -45,13 +46,15 @@ def parse_options(): action="store_true") parser.add_option("-M", "--no-mirror", action="callback", callback=disable_mirror) + parser.add_option("-F", dest="fullnames", default=True, + action="store_false") opts, args = parser.parse_args() if len(args) != 1: raise Error("invalid arguments") opts.pkgdirurl = layout.package_url(args[0]) return opts -def rpmlog(pkgdirurl, revision, size, template, oldlog, usespec, sort): +def rpmlog(pkgdirurl, revision, size, template, oldlog, usespec, sort, fullnames): another = None if usespec: svn = SVN() @@ -59,7 +62,10 @@ def rpmlog(pkgdirurl, revision, size, template, oldlog, usespec, sort): rawspec = svn.cat(specurl, rev=revision) spec, another = split_spec_changelog(StringIO(rawspec)) newlog = get_changelog(pkgdirurl, another=another, rev=revision, - size=size, sort=sort, template=template, oldlog=oldlog) + size=size, sort=sort, template=template, oldlog=oldlog, fullnames=fullnames) + # make sure stdout support unicode, otherwise it'll croak when encountered + if not "UTF-8" in sys.stdout.encoding: + sys.stdout = open(sys.stdout.fileno(), mode="w", encoding="UTF-8") sys.stdout.writelines(newlog) def main(): diff --git a/MgaRepo/commands/submit.py b/MgaRepo/commands/submit.py index 9f05dca..d36290f 100644 --- a/MgaRepo/commands/submit.py +++ b/MgaRepo/commands/submit.py @@ -160,9 +160,10 @@ def list_targets(option, opt, val, parser): raise Error("no submit host defined in mgarepo.conf") createsrpm = get_helper("create-srpm") #TODO make it configurable - command = "ssh %s %s --list" % (host, createsrpm) - execcmd(command, show=True) - sys.exit(0) + args = ["ssh", host, createsrpm, "--list"] + execcmd(args, show=true) + sys.exit(0) # it is invoked via optparse callback, thus we need to + # force ending the script def submit(urls, target, define=[], submithost=None, atonce=False, sid=None): if submithost is None: @@ -197,8 +198,7 @@ def submit(urls, target, define=[], submithost=None, atonce=False, sid=None): else: cmdsargs.extend((baseargs + [url]) for url in urls) for cmdargs in cmdsargs: - command = subprocess.list2cmdline(cmdargs) - status, output = execcmd(command) + status, output = execcmd(cmdargs) if status == 0: print("Package submitted!") else: |
