+def check_override_compliance(package, priority, suite, cnf, session):
+ print "Checking compliance with related overrides..."
+
+ depends = set()
+ rdepends = set()
+ components = get_component_names(session)
+ arches = set([x.arch_string for x in get_suite_architectures(suite)])
+ arches -= set(["source", "all"])
+ for arch in arches:
+ for component in components:
+ Packages = utils.get_packages_from_ftp(cnf['Dir::Root'], suite, component, arch)
+ while Packages.Step():
+ package_name = Packages.Section.Find("Package")
+ dep_list = Packages.Section.Find("Depends")
+ if dep_list:
+ if package_name == package:
+ for d in apt_pkg.ParseDepends(dep_list):
+ for i in d:
+ depends.add(i[0])
+ else:
+ for d in apt_pkg.ParseDepends(dep_list):
+ for i in d:
+ if i[0] == package:
+ rdepends.add(package_name)
+
+ query = """SELECT o.package, p.level, p.priority
+ FROM override o
+ JOIN suite s ON s.id = o.suite
+ JOIN priority p ON p.id = o.priority
+ WHERE s.suite_name = '%s'
+ AND o.package in ('%s')""" \
+ % (suite, "', '".join(depends.union(rdepends)))
+ packages = session.execute(query)
+
+ excuses = []
+ for p in packages:
+ if p[0] == package or not p[1]:
+ continue
+ if p[0] in depends:
+ if priority.level < p[1]:
+ excuses.append("%s would have priority %s, its dependency %s has priority %s" \
+ % (package, priority.priority, p[0], p[2]))
+ if p[0] in rdepends:
+ if priority.level > p[1]:
+ excuses.append("%s would have priority %s, its reverse dependency %s has priority %s" \
+ % (package, priority.priority, p[0], p[2]))
+
+ if excuses:
+ for ex in excuses:
+ print ex
+ else:
+ print "Proposed override change complies with Debian Policy"