source: soft/build_system/build_system/repsys/tags/V1_6_14/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.2 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-1mdk"
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            nargs=1, type="string", dest="__ignore")
50    parser.add_option("-r", dest="revision")
51    parser.add_option("-f", dest="filename")
52    parser.add_option("-n", dest="appendname", action="store_true")
53    opts, args = parser.parse_args()
54
55    if len(args) != 1:
56        raise Error, "invalid arguments"
57
58    opts.pkgdirurl = default_parent(args[0])
59
60    filename = opts.filename
61    appendname = opts.appendname
62    del opts.filename, opts.appendname, opts.__ignore
63
64    if filename:
65        if not os.path.isfile(filename):
66            raise Error, "file not found: "+filename
67        if not opts.revision:
68            basename = os.path.basename(filename)
69            end = basename.find(":")
70            if basename[0] != "@" or end == -1:
71                raise Error, "couldn't guess revision from filename"
72            opts.revision = basename[1:end]
73        srpm = None
74        if not opts.version:
75            srpm = SRPM(filename)
76            if srpm.epoch:
77                opts.version = "%s:%s" % (srpm.epoch, srpm.version)
78            else:
79                opts.version = srpm.version
80            opts.release = srpm.release
81        if appendname:
82            if not srpm:
83                srpm = SRPM(filename)
84            opts.pkgdirurl = "/".join([opts.pkgdirurl, srpm.name])
85    elif appendname:
86        raise Error, "option -n requires option -f"
87    elif not opts.revision:
88        raise Error, "no revision provided"
89    elif not opts.version:
90        raise Error, "no version provided"
91    #get_auth()
92    return opts
93
94def main():
95    do_command(parse_options, mark_release)
96
97# vim:et:ts=4:sw=4
Note: See TracBrowser for help on using the repository browser.