1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
#!/usr/bin/python
#
# All is OK if:
#
# - every package is in each architecture
# - every package is in each codename
# - if the version in unstable is x.y-z, then the version in codename foo
# is x.y-z.foo
import sys
def read_package_data(f):
data = []
for line in f:
pkg, version, s = line.split()
codename, main, arch = s.split('|')
if arch.endswith(':'):
arch = arch[:-1]
data.append((pkg, codename, arch, version))
return data
def packages(data):
return set(p for p, c, a, v in data)
def check_package(data, package):
# Is the package in every architecture?
all_arches = set(a for p, c, a, v in data)
arches_with_p = set(a for p, c, a, v in data if p == package)
missing_from_arches = all_arches.difference(arches_with_p)
for arch in missing_from_arches:
print 'ERROR: package %s not in arch %s' % (package, arch)
# Is the package in every codename?
all_codenames = set(c for p, c, a, v in data)
codenames_with_p = set(c for p, c, a, v in data if p == package)
missing_from_codenames = all_codenames.difference(codenames_with_p)
for codename in missing_from_codenames:
print 'ERROR: package %s not in codename %s' % (package, codename)
# Does the package have the same version (modulo ".$codename" suffix)
# in every codename?
unstable_versions = set(
v for p, c, a, v in data if p == package and c == 'unstable')
if len(unstable_versions) == 0:
print 'ERROR: package %s not in unstable' % package
elif len(unstable_versions) > 1:
print 'ERROR: package %s has more than one version in unstable' % \
package
else:
uv = unstable_versions.pop()
for p, c, a, v in data:
if p == package and c != 'unstable':
expected = '%s.%s' % (uv, c)
if v != expected:
print 'ERROR: package %s has version %s, expected %s' % \
(package, v, expected)
def main():
data = read_package_data(sys.stdin)
for p in sorted(list(packages(data))):
check_package(data, p)
main()
|