source: soft/build_system/build_system/repsys/trunk/RepSys/commands/getsrpm.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.0 KB
Line 
1#!/usr/bin/python
2#
3# This program will extract given version/revision of the named package
4# from the Conectiva Linux repository system.
5#
6from RepSys import Error, config
7from RepSys.command import *
8from RepSys.rpmutil import get_srpm
9import tempfile
10import shutil
11import getopt
12import glob
13import sys
14import os
15
16HELP = """\
17Usage: repsys getsrpm [OPTIONS] REPPKGURL
18
19Options:
20    -c      Use files in current/ directory (default)
21    -p      Use files in pristine/ directory
22    -v VER  Use files from the version specified by VER (e.g. 2.2.1-2cl)
23    -r REV  Use files from current directory, in revision REV (e.g. 1001)
24    -t DIR  Put SRPM file in directory DIR when done (default is ".")
25    -P USER Define the RPM packager inforamtion to USER
26    -s FILE Run script with "FILE TOPDIR SPECFILE" command
27    -n      Rename the package to include the revision number
28    -l      Use subversion log to build rpm %changelog
29    -T FILE Template to be used to generate the %changelog
30    -h      Show this message
31
32Examples:
33    repsys getsrpm http://foo.bar/svn/cnc/snapshot/python
34    repsys getsrpm -p http://foo.bar/svn/cnc/releases/8cl/python
35    repsys getsrpm -r 1001 file:///svn/cnc/snapshot/python
36"""
37
38def mode_callback(option, opt, val, parser, mode):
39    opts = parser.values
40    opts.mode = mode
41    if mode == "version":
42        try:
43            opts.version, opts.release = val.split("-", 1)
44        except ValueError:
45            raise Error, "wrong version, use something like 2.2-1mdk"
46    elif mode == "revision":
47        opts.revision = val
48
49def parse_options():
50    parser = OptionParser(help=HELP)
51    parser.defaults["mode"] = "current"
52    parser.defaults["version"] = None
53    parser.defaults["release"] = None
54    parser.defaults["revision"] = None
55    parser.defaults["submit"] = False
56    callback_options = dict(action="callback", callback=mode_callback,
57                            type="string", dest="__ignore")
58    parser.add_option("-c", callback_kwargs={"mode": "current"}, nargs=0,
59                      **callback_options)
60    parser.add_option("-p", callback_kwargs={"mode": "pristine"}, nargs=0,
61                      **callback_options)
62    parser.add_option("-r", callback_kwargs={"mode": "revision"}, nargs=1,
63                      **callback_options)
64    parser.add_option("-v", callback_kwargs={"mode": "version"}, nargs=1,
65                      **callback_options)
66    parser.add_option("-t", dest="targetdirs", action="append", default=[])
67    parser.add_option("-s", dest="scripts", action="append", default=[])
68    parser.add_option("-P", dest="packager", default="")
69    parser.add_option("-n", dest="revname", action="store_true")
70    parser.add_option("-l", dest="svnlog", action="store_true")
71    parser.add_option("-T", dest="template", type="string", default=None)
72    opts, args = parser.parse_args()
73    del opts.__ignore
74    if len(args) != 1:
75        raise Error, "invalid arguments"
76    opts.pkgdirurl = default_parent(args[0])
77    opts.verbose = 1
78    return opts
79
80def main():
81    do_command(parse_options, get_srpm)
82
83# vim:et:ts=4:sw=4
Note: See TracBrowser for help on using the repository browser.