]>
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 AM |
12 | try: |
13 | opts, args = getopt.getopt(sys.argv[1:], None, ["nopoldek", "noyum"]) | |
14 | except getopt.GetoptError: | |
749b120d | 15 | print "ERR: not enough parameters given" |
fdf5d714 | 16 | print "gen-indexes.py [--nopoldek] [--noyum] tree [tree2...]" |
df78f748 MM |
17 | sys.exit(1) |
18 | ||
fdf5d714 AM |
19 | do_poldek = True |
20 | do_yum = True | |
21 | ||
22 | for o, a in opts: | |
23 | if o == "--nopoldek": | |
24 | do_poldek = False | |
25 | if o == "--noyum": | |
26 | do_yum = False | |
27 | ||
28 | if not do_poldek and not do_yum: | |
29 | print "ERR: option --nopoldek conflicts with --noyum" | |
30 | sys.exit(1) | |
31 | ||
32 | trees=args | |
df78f748 MM |
33 | |
34 | for tree in trees: | |
35 | checkdir(tree) | |
36 | ||
37 | ftpio.connect('gen-indexes') | |
38 | ||
39 | locked=[] | |
40 | ||
41 | for tree in trees: | |
42 | if ftpio.lock(tree, True): | |
43 | locked.append(tree) | |
44 | else: | |
749b120d | 45 | print "ERR: %s tree already locked" % tree |
df78f748 MM |
46 | for i in locked: |
47 | ftpio.unlock(i) | |
48 | sys.exit(1) | |
49 | ||
50 | home=os.environ['HOME'] | |
51 | ||
65473a80 | 52 | os.umask(022) |
728ca432 | 53 | os.nice(19) |
65473a80 | 54 | |
fdf5d714 AM |
55 | if do_poldek: |
56 | for tree in trees: | |
57 | print '-------------------------- %s --------------------------' % tree | |
58 | for arch in all_ftp_archs: | |
59 | print 'ARCHITECTURE: %s' % arch | |
60 | if config.old_poldek: | |
61 | os.system('%s.stat/bin/poldek --cachedir=%s/tmp/poldek -c %s.stat/etc/poldek.conf -s %s%s/%s/RPMS/ --mkidxz' % | |
62 | (ftp_dir,home,ftp_dir,ftp_dir,tree,arch)) | |
63 | else: | |
64 | if config.poldek_indexes != "old": | |
65 | os.system('%s.stat/bin/poldek-new --cachedir=%s/tmp/poldek --conf %s.stat/etc/poldek.conf -s %s%s/%s/RPMS/ --mkidxz --mkidx-type pndir' % | |
66 | (ftp_dir,home,ftp_dir,ftp_dir,tree,arch)) | |
67 | if config.poldek_indexes != "new": | |
68 | os.system('%s.stat/bin/poldek-new --cachedir=%s/tmp/poldek --conf %s.stat/etc/poldek.conf -s %s%s/%s/RPMS/ --mkidxz --mkidx-type pdir' % | |
69 | (ftp_dir,home,ftp_dir,ftp_dir,tree,arch)) | |
70 | ||
71 | if do_yum: | |
04306c00 | 72 | os.system('cd %s.stat/repodata && cvs up comps.xml' % ftp_dir) |
fdf5d714 AM |
73 | for tree in trees: |
74 | print '-------------------------- %s --------------------------' % tree | |
75 | for arch in all_ftp_archs: | |
76 | print 'ARCHITECTURE: %s' % arch | |
77 | # Creating indexes for yum and other supporting xml repodata. | |
4e78461d | 78 | os.system('%s.stat/bin/createrepo -d -g %s.stat/repodata/comps.xml --cache %s/tmp/createrepo/%s-%s %s%s/%s/RPMS' % |
5458b671 | 79 | (ftp_dir,ftp_dir,home,tree,arch,ftp_dir,tree,arch)) |
df78f748 MM |
80 | |
81 | for tree in trees: | |
82 | ftpio.unlock(tree) | |
83 |