diff options
Diffstat (limited to 'MgaRepo/commands')
-rw-r--r-- | MgaRepo/commands/clone.py | 51 | ||||
-rw-r--r-- | MgaRepo/commands/log.py | 12 | ||||
-rw-r--r-- | MgaRepo/commands/maintdb.py | 3 | ||||
-rw-r--r-- | MgaRepo/commands/submit.py | 10 |
4 files changed, 66 insertions, 10 deletions
diff --git a/MgaRepo/commands/clone.py b/MgaRepo/commands/clone.py new file mode 100644 index 0000000..589ec75 --- /dev/null +++ b/MgaRepo/commands/clone.py @@ -0,0 +1,51 @@ +#!/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 + +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) + 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/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/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: |