From 61d3068de67933ccb02be3f9ba968f277cf706cf Mon Sep 17 00:00:00 2001 From: Niels Thykier Date: Tue, 25 Dec 2018 18:53:58 +0000 Subject: [PATCH] Move suite name auto-correction to MigrationItemFactory Signed-off-by: Niels Thykier --- britney.py | 23 +++-------------------- britney2/migrationitem.py | 17 +++++++++++++++++ 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/britney.py b/britney.py index 20b1c50..e0f9cc7 100755 --- a/britney.py +++ b/britney.py @@ -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: diff --git a/britney2/migrationitem.py b/britney2/migrationitem.py index b07896e..2a5b225 100644 --- a/britney2/migrationitem.py +++ b/britney2/migrationitem.py @@ -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)