aboutsummaryrefslogtreecommitdiffstats
path: root/RepSys/commands/markrelease.py
diff options
context:
space:
mode:
Diffstat (limited to 'RepSys/commands/markrelease.py')
-rw-r--r--RepSys/commands/markrelease.py96
1 files changed, 96 insertions, 0 deletions
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