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 | # |
---|
10 | from RepSys import Error |
---|
11 | from RepSys.command import * |
---|
12 | from RepSys.rpmutil import put_srpm |
---|
13 | import getopt |
---|
14 | import sys, os |
---|
15 | |
---|
16 | HELP = """\ |
---|
17 | *** WARNING --- You probably SHOULD NOT use this program! --- WARNING *** |
---|
18 | |
---|
19 | Usage: repsys putsrpm [OPTIONS] REPPKGURL |
---|
20 | |
---|
21 | Options: |
---|
22 | -n Append package name to provided URL |
---|
23 | -l LOG Use log when commiting changes |
---|
24 | -h Show this message |
---|
25 | |
---|
26 | Examples: |
---|
27 | repsys putsrpm file://svn/cnc/snapshot/foo /cnc/d/SRPMS/foo-1.0.src.rpm |
---|
28 | """ |
---|
29 | |
---|
30 | def parse_options(): |
---|
31 | parser = OptionParser(help=HELP) |
---|
32 | parser.add_option("-l", dest="log", default="") |
---|
33 | parser.add_option("-n", dest="appendname", action="store_true") |
---|
34 | opts, args = parser.parse_args() |
---|
35 | if len(args) != 2: |
---|
36 | raise Error, "invalid arguments" |
---|
37 | opts.pkgdirurl = default_parent(args[0]) |
---|
38 | opts.srpmfile = args[1] |
---|
39 | return opts |
---|
40 | |
---|
41 | def put_srpm_cmd(pkgdirurl, srpmfile, appendname=0, log=""): |
---|
42 | if os.path.isdir(srpmfile): |
---|
43 | dir = srpmfile |
---|
44 | for entry in os.listdir(dir): |
---|
45 | if entry[-8:] == ".src.rpm": |
---|
46 | sys.stderr.write("Putting %s... " % entry) |
---|
47 | sys.stderr.flush() |
---|
48 | entrypath = os.path.join(dir, entry) |
---|
49 | try: |
---|
50 | put_srpm(pkgdirurl, entrypath, appendname, log) |
---|
51 | sys.stderr.write("done\n") |
---|
52 | except Error, e: |
---|
53 | sys.stderr.write("error: %s\n" % str(e)) |
---|
54 | else: |
---|
55 | put_srpm(pkgdirurl, srpmfile, appendname, log) |
---|
56 | |
---|
57 | |
---|
58 | def main(): |
---|
59 | do_command(parse_options, put_srpm_cmd) |
---|
60 | |
---|
61 | # vim:et:ts=4:sw=4 |
---|