]> git.pld-linux.org Git - projects/pld-ftp-admin.git/blame - bin/pfa-genindex
- add options --nopoldek and --noyum
[projects/pld-ftp-admin.git] / bin / pfa-genindex
CommitLineData
df78f748
MM
1#!/usr/bin/env python
2# vi: encoding=utf-8 ts=8 sts=4 sw=4 et
3
fdf5d714 4import getopt
df78f748
MM
5import sys, os
6sys.path.insert(0, os.environ['HOME']+'/pld-ftp-admin/modules')
7from common import checkdir
796b7867 8from config import ftp_dir,all_ftp_archs
0bf1ad60 9import config
df78f748
MM
10import ftpio
11
fdf5d714
AM
12try:
13 opts, args = getopt.getopt(sys.argv[1:], None, ["nopoldek", "noyum"])
14except 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
19do_poldek = True
20do_yum = True
21
22for o, a in opts:
23 if o == "--nopoldek":
24 do_poldek = False
25 if o == "--noyum":
26 do_yum = False
27
28if not do_poldek and not do_yum:
29 print "ERR: option --nopoldek conflicts with --noyum"
30 sys.exit(1)
31
32trees=args
df78f748
MM
33
34for tree in trees:
35 checkdir(tree)
36
37ftpio.connect('gen-indexes')
38
39locked=[]
40
41for 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
50home=os.environ['HOME']
51
65473a80
AM
52os.umask(022)
53
fdf5d714
AM
54if 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
70if 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))
df78f748
MM
78
79for tree in trees:
80 ftpio.unlock(tree)
81
This page took 0.043159 seconds and 4 git commands to generate.