]>
Commit | Line | Data |
---|---|---|
1859b517 WF |
1 | #!/usr/bin/python |
2 | ||
3 | """ | |
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. | |
7 | ||
8 | If the script goes in a infinite loop, that means there is a cycle or other bug. | |
9 | """ | |
10 | ||
11 | import os | |
12 | import re | |
13 | import sys | |
14 | ||
fdc41000 | 15 | PATTERN = re.compile('BuildRequires:\s+(.*?)(\s|$|-devel)') |
1859b517 WF |
16 | DIR = '/home/users/builder/rpm/packages' |
17 | ||
18 | packages = {} | |
19 | packages_res = {} | |
20 | ||
21 | def build_requires(name): | |
fdc41000 | 22 | global packages |
1859b517 WF |
23 | res = [] |
24 | with open(os.path.join(DIR, name, name + '.spec'), 'r') as f: | |
25 | for line in f: | |
26 | br = PATTERN.match(line) | |
27 | if br: | |
28 | p = br.group(1) | |
29 | if p in packages: | |
30 | res.append(p) | |
31 | return res | |
32 | ||
33 | def print_packages(p): | |
fdc41000 | 34 | global packages, packages_res |
86ee5491 | 35 | |
1920deb7 WF |
36 | if not packages_res[p]: |
37 | packages_res[p] = 1 | |
38 | for pp in packages[p]: | |
39 | if not packages_res[pp]: | |
40 | print_packages(pp) | |
41 | print p | |
1859b517 WF |
42 | |
43 | if __name__ == "__main__": | |
44 | if len(sys.argv) < 2: | |
45 | print "Usage: %s filename" % sys.argv[0] | |
46 | sys.exit(1) | |
47 | with open(sys.argv[1], 'r') as f: | |
48 | for line in f: | |
49 | p = line.rstrip() | |
50 | packages[p] = [] | |
51 | packages_res[p] = 0 | |
52 | for p in packages.keys(): | |
53 | res = build_requires(p) | |
54 | if res: | |
55 | packages[p] = res[:] | |
56 | ||
57 | # for p in packages.keys(): | |
58 | # print p, packages[p] | |
59 | ||
60 | for p in packages.keys(): | |
61 | print_packages(p) |