diff options
author | Mageia SVN-Git Migration <svn-git-migration@mageia.org> | 2011-01-04 16:09:44 +0000 |
---|---|---|
committer | Mageia SVN-Git Migration <svn-git-migration@mageia.org> | 2011-01-04 16:09:44 +0000 |
commit | 846c9e0ef180aa5411803eb1906896dc5e2fc5b9 (patch) | |
tree | f82d50447e2f648e76d051cb20ca4c44b1dde8a8 /RepSys/commands/submit.py | |
parent | 085ad0c1554260fe8f87955ed1ba74e06413f416 (diff) | |
download | mgarepo-846c9e0ef180aa5411803eb1906896dc5e2fc5b9.tar mgarepo-846c9e0ef180aa5411803eb1906896dc5e2fc5b9.tar.gz mgarepo-846c9e0ef180aa5411803eb1906896dc5e2fc5b9.tar.bz2 mgarepo-846c9e0ef180aa5411803eb1906896dc5e2fc5b9.tar.xz mgarepo-846c9e0ef180aa5411803eb1906896dc5e2fc5b9.zip |
Synthesized commit during git-svn import combining previous Mandriva history with Magiea.
This commit consitsts of the following subversion commits:
------------------------------------------------------------------------
r202 | boklm | 2011-01-04 16:09:44 +0000 (Tue, 04 Jan 2011) | 1 line
add repsys
------------------------------------------------------------------------
Diffstat (limited to 'RepSys/commands/submit.py')
-rwxr-xr-x[-rw-r--r--] | RepSys/commands/submit.py | 76 |
1 files changed, 58 insertions, 18 deletions
diff --git a/RepSys/commands/submit.py b/RepSys/commands/submit.py index 88ff596..2924329 100644..100755 --- a/RepSys/commands/submit.py +++ b/RepSys/commands/submit.py @@ -1,5 +1,6 @@ #!/usr/bin/python -from RepSys import Error, config, layout +from RepSys import Error, config, layout, mirror +from RepSys.svn import SVN from RepSys.command import * from RepSys.rpmutil import get_spec, get_submit_info from RepSys.util import get_auth, execcmd, get_helper @@ -8,6 +9,7 @@ import getopt import sys import re import subprocess +import uuid import xmlrpclib @@ -37,6 +39,8 @@ Options: argument) -s The host in which the package URL will be submitted (defaults to the host in the URL) + -a Submit all URLs at once (depends on server-side support) + -i SID Use the submit identifier SID -h Show this message --distro The distribution branch where the packages come from --define Defines one variable to be used by the submit scripts @@ -63,6 +67,9 @@ def parse_options(): parser.add_option("-r", dest="revision", type="string", nargs=1) parser.add_option("-s", dest="submithost", type="string", nargs=1, default=None) + parser.add_option("-i", dest="sid", type="string", nargs=1, + default=None) + parser.add_option("-a", dest="atonce", action="store_true", default=False) parser.add_option("--distro", dest="distro", type="string", default=None) parser.add_option("--define", action="append", default=[]) @@ -96,8 +103,33 @@ def parse_options(): if expanded != args: print "Submitting: %s" % " ".join(expanded) args = expanded - opts.urls = [layout.package_url(nameurl, distro=opts.distro, mirrored=False) + # generate URLs for package names: + opts.urls = [mirror.strip_username( + layout.package_url(nameurl, distro=opts.distro, mirrored=False)) for nameurl in args] + # find the revision if not specified: + newurls = [] + for url in opts.urls: + if not "@" in url: + print "Fetching revision..." + courl = layout.checkout_url(url) + log = SVN().log(courl, limit=1) + if not log: + raise Error, "can't find a revision for %s" % courl + ci = log[0] + print "URL:", url + print "Commit:", + print "%d | %s" % (ci.revision, ci.author), + if ci.lines: + line = " ".join(ci.lines).strip() + if len(line) > 57: + line = line[:57] + "..." + print "| %s" % line, + print + url = url + "@" + str(ci.revision) + newurls.append(url) + opts.urls[:] = newurls + # choose a target if not specified: if opts.target is None and opts.distro is None: target = layout.distro_branch(opts.urls[0]) or DEFAULT_TARGET print "Implicit target: %s" % target @@ -132,7 +164,7 @@ def list_targets(option, opt, val, parser): execcmd(command, show=True) sys.exit(0) -def submit(urls, target, define=[], submithost=None): +def submit(urls, target, define=[], submithost=None, atonce=False, sid=None): if submithost is None: submithost = config.get("submit", "host") if submithost is None: @@ -145,25 +177,33 @@ def submit(urls, target, define=[], submithost=None): # runs a create-srpm in the server through ssh, which will make a # copy of the rpm in the export directory createsrpm = get_helper("create-srpm") - args = ["ssh", submithost, createsrpm, "-t", target] - for entry in define: - args.append("--define") - args.append(entry) + baseargs = ["ssh", submithost, createsrpm, "-t", target] + if not sid: + sid = uuid.uuid4() + define.append("sid=%s" % sid) + for entry in reversed(define): + baseargs.append("--define") + baseargs.append(entry) + cmdsargs = [] if len(urls) == 1: # be compatible with server-side repsys versions older than 1.6.90 url, rev = layout.split_url_revision(urls[0]) - args.append(url) - args.append("-r") - args.append(str(rev)) - else: - args.extend(urls) - command = subprocess.list2cmdline(args) - status, output = execcmd(command) - if status == 0: - print "Package submitted!" + baseargs.append("-r") + baseargs.append(str(rev)) + baseargs.append(url) + cmdsargs.append(baseargs) + elif atonce: + cmdsargs.append(baseargs + urls) else: - sys.stderr.write(output) - sys.exit(status) + cmdsargs.extend((baseargs + [url]) for url in urls) + for cmdargs in cmdsargs: + command = subprocess.list2cmdline(cmdargs) + status, output = execcmd(command) + if status == 0: + print "Package submitted!" + else: + sys.stderr.write(output) + sys.exit(status) def main(): do_command(parse_options, submit) |