aboutsummaryrefslogtreecommitdiffstats
path: root/RepSys/commands/putsrpm.py
blob: 21ad234871c8c299ef769c2f5eae7bbe76fe6e33 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/python
#
# This program will append a release to the Conectiva Linux package
# repository system.  It's meant to be a startup system to include
# pre-packaged SRPMS in the repository, thus, you should not commit
# packages over an ongoing package structure (with changes in current/
# directory and etc). Also, notice that packages must be included in
# cronological order.
#
from RepSys import Error
from RepSys.command import *
from RepSys.rpmutil import put_srpm
import getopt
import sys, os

HELP = """\
*** WARNING --- You probably SHOULD NOT use this program! --- WARNING ***

Usage: repsys putsrpm [OPTIONS] REPPKGURL

Options:
    -n      Append package name to provided URL
    -l LOG  Use log when commiting changes
    -h      Show this message

Examples:
    repsys putsrpm file://svn/cnc/snapshot/foo /cnc/d/SRPMS/foo-1.0.src.rpm
"""

def parse_options():
    parser = OptionParser(help=HELP)
    parser.add_option("-l", dest="log", default="")
    parser.add_option("-n", dest="appendname", action="store_true")
    opts, args = parser.parse_args()
    if len(args) != 2:
        raise Error, "invalid arguments"
    opts.pkgdirurl = default_parent(args[0])
    opts.srpmfile = args[1]
    return opts

def put_srpm_cmd(pkgdirurl, srpmfile, appendname=0, log=""):
    if os.path.isdir(srpmfile):
        dir = srpmfile
        for entry in os.listdir(dir):
            if entry[-8:] == ".src.rpm":
                sys.stderr.write("Putting %s... " % entry)
                sys.stderr.flush()
                entrypath = os.path.join(dir, entry)
                try:
                    put_srpm(pkgdirurl, entrypath, appendname, log)
                    sys.stderr.write("done\n")
                except Error, e:
                    sys.stderr.write("error: %s\n" % str(e))
    else:
        put_srpm(pkgdirurl, srpmfile, appendname, log)
        
                 
def main():
    do_command(parse_options, put_srpm_cmd)

# vim:et:ts=4:sw=4