aboutsummaryrefslogtreecommitdiffstats
path: root/RepSys/commands/submit.py
diff options
context:
space:
mode:
Diffstat (limited to 'RepSys/commands/submit.py')
-rwxr-xr-x[-rw-r--r--]RepSys/commands/submit.py76
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)