source: soft/build_system/build_system/repsys/tags/V1_5_5/RepSys/commands/markrelease.py @ 1

Last change on this file since 1 was 1, checked in by fasma, 12 years ago

Initial Import from Mandriva's soft revision 224062 and package revision 45733

File size: 3.1 KB
Line 
1#!/usr/bin/python
2#
3# This program will append a release to the Conectiva Linux package
4# repository system.  It's meant to be a startup system to include
5# pre-packaged SRPMS in the repository, thus, you should not commit
6# packages over an ongoing package structure (with changes in current/
7# directory and etc). Also, notice that packages must be included in
8# cronological order.
9#
10from RepSys import Error
11from RepSys.command import *
12from RepSys.rpm import SRPM
13from RepSys.rpmutil import mark_release
14from RepSys.util import get_auth
15import getopt
16import sys
17import os
18
19HELP = """\
20*** WARNING --- You probably SHOULD NOT use this program! --- WARNING ***
21
22Usage: repsys markrelease [OPTIONS] REPPKGURL
23
24Options:
25    -f FILE Try to extract information from given file
26    -r REV  Revision which will be used to make the release copy tag
27    -v VER  Version which will be used to make the release copy tag
28    -n      Append package name to provided URL
29    -h      Show this message
30
31Examples:
32    repsys markrelease -r 68 -v 1.0-1 file://svn/cnc/snapshot/foo
33    repsys markrelease -f @68:foo-1.0-1.src.rpm file://svn/cnc/snapshot/foo
34    repsys markrelease -r 68 -f foo-1.0.src.rpm file://svn/cnc/snapshot/foo
35"""
36
37def version_callback(option, opt, val, parser):
38    opts = parser.values
39    try:
40        opts.version, opts.release = val.split("-", 1)
41    except ValueError:
42        raise Error, "wrong version, use something like 1:2.2-1cl"
43
44def parse_options():
45    parser = OptionParser(help=HELP)
46    parser.defaults["version"] = None
47    parser.defaults["release"] = None
48    parser.add_option("-v", action="callback", callback=version_callback)
49    parser.add_option("-r", dest="revision")
50    parser.add_option("-f", dest="filename")
51    parser.add_option("-n", dest="appendname", action="store_true")
52    opts, args = parser.parse_args()
53
54    if len(args) != 1:
55        raise Error, "invalid arguments"
56
57    opts.pkgdirurl = default_parent(args[0])
58
59    filename = opts.filename
60    appendname = opts.appendname
61    del opts.filename, opts.appendname
62
63    if filename:
64        if not os.path.isfile(filename):
65            raise Error, "file not found: "+filename
66        if not opts.revision:
67            basename = os.path.basename(filename)
68            end = basename.find(":")
69            if basename[0] != "@" or end == -1:
70                raise Error, "couldn't guess revision from filename"
71            opts.revision = basename[1:end]
72        srpm = None
73        if not opts.version:
74            srpm = SRPM(filename)
75            if srpm.epoch:
76                opts.version = "%s:%s" % (srpm.epoch, srpm.version)
77            else:
78                opts.version = srpm.version
79            opts.release = srpm.release
80        if appendname:
81            if not srpm:
82                srpm = SRPM(filename)
83            opts.pkgdirurl = "/".join([opts.pkgdirurl, srpm.name])
84    elif appendname:
85        raise Error, "option -n requires option -f"
86    elif not opts.revision:
87        raise Error, "no revision provided"
88    elif not opts.version:
89        raise Error, "no version provided"
90    get_auth()
91    return opts
92
93def main():
94    do_command(parse_options, mark_release)
95
96# vim:et:ts=4:sw=4
Note: See TracBrowser for help on using the repository browser.