summaryrefslogtreecommitdiff
path: root/check-code.liw.fi-versions
diff options
context:
space:
mode:
Diffstat (limited to 'check-code.liw.fi-versions')
-rwxr-xr-xcheck-code.liw.fi-versions70
1 files changed, 70 insertions, 0 deletions
diff --git a/check-code.liw.fi-versions b/check-code.liw.fi-versions
new file mode 100755
index 0000000..8394a2d
--- /dev/null
+++ b/check-code.liw.fi-versions
@@ -0,0 +1,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()