]> git.pld-linux.org Git - projects/pld-ftp-admin.git/blame - bin/pfa-genindex
- be nicer to other
[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 52os.umask(022)
728ca432 53os.nice(19)
65473a80 54
fdf5d714
AM
55if 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
71if do_yum:
72 for tree in trees:
73 print '-------------------------- %s --------------------------' % tree
74 for arch in all_ftp_archs:
75 print 'ARCHITECTURE: %s' % arch
76 # Creating indexes for yum and other supporting xml repodata.
77 os.system('%s.stat/bin/createrepo --cache %s/tmp/createrepo/%s-%s %s%s/%s/RPMS' %
78 (ftp_dir,home,tree,arch,ftp_dir,tree,arch))
df78f748
MM
79
80for tree in trees:
81 ftpio.unlock(tree)
82
This page took 0.036248 seconds and 4 git commands to generate.