]> git.pld-linux.org Git - projects/pld-ftp-admin.git/blame - bin/pfa-genindex
- simple tool to verify if packages are signed
[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 12try:
b4c008d4
ER
13 opts, args = getopt.getopt(sys.argv[1:], 'q',
14 [
15 "quiet", "index=",
16 "nopoldek", "noyum", "norpmrepo",
17 "poldek", "yum", "rpmrepo"
18 ]
19 )
fdf5d714 20except getopt.GetoptError:
8911f226 21 print >>sys.stderr, "ERR: not enough parameters given"
053d2c0e 22 print >>sys.stderr, "gen-indexes.py [--quiet] [--[no]poldek] [--[no]yum] [--[no]rpmrepo] tree [tree2...]"
df78f748
MM
23 sys.exit(1)
24
fdf5d714 25do_poldek = True
d9bbfa2e 26do_yum = False
bc8134ee 27do_rpmrepo = False
b4c008d4 28quiet = False
fdf5d714
AM
29
30for o, a in opts:
31 if o == "--nopoldek":
32 do_poldek = False
33 if o == "--noyum":
34 do_yum = False
bc8134ee
ER
35 if o == "--norpmrepo":
36 do_rpmrepo = False
37
38 if o == "--poldek":
39 do_poldek = True
40 if o == "--yum":
41 do_yum = True
42 if o == "--rpmrepo":
43 do_rpmrepo = True
44
b4c008d4
ER
45 if o == "-q" or o == "--quiet":
46 quiet = True
47
48 if o == "--index":
49 do_poldek = do_yum = do_rpmrepo = False
50 for v in a.split(','):
51 if v == 'poldek':
52 do_poldek = True
53 if v == 'yum':
54 do_yum = True
55 if v == 'rpmrepo':
56 do_rpmrepo = True
57
58if not quiet:
59 print "poldek: %s; yum: %s; rpmrepo: %s" % (do_poldek, do_yum, do_rpmrepo)
fbfae074 60
bc8134ee 61if not do_poldek and not do_yum and not do_rpmrepo:
8911f226 62 print >>sys.stderr, "ERR: speciy at least one action"
fdf5d714
AM
63 sys.exit(1)
64
8911f226 65trees = args
df78f748
MM
66
67for tree in trees:
68 checkdir(tree)
69
70ftpio.connect('gen-indexes')
71
8911f226 72locked = []
df78f748
MM
73
74for tree in trees:
75 if ftpio.lock(tree, True):
76 locked.append(tree)
77 else:
b4c008d4 78 if not quiet:
fbfae074 79 print >>sys.stderr, "ERR: %s tree already locked" % tree
df78f748
MM
80 for i in locked:
81 ftpio.unlock(i)
82 sys.exit(1)
83
8911f226 84home = os.environ['HOME']
df78f748 85
65473a80 86os.umask(022)
728ca432 87os.nice(19)
65473a80 88
fdf5d714 89if do_poldek:
8911f226
ER
90 poldek = '%s.stat/bin/poldek-new --cachedir=%s/tmp/poldek --conf %s.stat/etc/poldek.conf --mkidxz' % (ftp_dir, home, ftp_dir)
91
fdf5d714 92 for tree in trees:
fa0549d4 93 print '\n-------------------------- %s --------------------------' % tree
fdf5d714 94 for arch in all_ftp_archs:
fa0549d4 95 print '\ngenerate poldek index for %s' % arch
8911f226
ER
96 if config.poldek_indexes != "old":
97 os.system('%s -s %s%s/%s/RPMS/ --mkidxz --mkidx-type pndir' % (poldek, ftp_dir, tree, arch))
f7ba8f7b 98 if arch != 'noarch' and config.separate_debuginfo:
54ff0049 99 os.system('%s -s %s%s/%s/debuginfo/ --mkidxz --mkidx-type pndir' % (poldek, ftp_dir, tree, arch))
8911f226
ER
100 if config.poldek_indexes != "new":
101 os.system('%s -s %s%s/%s/RPMS/ --mkidxz --mkidx-type pdir' % (poldek, ftp_dir, tree, arch))
f7ba8f7b 102 if arch != 'noarch' and config.separate_debuginfo:
54ff0049 103 os.system('%s -s %s%s/%s/debuginfo/ --mkidxz --mkidx-type pdir' % (poldek, ftp_dir, tree, arch))
fdf5d714
AM
104
105if do_yum:
b4c008d4 106 os.system('%s cd %s.stat/repodata && cvs %s up comps.xml' % ("" if quiet else "set -x;", ftp_dir, "" if quiet else "-Q"))
8911f226 107 yum = '%s.stat/bin/createrepo -d -g %s.stat/repodata/comps.xml' % (ftp_dir, ftp_dir)
fdf5d714 108 for tree in trees:
fa0549d4 109 print '\n-------------------------- %s --------------------------' % tree
8911f226 110 cachedir = '%s/tmp/createrepo/%s' % (home, tree)
fdf5d714 111 for arch in all_ftp_archs:
fa0549d4 112 print '\ngenerate repodata for %s using createrepo' % arch
fdf5d714 113 # Creating indexes for yum and other supporting xml repodata.
b4c008d4 114 os.system('%s %s --cache %s-%s %s%s/%s/RPMS' % ("" if quiet else "time", yum, cachedir, arch, ftp_dir, tree, arch))
f7ba8f7b 115 if arch != 'noarch' and config.separate_debuginfo:
b4c008d4 116 os.system('%s %s --cache %s-%s %s%s/%s/debuginfo' % ("" if quiet else "time", yum, cachedir, arch, ftp_dir, tree, arch))
df78f748 117
bc8134ee 118if do_rpmrepo:
b4c008d4 119 os.system('%s cd %s.stat/repodata && cvs %s up comps.xml' % ("" if quiet else "set -x;", ftp_dir, "" if quiet else "-Q"))
bc8134ee 120 for tree in trees:
fa0549d4 121 print '\n-------------------------- %s --------------------------' % tree
bc8134ee
ER
122 for arch in all_ftp_archs:
123 dir = '%s/%s/%s/RPMS' % (ftp_dir, tree, arch)
b4c008d4 124 if not quiet:
386310ed 125 print '\ngenerate repodata for %s using rpmrepo (in %s)' % (arch, dir)
b4c008d4
ER
126 os.system('%s rpmrepo %s -o %s' % ("" if quiet else "set -x;", dir, dir))
127 if not quiet:
386310ed 128 print 'copy comps.xml'
7444a3de 129 comps = '%s.stat/repodata/comps.xml' % ftp_dir
b4c008d4 130 os.system('%s cp -p %s %s/repodata' % ("" if quiet else "set -x;", comps, dir))
bc8134ee 131
df78f748
MM
132for tree in trees:
133 ftpio.unlock(tree)
This page took 0.129936 seconds and 4 git commands to generate.