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
|
#!/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
|