-
- ################################################################################
- def get_anyversion(self, sv_list, suite):
- """
- @type sv_list: list
- @param sv_list: list of (suite, version) tuples to check
-
- @type suite: string
- @param suite: suite name
-
- Description: TODO
- """
- Cnf = Config()
- anyversion = None
- anysuite = [suite] + [ vc.reference.suite_name for vc in get_version_checks(suite, "Enhances") ]
- for (s, v) in sv_list:
- if s in [ x.lower() for x in anysuite ]:
- if not anyversion or apt_pkg.version_compare(anyversion, v) <= 0:
- anyversion = v
-
- return anyversion
-
- ################################################################################
-
- def cross_suite_version_check(self, sv_list, filename, new_version, sourceful=False):
- """
- @type sv_list: list
- @param sv_list: list of (suite, version) tuples to check
-
- @type filename: string
- @param filename: XXX
-
- @type new_version: string
- @param new_version: XXX
-
- Ensure versions are newer than existing packages in target
- suites and that cross-suite version checking rules as
- set out in the conf file are satisfied.
- """
-
- cnf = Config()
-
- # Check versions for each target suite
- for target_suite in self.pkg.changes["distribution"].keys():
- # Check we can find the target suite
- ts = get_suite(target_suite)
- if ts is None:
- self.rejects.append("Cannot find target suite %s to perform version checks" % target_suite)
- continue
-
- must_be_newer_than = [ vc.reference.suite_name for vc in get_version_checks(target_suite, "MustBeNewerThan") ]
- must_be_older_than = [ vc.reference.suite_name for vc in get_version_checks(target_suite, "MustBeOlderThan") ]
-
- # Enforce "must be newer than target suite" even if conffile omits it
- if target_suite not in must_be_newer_than:
- must_be_newer_than.append(target_suite)
-
- for (suite, existent_version) in sv_list:
- vercmp = apt_pkg.version_compare(new_version, existent_version)
-
- if suite in must_be_newer_than and sourceful and vercmp < 1:
- self.rejects.append("%s: old version (%s) in %s >= new version (%s) targeted at %s." % (filename, existent_version, suite, new_version, target_suite))
-
- if suite in must_be_older_than and vercmp > -1:
- cansave = 0
-
- if self.pkg.changes.get('distribution-version', {}).has_key(suite):
- # we really use the other suite, ignoring the conflicting one ...
- addsuite = self.pkg.changes["distribution-version"][suite]
-
- add_version = self.get_anyversion(sv_list, addsuite)
- target_version = self.get_anyversion(sv_list, target_suite)
-
- if not add_version:
- # not add_version can only happen if we map to a suite
- # that doesn't enhance the suite we're propup'ing from.
- # so "propup-ver x a b c; map a d" is a problem only if
- # d doesn't enhance a.
- #
- # i think we could always propagate in this case, rather
- # than complaining. either way, this isn't a REJECT issue
- #
- # And - we really should complain to the dorks who configured dak
- self.warnings.append("%s is mapped to, but not enhanced by %s - adding anyways" % (suite, addsuite))
- self.pkg.changes.setdefault("propdistribution", {})
- self.pkg.changes["propdistribution"][addsuite] = 1
- cansave = 1
- elif not target_version:
- # not targets_version is true when the package is NEW
- # we could just stick with the "...old version..." REJECT
- # for this, I think.
- self.rejects.append("Won't propogate NEW packages.")
- elif apt_pkg.version_compare(new_version, add_version) < 0:
- # propogation would be redundant. no need to reject though.
- self.warnings.append("ignoring versionconflict: %s: old version (%s) in %s <= new version (%s) targeted at %s." % (filename, existent_version, suite, new_version, target_suite))
- cansave = 1
- elif apt_pkg.version_compare(new_version, add_version) > 0 and \
- apt_pkg.version_compare(add_version, target_version) >= 0:
- # propogate!!
- self.warnings.append("Propogating upload to %s" % (addsuite))
- self.pkg.changes.setdefault("propdistribution", {})
- self.pkg.changes["propdistribution"][addsuite] = 1
- cansave = 1
-
- if not cansave:
- self.rejects.append("%s: old version (%s) in %s <= new version (%s) targeted at %s." % (filename, existent_version, suite, new_version, target_suite))
-
- ################################################################################
-
- def accepted_checks(self, overwrite_checks, session):
- # Recheck anything that relies on the database; since that's not
- # frozen between accept and our run time when called from p-a.
-
- # overwrite_checks is set to False when installing to stable/oldstable
-
- propogate={}
- nopropogate={}
-
- for checkfile in self.pkg.files.keys():
- # The .orig.tar.gz can disappear out from under us is it's a
- # duplicate of one in the archive.
- if not self.pkg.files.has_key(checkfile):
- continue
-
- entry = self.pkg.files[checkfile]
-
- # propogate in the case it is in the override tables:
- for suite in self.pkg.changes.get("propdistribution", {}).keys():
- if self.in_override_p(entry["package"], entry["component"], suite, entry.get("dbtype",""), checkfile, session):
- propogate[suite] = 1
- else:
- nopropogate[suite] = 1
-
- for suite in propogate.keys():
- if suite in nopropogate:
- continue
- self.pkg.changes["distribution"][suite] = 1
-
- for checkfile in self.pkg.files.keys():
- # Check the package is still in the override tables
- for suite in self.pkg.changes["distribution"].keys():
- if not self.in_override_p(entry["package"], entry["component"], suite, entry.get("dbtype",""), checkfile, session):
- self.rejects.append("%s is NEW for %s." % (checkfile, suite))