aboutsummaryrefslogtreecommitdiffstats
path: root/RepSys/commands
diff options
context:
space:
mode:
authorFrederic Lepied <flepied@mandriva.com>2005-12-07 10:06:33 +0000
committerFrederic Lepied <flepied@mandriva.com>2005-12-07 10:06:33 +0000
commit2c78c40c9bfae22d1501022b2e52cf938b5a957e (patch)
tree33a030236dd735f665e7b1ff1a9fba203742ecc0 /RepSys/commands
parentaa9174bf0cce8d6a3c6e4d9e795be717da184406 (diff)
downloadmgarepo-topic/V1_5_X@821.tar
mgarepo-topic/V1_5_X@821.tar.gz
mgarepo-topic/V1_5_X@821.tar.bz2
mgarepo-topic/V1_5_X@821.tar.xz
mgarepo-topic/V1_5_X@821.zip
Diffstat (limited to 'RepSys/commands')
-rw-r--r--RepSys/commands/__init__.py0
-rw-r--r--RepSys/commands/authoremail.py34
-rw-r--r--RepSys/commands/changed.py35
-rw-r--r--RepSys/commands/co.py36
-rw-r--r--RepSys/commands/create.py30
-rw-r--r--RepSys/commands/editlog.py38
-rw-r--r--RepSys/commands/getspec.py31
-rw-r--r--RepSys/commands/getsrpm.py76
-rw-r--r--RepSys/commands/markrelease.py96
-rw-r--r--RepSys/commands/patchspec.py35
-rw-r--r--RepSys/commands/putsrpm.py61
-rw-r--r--RepSys/commands/rpmlog.py40
-rw-r--r--RepSys/commands/submit.py104
13 files changed, 616 insertions, 0 deletions
diff --git a/RepSys/commands/__init__.py b/RepSys/commands/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/RepSys/commands/__init__.py
diff --git a/RepSys/commands/authoremail.py b/RepSys/commands/authoremail.py
new file mode 100644
index 0000000..aee7b58
--- /dev/null
+++ b/RepSys/commands/authoremail.py
@@ -0,0 +1,34 @@
+#!/usr/bin/python
+from RepSys import Error, config
+from RepSys.command import *
+import sys
+import getopt
+
+HELP = """\
+Usage: repsys authoremail [OPTIONS] AUTHOR
+
+Options:
+ -h Show this message
+
+Examples:
+ repsys authoremail john
+"""
+
+def parse_options():
+ parser = OptionParser(help=HELP)
+ opts, args = parser.parse_args()
+ if len(args) != 1:
+ raise Error, "invalid arguments"
+ opts.author = args[0]
+ return opts
+
+def print_author_email(author):
+ email = config.get("users", author)
+ if not email:
+ raise Error, "author not found"
+ print email
+
+def main():
+ do_command(parse_options, print_author_email)
+
+# vim:et:ts=4:sw=4
diff --git a/RepSys/commands/changed.py b/RepSys/commands/changed.py
new file mode 100644
index 0000000..c99f3ae
--- /dev/null
+++ b/RepSys/commands/changed.py
@@ -0,0 +1,35 @@
+#!/usr/bin/python
+from RepSys import Error
+from RepSys.command import *
+from RepSys.rpmutil import check_changed
+import getopt
+import sys
+
+HELP = """\
+Usage: repsys changed [OPTIONS] URL
+
+Options:
+ -a Check all packages in given URL
+ -s Show differences
+ -h Show this message
+
+Examples:
+ repsys changed http://repos/svn/cnc/snapshot/foo
+ repsys changed -a http://repos/svn/cnc/snapshot
+"""
+
+def parse_options():
+ parser = OptionParser(help=HELP)
+ parser.add_option("-a", dest="all", action="store_true")
+ parser.add_option("-s", dest="show", action="store_true")
+ opts, args = parser.parse_args()
+ if len(args) != 1:
+ raise Error, "invalid arguments"
+ opts.url = default_parent(args[0])
+ opts.verbose = 1 # Unconfigurable
+ return opts
+
+def main():
+ do_command(parse_options, check_changed)
+
+# vim:et:ts=4:sw=4
diff --git a/RepSys/commands/co.py b/RepSys/commands/co.py
new file mode 100644
index 0000000..0c9d2dc
--- /dev/null
+++ b/RepSys/commands/co.py
@@ -0,0 +1,36 @@
+#!/usr/bin/python
+from RepSys import Error
+from RepSys.command import *
+from RepSys.rpmutil import checkout
+import getopt
+import sys
+
+HELP = """\
+Usage: repsys co [OPTIONS] URL [LOCALPATH]
+
+Options:
+ -r REV Revision to checkout
+ -h Show this message
+
+Examples:
+ repsys co http://repos/svn/cnc/snapshot/foo
+ repsys co http://repos/svn/cnc/snapshot/foo foo-pkg
+"""
+
+def parse_options():
+ parser = OptionParser(help=HELP)
+ parser.add_option("-r", dest="revision")
+ opts, args = parser.parse_args()
+ if len(args) not in (1, 2):
+ raise Error, "invalid arguments"
+ opts.url = default_parent(args[0])
+ if len(args) == 2:
+ opts.path = args[1]
+ else:
+ opts.path = None
+ return opts
+
+def main():
+ do_command(parse_options, checkout)
+
+# vim:et:ts=4:sw=4
diff --git a/RepSys/commands/create.py b/RepSys/commands/create.py
new file mode 100644
index 0000000..56af1ef
--- /dev/null
+++ b/RepSys/commands/create.py
@@ -0,0 +1,30 @@
+#!/usr/bin/python
+from RepSys import Error
+from RepSys.command import *
+from RepSys.rpmutil import create_package
+import getopt
+import sys
+
+HELP = """\
+Usage: repsys create [OPTIONS] URL
+
+Options:
+ -h Show this message
+
+Examples:
+ repsys create http://repos/svn/cnc/snapshot/newpkg
+"""
+
+def parse_options():
+ parser = OptionParser(help=HELP)
+ opts, args = parser.parse_args()
+ if len(args) != 1:
+ raise Error, "invalid arguments"
+ opts.pkgdirurl = default_parent(args[0])
+ opts.verbose = 1 # Unconfigurable
+ return opts
+
+def main():
+ do_command(parse_options, create_package)
+
+# vim:et:ts=4:sw=4
diff --git a/RepSys/commands/editlog.py b/RepSys/commands/editlog.py
new file mode 100644
index 0000000..1962ed8
--- /dev/null
+++ b/RepSys/commands/editlog.py
@@ -0,0 +1,38 @@
+#!/usr/bin/python
+from RepSys import Error
+from RepSys.command import *
+from RepSys.svn import SVN
+import re
+
+HELP = """\
+Usage: repsys editlog [OPTIONS] [URL] REVISION
+
+Options:
+ -h Show this message
+
+Examples:
+ repsys editlog 14800
+ repsys editlog https://repos/svn/cnc/snapshot 14800
+"""
+
+def parse_options():
+ parser = OptionParser(help=HELP)
+ opts, args = parser.parse_args()
+ if len(args) == 2:
+ pkgdirurl, revision = args
+ elif len(args) == 1:
+ pkgdirurl, revision = "", args[0]
+ else:
+ raise Error, "invalid arguments"
+ opts.pkgdirurl = default_parent(pkgdirurl)
+ opts.revision = re.compile(r".*?(\d+).*").sub(r"\1", revision)
+ return opts
+
+def editlog(pkgdirurl, revision):
+ svn = SVN()
+ svn.propedit("svn:log", pkgdirurl, rev=revision)
+
+def main():
+ do_command(parse_options, editlog)
+
+# vim:et:ts=4:sw=4
diff --git a/RepSys/commands/getspec.py b/RepSys/commands/getspec.py
new file mode 100644
index 0000000..1079a81
--- /dev/null
+++ b/RepSys/commands/getspec.py
@@ -0,0 +1,31 @@
+#!/usr/bin/python
+from RepSys import Error
+from RepSys.command import *
+from RepSys.rpmutil import get_spec
+import getopt
+import sys
+
+HELP = """\
+Usage: repsys getspec [OPTIONS] REPPKGURL
+
+Options:
+ -t DIR Use DIR as target for spec file (default is ".")
+ -h Show this message
+
+Examples:
+ repsys getspec http://repos/svn/cnc/snapshot/foo
+"""
+
+def parse_options():
+ parser = OptionParser(help=HELP)
+ parser.add_option("-t", dest="targetdir", default=".")
+ opts, args = parser.parse_args()
+ if len(args) != 1:
+ raise Error, "invalid arguments"
+ opts.pkgdirurl = default_parent(args[0])
+ return opts
+
+def main():
+ do_command(parse_options, get_spec)
+
+# vim:et:ts=4:sw=4
diff --git a/RepSys/commands/getsrpm.py b/RepSys/commands/getsrpm.py
new file mode 100644
index 0000000..f2def54
--- /dev/null
+++ b/RepSys/commands/getsrpm.py
@@ -0,0 +1,76 @@
+#!/usr/bin/python
+#
+# This program will extract given version/revision of the named package
+# from the Conectiva Linux repository system.
+#
+from RepSys import Error, config
+from RepSys.command import *
+from RepSys.rpmutil import get_srpm
+import tempfile
+import shutil
+import getopt
+import glob
+import sys
+import os
+
+HELP = """\
+Usage: repsys getsrpm [OPTIONS] REPPKGURL
+
+Options:
+ -c Use files in current/ directory (default)
+ -p Use files in pristine/ directory
+ -v VER Use files from the version specified by VER (e.g. 2.2.1-2cl)
+ -r REV Use files from current directory, in revision REV (e.g. 1001)
+ -t DIR Put SRPM file in directory DIR when done (default is ".")
+ -P USER Define the RPM packager inforamtion to USER
+ -s FILE Run script with "FILE TOPDIR SPECFILE" command
+ -n Rename the package to include the revision number
+ -l Use subversion log to build rpm %changelog
+ -h Show this message
+
+Examples:
+ repsys getsrpm http://foo.bar/svn/cnc/snapshot/python
+ repsys getsrpm -p http://foo.bar/svn/cnc/releases/8cl/python
+ repsys getsrpm -r 1001 file:///svn/cnc/snapshot/python
+"""
+
+def mode_callback(option, opt, val, parser, mode):
+ opts = parser.values
+ opts.mode = mode
+ if mode == "version":
+ try:
+ opts.version, opts.release = val.split("-", 1)
+ except ValueError:
+ raise Error, "wrong version, use something like 2.2-1cl"
+ elif mode == "revision":
+ opts.revision = val
+
+def parse_options():
+ parser = OptionParser(help=HELP)
+ parser.defaults["mode"] = "current"
+ parser.defaults["version"] = None
+ parser.defaults["release"] = None
+ parser.defaults["revision"] = None
+ parser.add_option("-c", action="callback", callback=mode_callback,
+ callback_kwargs={"mode": "current"})
+ parser.add_option("-p", action="callback", callback=mode_callback,
+ callback_kwargs={"mode": "pristine"})
+ parser.add_option("-r", action="callback", callback=mode_callback,
+ callback_kwargs={"mode": "revision"})
+ parser.add_option("-v", action="callback", callback=mode_callback,
+ callback_kwargs={"mode": "version"})
+ parser.add_option("-t", dest="targetdirs", action="append", default=[])
+ parser.add_option("-s", dest="scripts", action="append", default=[])
+ parser.add_option("-P", dest="packager", default="")
+ parser.add_option("-n", dest="revname", action="store_true")
+ parser.add_option("-l", dest="svnlog", action="store_true")
+ opts, args = parser.parse_args()
+ if len(args) != 1:
+ raise Error, "invalid arguments"
+ opts.pkgdirurl = default_parent(args[0])
+ return opts
+
+def main():
+ do_command(parse_options, get_srpm)
+
+# vim:et:ts=4:sw=4
diff --git a/RepSys/commands/markrelease.py b/RepSys/commands/markrelease.py
new file mode 100644
index 0000000..054fff0
--- /dev/null
+++ b/RepSys/commands/markrelease.py
@@ -0,0 +1,96 @@
+#!/usr/bin/python
+#
+# This program will append a release to the Conectiva Linux package
+# repository system. It's meant to be a startup system to include
+# pre-packaged SRPMS in the repository, thus, you should not commit
+# packages over an ongoing package structure (with changes in current/
+# directory and etc). Also, notice that packages must be included in
+# cronological order.
+#
+from RepSys import Error
+from RepSys.command import *
+from RepSys.rpm import SRPM
+from RepSys.rpmutil import mark_release
+from RepSys.util import get_auth
+import getopt
+import sys
+import os
+
+HELP = """\
+*** WARNING --- You probably SHOULD NOT use this program! --- WARNING ***
+
+Usage: repsys markrelease [OPTIONS] REPPKGURL
+
+Options:
+ -f FILE Try to extract information from given file
+ -r REV Revision which will be used to make the release copy tag
+ -v VER Version which will be used to make the release copy tag
+ -n Append package name to provided URL
+ -h Show this message
+
+Examples:
+ repsys markrelease -r 68 -v 1.0-1 file://svn/cnc/snapshot/foo
+ repsys markrelease -f @68:foo-1.0-1.src.rpm file://svn/cnc/snapshot/foo
+ repsys markrelease -r 68 -f foo-1.0.src.rpm file://svn/cnc/snapshot/foo
+"""
+
+def version_callback(option, opt, val, parser):
+ opts = parser.values
+ try:
+ opts.version, opts.release = val.split("-", 1)
+ except ValueError:
+ raise Error, "wrong version, use something like 1:2.2-1cl"
+
+def parse_options():
+ parser = OptionParser(help=HELP)
+ parser.defaults["version"] = None
+ parser.defaults["release"] = None
+ parser.add_option("-v", action="callback", callback=version_callback)
+ parser.add_option("-r", dest="revision")
+ parser.add_option("-f", dest="filename")
+ parser.add_option("-n", dest="appendname", action="store_true")
+ opts, args = parser.parse_args()
+
+ if len(args) != 1:
+ raise Error, "invalid arguments"
+
+ opts.pkgdirurl = default_parent(args[0])
+
+ filename = opts.filename
+ appendname = opts.appendname
+ del opts.filename, opts.appendname
+
+ if filename:
+ if not os.path.isfile(filename):
+ raise Error, "file not found: "+filename
+ if not opts.revision:
+ basename = os.path.basename(filename)
+ end = basename.find(":")
+ if basename[0] != "@" or end == -1:
+ raise Error, "couldn't guess revision from filename"
+ opts.revision = basename[1:end]
+ srpm = None
+ if not opts.version:
+ srpm = SRPM(filename)
+ if srpm.epoch:
+ opts.version = "%s:%s" % (srpm.epoch, srpm.version)
+ else:
+ opts.version = srpm.version
+ opts.release = srpm.release
+ if appendname:
+ if not srpm:
+ srpm = SRPM(filename)
+ opts.pkgdirurl = "/".join([opts.pkgdirurl, srpm.name])
+ elif appendname:
+ raise Error, "option -n requires option -f"
+ elif not opts.revision:
+ raise Error, "no revision provided"
+ elif not opts.version:
+ raise Error, "no version provided"
+ get_auth()
+ return opts
+
+def main():
+ do_command(parse_options, mark_release)
+
+# vim:et:ts=4:sw=4
diff --git a/RepSys/commands/patchspec.py b/RepSys/commands/patchspec.py
new file mode 100644
index 0000000..155ff4f
--- /dev/null
+++ b/RepSys/commands/patchspec.py
@@ -0,0 +1,35 @@
+#!/usr/bin/python
+#
+# This program will try to patch a spec file from a given package url.
+#
+from RepSys import Error
+from RepSys.rpmutil import patch_spec
+from RepSys.command import *
+import getopt
+import sys
+
+HELP = """\
+Usage: repsys patchspec [OPTIONS] REPPKGURL PATCHFILE
+
+Options:
+ -l LOG Use LOG as log message
+ -h Show this message
+
+Examples:
+ repsys patchspec http://repos/svn/cnc/snapshot/foo
+"""
+
+def parse_options():
+ parser = OptionParser(help=HELP)
+ parser.add_option("-l", dest="log", default="")
+ opts, args = parser.parse_args()
+ if len(args) != 2:
+ raise Error, "invalid arguments"
+ opts.pkgdirurl = default_parent(args[0])
+ opts.patchfile = args[1]
+ return opts
+
+def main():
+ do_command(parse_options, patch_spec)
+
+# vim:et:ts=4:sw=4
diff --git a/RepSys/commands/putsrpm.py b/RepSys/commands/putsrpm.py
new file mode 100644
index 0000000..21ad234
--- /dev/null
+++ b/RepSys/commands/putsrpm.py
@@ -0,0 +1,61 @@
+#!/usr/bin/python
+#
+# This program will append a release to the Conectiva Linux package
+# repository system. It's meant to be a startup system to include
+# pre-packaged SRPMS in the repository, thus, you should not commit
+# packages over an ongoing package structure (with changes in current/
+# directory and etc). Also, notice that packages must be included in
+# cronological order.
+#
+from RepSys import Error
+from RepSys.command import *
+from RepSys.rpmutil import put_srpm
+import getopt
+import sys, os
+
+HELP = """\
+*** WARNING --- You probably SHOULD NOT use this program! --- WARNING ***
+
+Usage: repsys putsrpm [OPTIONS] REPPKGURL
+
+Options:
+ -n Append package name to provided URL
+ -l LOG Use log when commiting changes
+ -h Show this message
+
+Examples:
+ repsys putsrpm file://svn/cnc/snapshot/foo /cnc/d/SRPMS/foo-1.0.src.rpm
+"""
+
+def parse_options():
+ parser = OptionParser(help=HELP)
+ parser.add_option("-l", dest="log", default="")
+ parser.add_option("-n", dest="appendname", action="store_true")
+ opts, args = parser.parse_args()
+ if len(args) != 2:
+ raise Error, "invalid arguments"
+ opts.pkgdirurl = default_parent(args[0])
+ opts.srpmfile = args[1]
+ return opts
+
+def put_srpm_cmd(pkgdirurl, srpmfile, appendname=0, log=""):
+ if os.path.isdir(srpmfile):
+ dir = srpmfile
+ for entry in os.listdir(dir):
+ if entry[-8:] == ".src.rpm":
+ sys.stderr.write("Putting %s... " % entry)
+ sys.stderr.flush()
+ entrypath = os.path.join(dir, entry)
+ try:
+ put_srpm(pkgdirurl, entrypath, appendname, log)
+ sys.stderr.write("done\n")
+ except Error, e:
+ sys.stderr.write("error: %s\n" % str(e))
+ else:
+ put_srpm(pkgdirurl, srpmfile, appendname, log)
+
+
+def main():
+ do_command(parse_options, put_srpm_cmd)
+
+# vim:et:ts=4:sw=4
diff --git a/RepSys/commands/rpmlog.py b/RepSys/commands/rpmlog.py
new file mode 100644
index 0000000..24eddfe
--- /dev/null
+++ b/RepSys/commands/rpmlog.py
@@ -0,0 +1,40 @@
+#!/usr/bin/python
+#
+# This program will convert the output of "svn log" to be suitable
+# for usage in an rpm %changelog session.
+#
+from RepSys import Error
+from RepSys.command import *
+from RepSys.log import svn2rpm
+import getopt
+import sys
+
+HELP = """\
+Usage: repsys rpmlog [OPTIONS] REPPKGDIRURL
+
+Options:
+ -r REV Collect logs from given revision to revision 0
+ -n NUM Output only last NUM entries
+ -h Show this message
+
+Examples:
+ repsys rpmlog https://repos/snapshot/python
+"""
+
+def parse_options():
+ parser = OptionParser(help=HELP)
+ parser.add_option("-r", dest="revision")
+ parser.add_option("-n", dest="size", type="int")
+ opts, args = parser.parse_args()
+ if len(args) != 1:
+ raise Error, "invalid arguments"
+ opts.pkgdirurl = default_parent(args[0])
+ return opts
+
+def rpmlog(pkgdirurl, revision, size):
+ sys.stdout.write(svn2rpm(pkgdirurl, revision, size))
+
+def main():
+ do_command(parse_options, rpmlog)
+
+# vim:sw=4:ts=4:et
diff --git a/RepSys/commands/submit.py b/RepSys/commands/submit.py
new file mode 100644
index 0000000..ff442c1
--- /dev/null
+++ b/RepSys/commands/submit.py
@@ -0,0 +1,104 @@
+#!/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
+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]]
+
+Options:
+ -t TARGET Submit given package URL to given target
+ -l Just list available targets
+ -h Show this message
+
+Examples:
+ repsys submit
+ repsys submit foo 14800
+ repsys submit https://repos/svn/cnc/snapshot/foo 14800
+ repsys submit -l https://repos
+"""
+
+def parse_options():
+ parser = OptionParser(help=HELP)
+ parser.defaults["revision"] = ""
+ parser.add_option("-t", dest="target", default="Snapshot")
+ parser.add_option("-l", dest="list", action="store_true")
+ 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 not opts.list:
+ raise Error, "provide -l or a revision number"
+ return opts
+
+def submit(pkgdirurl, revision, target, list=0):
+ #if not NINZ:
+ # raise Error, "you must have NINZ installed to use this command"
+ type, rest = urllib.splittype(pkgdirurl)
+ host, path = urllib.splithost(rest)
+ user, host = urllib.splituser(host)
+ host, port = urllib.splitport(host)
+ if type != "https":
+ raise Error, "you must use https:// urls"
+ if user:
+ user, passwd = urllib.splitpasswd(user)
+ if passwd:
+ raise Error, "do not use a password in your command line"
+ user, passwd = get_auth(username=user)
+ #soap = NINZ.client.Binding(host=host,
+ # url="https://%s/scripts/cnc/soap" % host,
+ # ssl=1,
+ # auth=(NINZ.client.AUTH.httpbasic,
+ # user, passwd))
+ if port:
+ port = ":"+port
+ else:
+ port = ""
+ iface = xmlrpclib.ServerProxy("https://%s:%s@%s%s/scripts/cnc/xmlrpc"
+ % (user, passwd, host, port))
+ try:
+ if list:
+ targets = iface.submit_targets()
+ if not targets:
+ raise Error, "no targets available"
+ sys.stdout.writelines(['"%s"\n' % x for x in targets])
+ else:
+ iface.submit_package(pkgdirurl, revision, target)
+ print "Package submitted!"
+ #except NINZ.client.SoapError, e:
+ except xmlrpclib.ProtocolError, e:
+ raise Error, "remote error: "+str(e.errmsg)
+ except xmlrpclib.Fault, e:
+ raise Error, "remote error: "+str(e.faultString)
+ except xmlrpclib.Error, e:
+ raise Error, "remote error: "+str(e)
+
+def main():
+ do_command(parse_options, submit)
+
+# vim:et:ts=4:sw=4