]> git.pld-linux.org Git - projects/pld-ftp-admin.git/blame - wwwbin/dump-packagenames.py
th-i486->th-x32 (baggins)
[projects/pld-ftp-admin.git] / wwwbin / dump-packagenames.py
CommitLineData
ed1ec331
ER
1#!/usr/bin/python
2
3import os
4import re
5
6import rpm
7
b27647ca 8dirs = ['/home/services/ftp/pld/dists/3.0/PLD/x32/RPMS',
ed1ec331
ER
9 '/home/services/ftp/pld/dists/3.0/PLD/i686/RPMS',
10 '/home/services/ftp/pld/dists/3.0/PLD/x86_64/RPMS',
b27647ca 11 '/home/services/ftp/pld/dists/3.0/ready/x32/RPMS',
ed1ec331
ER
12 '/home/services/ftp/pld/dists/3.0/ready/i686/RPMS',
13 '/home/services/ftp/pld/dists/3.0/ready/x86_64/RPMS',
b27647ca 14 '/home/services/ftp/pld/dists/3.0/test/x32/RPMS',
ed1ec331
ER
15 '/home/services/ftp/pld/dists/3.0/test/i686/RPMS',
16 '/home/services/ftp/pld/dists/3.0/test/x86_64/RPMS']
17
18#dirs = ['/home/services/ftp/pld/dists/3.0/test/x86_64/RPMS']
19
20outname = "/home/pld/admins/th/www/name-srcname.txt"
21
22re_rpm = re.compile(r'.*\.rpm$')
23re_nvr = re.compile('^(.*)-([^-]*)-([^-]*)\.rpm$')
24
25ts = rpm.ts()
26ts.setVSFlags(-1)
27pkgs = {}
28for dir in dirs:
29 for file in os.listdir(dir):
30 if not re_rpm.match(file):
31 continue
32
33 rpm_file = os.path.join(dir, file)
34
35 fdno = os.open(rpm_file, os.O_RDONLY)
36 try:
37 hdr = ts.hdrFromFdno(fdno)
38 except Exception, e:
39 print "hdrFromFdno: %s: %s" % (rpm_file, e)
40 os.close(fdno)
41 continue
42 os.close(fdno)
43
44 name = hdr[rpm.RPMTAG_NAME]
45 sourcerpm = hdr[rpm.RPMTAG_SOURCERPM]
46 m = re_nvr.match(sourcerpm)
47 if not m:
48 print "%s: doesn't match src.rpm file name" % (sourcerpm)
49 continue
50 srcname = m.group(1)
51 pkgs[name] = srcname
52
53f = open(outname + ".tmp", "w")
54for (pkg, spkg) in pkgs.iteritems():
55 f.write("%s:%s\n" % (pkg, spkg))
56f.close()
57os.chmod(outname + ".tmp", 0644)
58os.rename(outname + ".tmp", outname)
59
This page took 0.405526 seconds and 4 git commands to generate.