]> git.pld-linux.org Git - projects/pld-ftp-admin.git/blame - bin/pfa-genindex
- use rpm.RPMVSF_NODSAHEADER where we had NOSIGNATURES in rpm4
[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
a7ab51cd
ER
29# update only if changed (applicable to yum)
30freshen = True
fdf5d714
AM
31
32for o, a in opts:
33 if o == "--nopoldek":
34 do_poldek = False
35 if o == "--noyum":
36 do_yum = False
bc8134ee
ER
37 if o == "--norpmrepo":
38 do_rpmrepo = False
39
40 if o == "--poldek":
41 do_poldek = True
42 if o == "--yum":
43 do_yum = True
44 if o == "--rpmrepo":
45 do_rpmrepo = True
46
b4c008d4
ER
47 if o == "-q" or o == "--quiet":
48 quiet = True
49
50 if o == "--index":
51 do_poldek = do_yum = do_rpmrepo = False
52 for v in a.split(','):
53 if v == 'poldek':
54 do_poldek = True
55 if v == 'yum':
56 do_yum = True
57 if v == 'rpmrepo':
58 do_rpmrepo = True
59
60if not quiet:
61 print "poldek: %s; yum: %s; rpmrepo: %s" % (do_poldek, do_yum, do_rpmrepo)
fbfae074 62
bc8134ee 63if not do_poldek and not do_yum and not do_rpmrepo:
8911f226 64 print >>sys.stderr, "ERR: speciy at least one action"
fdf5d714
AM
65 sys.exit(1)
66
8911f226 67trees = args
df78f748
MM
68
69for tree in trees:
70 checkdir(tree)
71
72ftpio.connect('gen-indexes')
73
8911f226 74locked = []
df78f748
MM
75
76for tree in trees:
77 if ftpio.lock(tree, True):
78 locked.append(tree)
79 else:
b4c008d4 80 if not quiet:
fbfae074 81 print >>sys.stderr, "ERR: %s tree already locked" % tree
df78f748
MM
82 for i in locked:
83 ftpio.unlock(i)
84 sys.exit(1)
85
8911f226 86home = os.environ['HOME']
df78f748 87
65473a80 88os.umask(022)
728ca432 89os.nice(19)
65473a80 90
fdf5d714 91if do_poldek:
8911f226
ER
92 poldek = '%s.stat/bin/poldek-new --cachedir=%s/tmp/poldek --conf %s.stat/etc/poldek.conf --mkidxz' % (ftp_dir, home, ftp_dir)
93
fdf5d714 94 for tree in trees:
fa0549d4 95 print '\n-------------------------- %s --------------------------' % tree
fdf5d714 96 for arch in all_ftp_archs:
fa0549d4 97 print '\ngenerate poldek index for %s' % arch
255b5e63
ER
98 os.system('%s -s %s%s/%s/RPMS/ --mkidxz --mkidx-type pndir' % (poldek, ftp_dir, tree, arch))
99 if arch != 'noarch' and config.separate_debuginfo:
100 os.system('%s -s %s%s/%s/debuginfo/ --mkidxz --mkidx-type pndir' % (poldek, ftp_dir, tree, arch))
fdf5d714
AM
101
102if do_yum:
b4c008d4 103 os.system('%s cd %s.stat/repodata && cvs %s up comps.xml' % ("" if quiet else "set -x;", ftp_dir, "" if quiet else "-Q"))
b1b2ab1f 104 yum = '%s.stat/bin/createrepo -d -v --skip-stat --workers=12 -g %s.stat/repodata/comps.xml' % (ftp_dir, ftp_dir)
fdf5d714 105 for tree in trees:
fa0549d4 106 print '\n-------------------------- %s --------------------------' % tree
8911f226 107 cachedir = '%s/tmp/createrepo/%s' % (home, tree)
b1b2ab1f 108 treedir = "%s%s" % (ftp_dir, tree)
fdf5d714 109 for arch in all_ftp_archs:
fa0549d4 110 print '\ngenerate repodata for %s using createrepo' % arch
b1b2ab1f 111 archdir = "%s/%s" % (treedir, arch)
a7ab51cd
ER
112 poldek_idx = "%s/RPMS/packages.ndir.md" % archdir
113 repodata_idx = "%s/RPMS/repodata/repomd.xml" % archdir
114 if freshen and os.path.exists(poldek_idx) and os.path.exists(repodata_idx) and not os.path.getmtime(poldek_idx) > os.path.getmtime(repodata_idx):
115 print "repodata indexes already fresh"
116 continue
b1b2ab1f
ER
117 print ('%s %s --cache %s-%s %s/RPMS' % ("" if quiet else "time", yum, cachedir, arch, archdir))
118 os.system('%s %s --cache %s-%s %s/RPMS' % ("" if quiet else "time", yum, cachedir, arch, archdir))
f7ba8f7b 119 if arch != 'noarch' and config.separate_debuginfo:
b1b2ab1f 120 os.system('%s %s --cache %s-%s %s/debuginfo' % ("" if quiet else "time", yum, cachedir, arch, archdir))
df78f748 121
bc8134ee 122if do_rpmrepo:
b4c008d4 123 os.system('%s cd %s.stat/repodata && cvs %s up comps.xml' % ("" if quiet else "set -x;", ftp_dir, "" if quiet else "-Q"))
bc8134ee 124 for tree in trees:
fa0549d4 125 print '\n-------------------------- %s --------------------------' % tree
bc8134ee
ER
126 for arch in all_ftp_archs:
127 dir = '%s/%s/%s/RPMS' % (ftp_dir, tree, arch)
b4c008d4 128 if not quiet:
386310ed 129 print '\ngenerate repodata for %s using rpmrepo (in %s)' % (arch, dir)
b4c008d4
ER
130 os.system('%s rpmrepo %s -o %s' % ("" if quiet else "set -x;", dir, dir))
131 if not quiet:
386310ed 132 print 'copy comps.xml'
7444a3de 133 comps = '%s.stat/repodata/comps.xml' % ftp_dir
b4c008d4 134 os.system('%s cp -p %s %s/repodata' % ("" if quiet else "set -x;", comps, dir))
bc8134ee 135
df78f748
MM
136for tree in trees:
137 ftpio.unlock(tree)
This page took 0.110336 seconds and 4 git commands to generate.