source: soft/build_system/build_system/repsys/branches/V1_5_3/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: 2.7 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    -h      Show this message
30
31Examples:
32    repsys getsrpm http://foo.bar/svn/cnc/snapshot/python
33    repsys getsrpm -p http://foo.bar/svn/cnc/releases/8cl/python
34    repsys getsrpm -r 1001 file:///svn/cnc/snapshot/python
35"""
36
37def mode_callback(option, opt, val, parser, mode):
38    opts = parser.values
39    opts.mode = mode
40    if mode == "version":
41        try:
42            opts.version, opts.release = val.split("-", 1)
43        except ValueError:
44            raise Error, "wrong version, use something like 2.2-1cl"
45    elif mode == "revision":
46        opts.revision = val
47
48def parse_options():
49    parser = OptionParser(help=HELP)
50    parser.defaults["mode"] = "current"
51    parser.defaults["version"] = None
52    parser.defaults["release"] = None
53    parser.defaults["revision"] = None
54    parser.add_option("-c", action="callback", callback=mode_callback,
55                      callback_kwargs={"mode": "current"})
56    parser.add_option("-p", action="callback", callback=mode_callback,
57                      callback_kwargs={"mode": "pristine"})
58    parser.add_option("-r", action="callback", callback=mode_callback,
59                      callback_kwargs={"mode": "revision"})
60    parser.add_option("-v", action="callback", callback=mode_callback,
61                      callback_kwargs={"mode": "version"})
62    parser.add_option("-t", dest="targetdirs", action="append", default=[])
63    parser.add_option("-s", dest="scripts", action="append", default=[])
64    parser.add_option("-P", dest="packager", default="")
65    parser.add_option("-n", dest="revname", action="store_true")
66    parser.add_option("-l", dest="svnlog", action="store_true")
67    opts, args = parser.parse_args()
68    if len(args) != 1:
69        raise Error, "invalid arguments"
70    opts.pkgdirurl = default_parent(args[0])
71    return opts
72
73def main():
74    do_command(parse_options, get_srpm)
75
76# vim:et:ts=4:sw=4
Note: See TracBrowser for help on using the repository browser.