]> git.pld-linux.org Git - packages/rpm-build-tools.git/blame - sort-pkgs
- script that might be useful when sending big sets of packages to builders (for...
[packages/rpm-build-tools.git] / sort-pkgs
CommitLineData
1859b517
WF
1#!/usr/bin/python
2
3"""
4This script tries to set ordering in which packages ought to be sent to builders.
5Input: file with names of packages (without the .spec suffix). One package name per line.
6Output: sorted packages on stdout.
7
8If the script goes in a infinite loop, that means there is a cycle or other bug.
9"""
10
11import os
12import re
13import sys
14
15PATTERN = re.compile('BuildRequires:\t(.*)-devel')
16DIR = '/home/users/builder/rpm/packages'
17
18packages = {}
19packages_res = {}
20
21def build_requires(name):
22 res = []
23 with open(os.path.join(DIR, name, name + '.spec'), 'r') as f:
24 for line in f:
25 br = PATTERN.match(line)
26 if br:
27 p = br.group(1)
28 if p in packages:
29 res.append(p)
30 return res
31
32def print_packages(p):
33 if packages_res[p] == 1:
34 return
35 for pp in packages[p]:
36 print_packages(pp)
37 packages_res[p] = 1
38 print p#, packages[p]
39
40if __name__ == "__main__":
41 if len(sys.argv) < 2:
42 print "Usage: %s filename" % sys.argv[0]
43 sys.exit(1)
44 with open(sys.argv[1], 'r') as f:
45 for line in f:
46 p = line.rstrip()
47 packages[p] = []
48 packages_res[p] = 0
49 for p in packages.keys():
50 res = build_requires(p)
51 if res:
52 packages[p] = res[:]
53
54# for p in packages.keys():
55# print p, packages[p]
56
57 for p in packages.keys():
58 print_packages(p)
This page took 0.031984 seconds and 4 git commands to generate.