4 This script tries to set ordering in which packages ought to be sent to builders.
5 Input: file with names of packages (without the .spec suffix). One package name per line.
6 Output: sorted packages on stdout.
8 If the script goes in a infinite loop, that means there is a cycle or other bug.
15 BR_PATTERN = re.compile('BuildRequires:\s+(.*?)(\s|$)')
16 PACKAGE_PATTERN_WITH_N = re.compile('%package\s+-n\s+(.*)')
17 PACKAGE_PATTERN = re.compile('%package\s+(.*)')
19 DIR = os.getenv("HOME") + '/rpm/packages'
28 global PACKAGES, SPECS, BUILD_REQUIRES, VISITED
31 with open(os.path.join(DIR, name, name + '.spec'), 'r') as f:
33 br = BR_PATTERN.match(line)
37 if line.startswith('%package'):
38 pn = PACKAGE_PATTERN_WITH_N.match(line)
41 PACKAGES[package] = name
43 pn = PACKAGE_PATTERN.match(line)
47 package = name + '-' + ext
48 PACKAGES[package] = name
49 BUILD_REQUIRES[name] = res[:]
58 global PACKAGES, SPECS, BUILD_REQUIRES, VISITED
62 for br in BUILD_REQUIRES[spec]:
63 name = PACKAGES.get(br, '')
70 if __name__ == "__main__":
72 print("Usage: %s filename" % sys.argv[0])
74 with open(sys.argv[1], 'r') as f: