]> git.pld-linux.org Git - projects/pld-ftp-admin.git/blob - bin/pfa-genindex
c89f66b9ff516e9d82199210870d5c498731684d
[projects/pld-ftp-admin.git] / bin / pfa-genindex
1 #!/usr/bin/env python
2 # vi: encoding=utf-8 ts=8 sts=4 sw=4 et
3
4 import getopt
5 import sys, os
6 sys.path.insert(0, os.environ['HOME']+'/pld-ftp-admin/modules')
7 from common import checkdir
8 from config import ftp_dir,all_ftp_archs
9 import config
10 import ftpio
11
12 try:
13     opts, args = getopt.getopt(sys.argv[1:], None, ["nopoldek", "noyum"])
14 except getopt.GetoptError:
15     print "ERR: not enough parameters given"
16     print "gen-indexes.py [--nopoldek] [--noyum] tree [tree2...]"
17     sys.exit(1)
18
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
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:
45         print "ERR: %s tree already locked" % tree
46         for i in locked:
47             ftpio.unlock(i)
48         sys.exit(1)
49
50 home=os.environ['HOME']
51
52 os.umask(022)
53
54 if do_poldek:
55     for tree in trees:
56         print '-------------------------- %s --------------------------' % tree
57         for arch in all_ftp_archs:
58             print 'ARCHITECTURE: %s' % arch
59             if config.old_poldek:
60                 os.system('%s.stat/bin/poldek --cachedir=%s/tmp/poldek -c %s.stat/etc/poldek.conf -s %s%s/%s/RPMS/ --mkidxz' %
61                     (ftp_dir,home,ftp_dir,ftp_dir,tree,arch))
62             else:
63                 if config.poldek_indexes != "old":
64                     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' %
65                             (ftp_dir,home,ftp_dir,ftp_dir,tree,arch))
66                 if config.poldek_indexes != "new":
67                     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' %
68                             (ftp_dir,home,ftp_dir,ftp_dir,tree,arch))
69
70 if do_yum:
71     for tree in trees:
72         print '-------------------------- %s --------------------------' % tree
73         for arch in all_ftp_archs:
74             print 'ARCHITECTURE: %s' % arch
75             # Creating indexes for yum and other supporting xml repodata.
76             os.system('%s.stat/bin/createrepo --cache %s/tmp/createrepo/%s-%s %s%s/%s/RPMS' %
77                     (ftp_dir,home,tree,arch,ftp_dir,tree,arch))
78
79 for tree in trees:
80     ftpio.unlock(tree)
81
This page took 0.037669 seconds and 2 git commands to generate.