2 # vi: encoding=utf-8 ts=8 sts=4 sw=4 et
4 from __future__ import print_function
8 sys.path.insert(0, os.environ['HOME']+'/tld-ftp-admin/modules')
9 from common import checkdir
10 from config import ftp_dir,all_ftp_archs
15 opts, args = getopt.getopt(sys.argv[1:], 'q',
18 "nopoldek", "noyum", "norpmrepo",
19 "poldek", "yum", "rpmrepo"
22 except getopt.GetoptError:
23 print("ERR: not enough parameters given", file=sys.stderr)
24 print("gen-indexes.py [--quiet] [--[no]poldek] [--[no]yum] [--[no]rpmrepo] tree [tree2...]", file=sys.stderr)
31 # update only if changed (applicable to yum)
39 if o == "--norpmrepo":
49 if o == "-q" or o == "--quiet":
53 do_poldek = do_yum = do_rpmrepo = False
54 for v in a.split(','):
63 print("poldek: %s; yum: %s; rpmrepo: %s" % (do_poldek, do_yum, do_rpmrepo))
65 if not do_poldek and not do_yum and not do_rpmrepo:
66 print("ERR: speciy at least one action", file=sys.stderr)
74 ftpio.connect('gen-indexes')
79 if ftpio.lock(tree, True):
82 print("ERR: %s tree already locked" % tree, file=sys.stderr)
87 home = os.environ['HOME']
93 poldek = '%s.stat/bin/poldek-new --cachedir=%s/tmp/poldek --conf %s.stat/etc/poldek.conf --mkidxz' % (ftp_dir, home, ftp_dir)
96 print('\n-------------------------- %s --------------------------' % tree)
97 for arch in all_ftp_archs:
98 print('\ngenerate poldek index for %s' % arch)
99 print('%s -s %s%s/%s/RPMS/ --mkidxz --mkidx-type pndir' % (poldek, ftp_dir, tree, arch))
100 os.system('%s -s %s%s/%s/RPMS/ --mkidxz --mkidx-type pndir' % (poldek, ftp_dir, tree, arch))
101 if arch != 'noarch' and config.separate_debuginfo:
102 os.system('%s -s %s%s/%s/debuginfo/ --mkidxz --mkidx-type pndir' % (poldek, ftp_dir, tree, arch))
105 os.system('%s cd %s.stat/repodata && cvs %s up comps.xml' % ("" if quiet else "set -x;", ftp_dir, "" if quiet else "-Q"))
106 yum = '%s.stat/bin/createrepo -d -v --update --checkts --skip-stat --workers=12 -g %s.stat/repodata/comps.xml' % (ftp_dir, ftp_dir)
107 comps_file = '%s.stat/repodata/comps.xml' % ftp_dir
109 print('\n-------------------------- %s --------------------------' % tree)
110 cachedir = '%s/tmp/createrepo/%s' % (home, tree)
111 treedir = "%s%s" % (ftp_dir, tree)
112 for arch in all_ftp_archs:
113 print('\ngenerate repodata for %s using createrepo' % arch)
114 archdir = "%s/%s" % (treedir, arch)
115 poldek_idx = "%s/RPMS/packages.ndir.md" % archdir
116 repodata_idx = "%s/RPMS/repodata/repomd.xml" % archdir
117 if freshen and os.path.exists(poldek_idx) and os.path.exists(repodata_idx) \
118 and not os.path.getmtime(comps_file) > os.path.getmtime(repodata_idx) \
119 and not os.path.getmtime(poldek_idx) > os.path.getmtime(repodata_idx):
120 print("repodata indexes already fresh")
122 print('%s %s --cache %s-%s %s/RPMS' % ("" if quiet else "time", yum, cachedir, arch, archdir))
123 os.system('%s %s --cache %s-%s %s/RPMS' % ("" if quiet else "time", yum, cachedir, arch, archdir))
124 if arch != 'noarch' and config.separate_debuginfo:
125 os.system('%s %s --cache %s-%s %s/debuginfo' % ("" if quiet else "time", yum, cachedir, arch, archdir))
128 os.system('%s cd %s.stat/repodata && cvs %s up comps.xml' % ("" if quiet else "set -x;", ftp_dir, "" if quiet else "-Q"))
130 print('\n-------------------------- %s --------------------------' % tree)
131 for arch in all_ftp_archs:
132 dir = '%s/%s/%s/RPMS' % (ftp_dir, tree, arch)
134 print('\ngenerate repodata for %s using rpmrepo (in %s)' % (arch, dir))
135 os.system('%s rpmrepo %s -o %s' % ("" if quiet else "set -x;", dir, dir))
137 print('copy comps.xml')
138 comps = '%s.stat/repodata/comps.xml' % ftp_dir
139 os.system('%s cp -p %s %s/repodata' % ("" if quiet else "set -x;", comps, dir))