]>
Commit | Line | Data |
---|---|---|
df78f748 MM |
1 | #!/usr/bin/env python |
2 | # vi: encoding=utf-8 ts=8 sts=4 sw=4 et | |
3 | ||
fdf5d714 | 4 | import getopt |
df78f748 MM |
5 | import sys, os |
6 | sys.path.insert(0, os.environ['HOME']+'/pld-ftp-admin/modules') | |
7 | from common import checkdir | |
796b7867 | 8 | from config import ftp_dir,all_ftp_archs |
0bf1ad60 | 9 | import config |
df78f748 MM |
10 | import ftpio |
11 | ||
fdf5d714 | 12 | try: |
bc8134ee | 13 | opts, args = getopt.getopt(sys.argv[1:], None, ["nopoldek", "noyum", "norpmrepo", "poldek", "yum", "rpmrepo"]) |
fdf5d714 | 14 | except getopt.GetoptError: |
8911f226 ER |
15 | print >>sys.stderr, "ERR: not enough parameters given" |
16 | print >>sys.stderr, "gen-indexes.py [--[no]poldek] [--[no]yum] [--[no]rpmrepo] tree [tree2...]" | |
df78f748 MM |
17 | sys.exit(1) |
18 | ||
fdf5d714 AM |
19 | do_poldek = True |
20 | do_yum = True | |
bc8134ee | 21 | do_rpmrepo = False |
fbfae074 | 22 | do_quiet = False |
fdf5d714 AM |
23 | |
24 | for o, a in opts: | |
25 | if o == "--nopoldek": | |
26 | do_poldek = False | |
27 | if o == "--noyum": | |
28 | do_yum = False | |
bc8134ee ER |
29 | if o == "--norpmrepo": |
30 | do_rpmrepo = False | |
31 | ||
32 | if o == "--poldek": | |
33 | do_poldek = True | |
34 | if o == "--yum": | |
35 | do_yum = True | |
36 | if o == "--rpmrepo": | |
37 | do_rpmrepo = True | |
38 | ||
fbfae074 AM |
39 | if o == "--quiet": |
40 | do_quiet = True | |
41 | ||
bc8134ee | 42 | if not do_poldek and not do_yum and not do_rpmrepo: |
8911f226 | 43 | print >>sys.stderr, "ERR: speciy at least one action" |
fdf5d714 AM |
44 | sys.exit(1) |
45 | ||
8911f226 | 46 | trees = args |
df78f748 MM |
47 | |
48 | for tree in trees: | |
49 | checkdir(tree) | |
50 | ||
51 | ftpio.connect('gen-indexes') | |
52 | ||
8911f226 | 53 | locked = [] |
df78f748 MM |
54 | |
55 | for tree in trees: | |
56 | if ftpio.lock(tree, True): | |
57 | locked.append(tree) | |
58 | else: | |
fbfae074 AM |
59 | if not do_quiet: |
60 | print >>sys.stderr, "ERR: %s tree already locked" % tree | |
df78f748 MM |
61 | for i in locked: |
62 | ftpio.unlock(i) | |
63 | sys.exit(1) | |
64 | ||
8911f226 | 65 | home = os.environ['HOME'] |
df78f748 | 66 | |
65473a80 | 67 | os.umask(022) |
728ca432 | 68 | os.nice(19) |
65473a80 | 69 | |
fdf5d714 | 70 | if do_poldek: |
8911f226 ER |
71 | poldek = '%s.stat/bin/poldek-new --cachedir=%s/tmp/poldek --conf %s.stat/etc/poldek.conf --mkidxz' % (ftp_dir, home, ftp_dir) |
72 | ||
fdf5d714 | 73 | for tree in trees: |
fa0549d4 | 74 | print '\n-------------------------- %s --------------------------' % tree |
fdf5d714 | 75 | for arch in all_ftp_archs: |
fa0549d4 | 76 | print '\ngenerate poldek index for %s' % arch |
8911f226 ER |
77 | if config.poldek_indexes != "old": |
78 | os.system('%s -s %s%s/%s/RPMS/ --mkidxz --mkidx-type pndir' % (poldek, ftp_dir, tree, arch)) | |
f7ba8f7b | 79 | if arch != 'noarch' and config.separate_debuginfo: |
54ff0049 | 80 | os.system('%s -s %s%s/%s/debuginfo/ --mkidxz --mkidx-type pndir' % (poldek, ftp_dir, tree, arch)) |
8911f226 ER |
81 | if config.poldek_indexes != "new": |
82 | os.system('%s -s %s%s/%s/RPMS/ --mkidxz --mkidx-type pdir' % (poldek, ftp_dir, tree, arch)) | |
f7ba8f7b | 83 | if arch != 'noarch' and config.separate_debuginfo: |
54ff0049 | 84 | os.system('%s -s %s%s/%s/debuginfo/ --mkidxz --mkidx-type pdir' % (poldek, ftp_dir, tree, arch)) |
fdf5d714 AM |
85 | |
86 | if do_yum: | |
6147d093 | 87 | os.system('%s cd %s.stat/repodata && cvs %s up comps.xml' % ("" if do_quiet else "set -x;", ftp_dir, "" if do_quiet else "-Q")) |
8911f226 | 88 | yum = '%s.stat/bin/createrepo -d -g %s.stat/repodata/comps.xml' % (ftp_dir, ftp_dir) |
fdf5d714 | 89 | for tree in trees: |
fa0549d4 | 90 | print '\n-------------------------- %s --------------------------' % tree |
8911f226 | 91 | cachedir = '%s/tmp/createrepo/%s' % (home, tree) |
fdf5d714 | 92 | for arch in all_ftp_archs: |
fa0549d4 | 93 | print '\ngenerate repodata for %s using createrepo' % arch |
fdf5d714 | 94 | # Creating indexes for yum and other supporting xml repodata. |
386310ed | 95 | os.system('%s %s --cache %s-%s %s%s/%s/RPMS' % ("" if do_quiet else "time", yum, cachedir, arch, ftp_dir, tree, arch)) |
f7ba8f7b | 96 | if arch != 'noarch' and config.separate_debuginfo: |
386310ed | 97 | os.system('%s %s --cache %s-%s %s%s/%s/debuginfo' % ("" if do_quiet else "time", yum, cachedir, arch, ftp_dir, tree, arch)) |
df78f748 | 98 | |
bc8134ee | 99 | if do_rpmrepo: |
6147d093 | 100 | os.system('%s cd %s.stat/repodata && cvs %s up comps.xml' % ("" if do_quiet else "set -x;", ftp_dir, "" if do_quiet else "-Q")) |
bc8134ee | 101 | for tree in trees: |
fa0549d4 | 102 | print '\n-------------------------- %s --------------------------' % tree |
bc8134ee ER |
103 | for arch in all_ftp_archs: |
104 | dir = '%s/%s/%s/RPMS' % (ftp_dir, tree, arch) | |
386310ed AM |
105 | if not do_quiet: |
106 | print '\ngenerate repodata for %s using rpmrepo (in %s)' % (arch, dir) | |
107 | os.system('%s rpmrepo %s -o %s' % ("" if do_quiet else "set -x;", dir, dir)) | |
108 | if not do_quiet: | |
109 | print 'copy comps.xml' | |
7444a3de | 110 | comps = '%s.stat/repodata/comps.xml' % ftp_dir |
386310ed | 111 | os.system('%s cp -p %s %s/repodata' % ("" if do_quiet else "set -x;", comps, dir)) |
bc8134ee | 112 | |
df78f748 MM |
113 | for tree in trees: |
114 | ftpio.unlock(tree) |