3 from __future__ import print_function
10 dirs = ['/home/services/ftp/pld/dists/3.0/PLD/x32/RPMS',
11 '/home/services/ftp/pld/dists/3.0/PLD/i686/RPMS',
12 '/home/services/ftp/pld/dists/3.0/PLD/x86_64/RPMS',
13 '/home/services/ftp/pld/dists/3.0/ready/x32/RPMS',
14 '/home/services/ftp/pld/dists/3.0/ready/i686/RPMS',
15 '/home/services/ftp/pld/dists/3.0/ready/x86_64/RPMS',
16 '/home/services/ftp/pld/dists/3.0/test/x32/RPMS',
17 '/home/services/ftp/pld/dists/3.0/test/i686/RPMS',
18 '/home/services/ftp/pld/dists/3.0/test/x86_64/RPMS']
20 #dirs = ['/home/services/ftp/pld/dists/3.0/test/x86_64/RPMS']
22 outname = "/home/pld/admins/th/www/name-srcname.txt"
24 re_rpm = re.compile(r'.*\.rpm$')
25 re_nvr = re.compile('^(.*)-([^-]*)-([^-]*)\.rpm$')
31 for file in os.listdir(dir):
32 if not re_rpm.match(file):
35 rpm_file = os.path.join(dir, file)
37 fdno = os.open(rpm_file, os.O_RDONLY)
39 hdr = ts.hdrFromFdno(fdno)
40 except Exception as e:
41 print("hdrFromFdno: %s: %s" % (rpm_file, e))
46 name = hdr[rpm.RPMTAG_NAME]
47 sourcerpm = hdr[rpm.RPMTAG_SOURCERPM]
48 m = re_nvr.match(sourcerpm)
50 print("%s: doesn't match src.rpm file name" % (sourcerpm))
55 f = open(outname + ".tmp", "w")
56 for (pkg, spkg) in iter(pkgs.items()):
57 f.write("%s:%s\n" % (pkg, spkg))
59 os.chmod(outname + ".tmp", 0o644)
60 os.rename(outname + ".tmp", outname)