2 # vi: encoding=utf-8 ts=8 sts=4 sw=4 et
6 sys.path.insert(0, os.environ['HOME']+'/pld-ftp-admin/modules')
7 from common import checkdir
8 from config import ftp_dir,all_ftp_archs
13 opts, args = getopt.getopt(sys.argv[1:], 'q',
16 "nopoldek", "noyum", "norpmrepo",
17 "poldek", "yum", "rpmrepo"
20 except getopt.GetoptError:
21 print >>sys.stderr, "ERR: not enough parameters given"
22 print >>sys.stderr, "gen-indexes.py [--quiet] [--[no]poldek] [--[no]yum] [--[no]rpmrepo] tree [tree2...]"
35 if o == "--norpmrepo":
45 if o == "-q" or o == "--quiet":
49 do_poldek = do_yum = do_rpmrepo = False
50 for v in a.split(','):
59 print "poldek: %s; yum: %s; rpmrepo: %s" % (do_poldek, do_yum, do_rpmrepo)
61 if not do_poldek and not do_yum and not do_rpmrepo:
62 print >>sys.stderr, "ERR: speciy at least one action"
70 ftpio.connect('gen-indexes')
75 if ftpio.lock(tree, True):
79 print >>sys.stderr, "ERR: %s tree already locked" % tree
84 home = os.environ['HOME']
90 poldek = '%s.stat/bin/poldek-new --cachedir=%s/tmp/poldek --conf %s.stat/etc/poldek.conf --mkidxz' % (ftp_dir, home, ftp_dir)
93 print '\n-------------------------- %s --------------------------' % tree
94 for arch in all_ftp_archs:
95 print '\ngenerate poldek index for %s' % arch
96 if config.poldek_indexes != "old":
97 os.system('%s -s %s%s/%s/RPMS/ --mkidxz --mkidx-type pndir' % (poldek, ftp_dir, tree, arch))
98 if arch != 'noarch' and config.separate_debuginfo:
99 os.system('%s -s %s%s/%s/debuginfo/ --mkidxz --mkidx-type pndir' % (poldek, ftp_dir, tree, arch))
100 if config.poldek_indexes != "new":
101 os.system('%s -s %s%s/%s/RPMS/ --mkidxz --mkidx-type pdir' % (poldek, ftp_dir, tree, arch))
102 if arch != 'noarch' and config.separate_debuginfo:
103 os.system('%s -s %s%s/%s/debuginfo/ --mkidxz --mkidx-type pdir' % (poldek, ftp_dir, tree, arch))
106 os.system('%s cd %s.stat/repodata && cvs %s up comps.xml' % ("" if quiet else "set -x;", ftp_dir, "" if quiet else "-Q"))
107 yum = '%s.stat/bin/createrepo -d -g %s.stat/repodata/comps.xml' % (ftp_dir, ftp_dir)
109 print '\n-------------------------- %s --------------------------' % tree
110 cachedir = '%s/tmp/createrepo/%s' % (home, tree)
111 for arch in all_ftp_archs:
112 print '\ngenerate repodata for %s using createrepo' % arch
113 # Creating indexes for yum and other supporting xml repodata.
114 os.system('%s %s --cache %s-%s %s%s/%s/RPMS' % ("" if quiet else "time", yum, cachedir, arch, ftp_dir, tree, arch))
115 if arch != 'noarch' and config.separate_debuginfo:
116 os.system('%s %s --cache %s-%s %s%s/%s/debuginfo' % ("" if quiet else "time", yum, cachedir, arch, ftp_dir, tree, arch))
119 os.system('%s cd %s.stat/repodata && cvs %s up comps.xml' % ("" if quiet else "set -x;", ftp_dir, "" if quiet else "-Q"))
121 print '\n-------------------------- %s --------------------------' % tree
122 for arch in all_ftp_archs:
123 dir = '%s/%s/%s/RPMS' % (ftp_dir, tree, arch)
125 print '\ngenerate repodata for %s using rpmrepo (in %s)' % (arch, dir)
126 os.system('%s rpmrepo %s -o %s' % ("" if quiet else "set -x;", dir, dir))
128 print 'copy comps.xml'
129 comps = '%s.stat/repodata/comps.xml' % ftp_dir
130 os.system('%s cp -p %s %s/repodata' % ("" if quiet else "set -x;", comps, dir))