1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
#!/usr/bin/python
from RepSys import Error, config
from RepSys.command import *
from RepSys.rpmutil import get_spec, get_submit_info
from RepSys.util import get_auth, execcmd, get_helper
import urllib
import getopt
import sys
import re
#try:
# import NINZ.client
#except ImportError:
# NINZ = None
import xmlrpclib
HELP = """\
Usage: repsys submit [OPTIONS] [URL [REVISION]]
Submits the package from URL to the submit host.
Options:
-t TARGET Submit given package URL to given target
-l Just list available targets
-r REV Provides a revision number (when not providing as an
argument)
-s The host in which the package URL will be submitted
(defaults to the host in the URL)
-h Show this message
--define Defines one variable to be used by the submit scripts
in the submit host
Examples:
repsys submit
repsys submit foo 14800
repsys submit https://repos/svn/mdv/cooker/foo 14800
repsys submit -r 14800 https://repos/svn/mdv/cooker/foo
repsys submit -l https://repos
"""
def parse_options():
parser = OptionParser(help=HELP)
parser.defaults["revision"] = ""
parser.add_option("-t", dest="target", default="Cooker")
parser.add_option("-l", dest="list", action="store_true")
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("--define", action="append")
opts, args = parser.parse_args()
if not args:
name, rev = get_submit_info(".")
try:
yn = raw_input("Submit '%s', revision %d (y/N)? " % (name, rev))
except KeyboardInterrupt:
yn = "n"
if yn.lower() in ("y", "yes"):
args = name, str(rev)
else:
print "Cancelled."
sys.exit(1)
elif len(args) > 2:
raise Error, "invalid arguments"
opts.pkgdirurl = default_parent(args[0])
if len(args) == 2:
opts.revision = re.compile(r".*?(\d+).*").sub(r"\1", args[1])
elif len(args) == 1 and opts.revision:
# accepts -r 3123 http://foo/bar
pass
elif not opts.list:
raise Error, "provide -l or a revision number"
return opts
def submit(pkgdirurl, revision, target, list=0, define=[], submithost=None):
#if not NINZ:
# raise Error, "you must have NINZ installed to use this command"
if submithost is None:
submithost = config.get("submit", "host")
if submithost is None:
# extract the submit host from the svn host
type, rest = urllib.splittype(pkgdirurl)
host, path = urllib.splithost(rest)
user, host = urllib.splituser(host)
submithost, port = urllib.splitport(host)
del type, user, port, path, rest
# runs a create-srpm in the server through ssh, which will make a
# copy of the rpm in the export directory
if list:
raise Error, "unable to list targets from svn+ssh:// URLs"
createsrpm = get_helper("create-srpm")
command = "ssh %s %s '%s' -r %s -t %s" % (
submithost, createsrpm, pkgdirurl, revision, target)
if define:
command += " " + " ".join([ "--define " + x for x in define ])
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)
# vim:et:ts=4:sw=4
|