Move suite name auto-correction to MigrationItemFactory

Signed-off-by: Niels Thykier <niels@thykier.net>
ubuntu/rebased
Niels Thykier 6 years ago
parent eec7b9b7ef
commit 61d3068de6
No known key found for this signature in database
GPG Key ID: A65B78DBE67C7AAC

@ -1994,27 +1994,10 @@ class Britney(object):
continue
suite = pkg.suite
in_primary = pkg.package in suite.sources
rightversion = in_primary and apt_pkg.version_compare(suite.sources[pkg.package].version, pkg.version) == 0
if suite.suite_class.is_primary_source and not rightversion:
for s in suites.additional_source_suites:
if pkg.package in s.sources and apt_pkg.version_compare(suite.sources[pkg.package].version,
pkg.version) == 0:
suite = s
pkg.suite = s
pkgvers[idx] = pkg
break
if suite.suite_class.is_additional_source:
if pkg.package not in suite.sources:
continue
if apt_pkg.version_compare(suite.sources[pkg.package].version, pkg.version) != 0:
issues.append("Version mismatch, %s %s != %s" % (pkg.package, pkg.version,
suite.sources[pkg.package].version))
# does the package exist in the primary source suite?
elif not in_primary:
if pkg.package not in suite.sources:
issues.append("Source %s has no version in %s" % (pkg.package, suite.name))
elif not rightversion:
elif apt_pkg.version_compare(suite.sources[pkg.package].version, pkg.version) != 0:
issues.append("Version mismatch, %s %s != %s" % (pkg.package, pkg.version,
suite.sources[pkg.package].version))
if issues:

@ -12,6 +12,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
import apt_pkg
import logging
from britney2 import SuiteClass
@ -138,6 +139,17 @@ class MigrationItemFactory(object):
suite=self._suites.target_suite
)
@staticmethod
def _is_right_version(suite, package_name, expected_version):
if package_name not in suite.sources:
return False
actual_version = suite.sources[package_name].version
if apt_pkg.version_compare(actual_version, expected_version) != 0:
return False
return True
def parse_item(self, item_text, versioned=True, auto_correct=True):
"""
@ -194,6 +206,11 @@ class MigrationItemFactory(object):
else:
suite = suites.by_name_or_alias[suite_name]
assert suite.suite_class != SuiteClass.TARGET_SUITE
if version is not None and auto_correct and not self._is_right_version(suite, package_name, version):
for s in suites.source_suites:
if self._is_right_version(s, package_name, version):
suite = s
break
uvname = self._canonicalise_uvname(item_text, package_name, architecture, suite, is_removal)

Loading…
Cancel
Save