From 920d82445d750f60c5156ecf8473a76877b55872 Mon Sep 17 00:00:00 2001 From: Ivo De Decker Date: Wed, 1 Apr 2020 16:27:03 +0000 Subject: [PATCH] Add allow-smooth-update hint Hint to allow smooth update, even if the section isn't allowed in the configuration. Note that this takes the source name and the source version IN TESTING of the binaries that must be allowed to stay around to allow a smooth update. --- britney.py | 3 ++- britney2/excusefinder.py | 3 ++- britney2/hints.py | 1 + britney2/migration.py | 7 +++++-- britney2/policies/policy.py | 2 +- britney2/utils.py | 10 +++++++--- 6 files changed, 18 insertions(+), 8 deletions(-) diff --git a/britney.py b/britney.py index 60055d2..46df2fd 100755 --- a/britney.py +++ b/britney.py @@ -339,7 +339,8 @@ class Britney(object): self._migration_item_factory = MigrationItemFactory(self.suite_info) self._hint_parser = HintParser(self._migration_item_factory) self._migration_manager = MigrationManager(self.options, self.suite_info, self.all_binaries, self.pkg_universe, - self.constraints, self.allow_uninst, self._migration_item_factory) + self.constraints, self.allow_uninst, self._migration_item_factory, + self.hints) if not self.options.nuninst_cache: self.logger.info("Building the list of non-installable packages for the full archive") diff --git a/britney2/excusefinder.py b/britney2/excusefinder.py index fad8e72..26ceadf 100644 --- a/britney2/excusefinder.py +++ b/britney2/excusefinder.py @@ -215,7 +215,8 @@ class ExcuseFinder(object): binaries_t, source_suite.binaries, frozenset(), - self.options.smooth_updates) + self.options.smooth_updates, + self.hints) # for every binary package produced by this source in testing for this architecture for pkg_id in sorted(x for x in source_t.binaries if x.architecture == arch): diff --git a/britney2/hints.py b/britney2/hints.py index 8e6a10a..e17e625 100644 --- a/britney2/hints.py +++ b/britney2/hints.py @@ -169,6 +169,7 @@ class HintParser(object): 'remove': (1, split_into_one_hint_per_package), 'force': (1, split_into_one_hint_per_package), 'allow-uninst': (1, split_into_one_hint_per_package), + 'allow-smooth-update': (1, split_into_one_hint_per_package), } self._aliases = { 'approve': 'unblock', diff --git a/britney2/migration.py b/britney2/migration.py index dac189e..6b52cff 100644 --- a/britney2/migration.py +++ b/britney2/migration.py @@ -38,13 +38,15 @@ def is_nuninst_worse(must_be_installable, nuninst_now_arch, nuninst_after_arch, class MigrationManager(object): - def __init__(self, options, suite_info, all_binaries, pkg_universe, constraints, allow_uninst, migration_item_factory): + def __init__(self, options, suite_info, all_binaries, pkg_universe, + constraints, allow_uninst, migration_item_factory, hints): self.options = options self.suite_info = suite_info self.all_binaries = all_binaries self.pkg_universe = pkg_universe self.constraints = constraints self.allow_uninst = allow_uninst + self.hints = hints self._transactions = [] self._all_architectures = frozenset(self.options.architectures) self._migration_item_factory = migration_item_factory @@ -206,7 +208,8 @@ class MigrationManager(object): binaries_t, binaries_s, removals, - self.options.smooth_updates) + self.options.smooth_updates, + self.hints) else: smoothbins = set() diff --git a/britney2/policies/policy.py b/britney2/policies/policy.py index 5c1b3cd..d69dedf 100644 --- a/britney2/policies/policy.py +++ b/britney2/policies/policy.py @@ -1692,7 +1692,7 @@ class ImplicitDependencyPolicy(BasePolicy): pkg_id_s = None if not pkg_id_s and \ - is_smooth_update_allowed(binaries_t_a[mypkg], self._smooth_updates): + is_smooth_update_allowed(binaries_t_a[mypkg], self._smooth_updates, self.hints): # the binary isn't in the new version (or is cruft there), and # smooth updates are allowed: the binary can stay around if # that is necessary to satisfy dependencies, so we don't need diff --git a/britney2/utils.py b/britney2/utils.py index fbae559..bd640d2 100644 --- a/britney2/utils.py +++ b/britney2/utils.py @@ -761,12 +761,15 @@ def compile_nuninst(target_suite, architectures, nobreakall_arches): return nuninst -def is_smooth_update_allowed(binary, smooth_updates): +def is_smooth_update_allowed(binary, smooth_updates, hints): if 'ALL' in smooth_updates: return True section = binary.section.split('/')[-1] if section in smooth_updates: return True + if hints.search('allow-smooth-update', package=binary.source, version=binary.source_version): + # note that this needs to match the source version *IN TESTING* + return True return False @@ -777,7 +780,8 @@ def find_smooth_updateable_binaries(binaries_to_check, binaries_t, binaries_s, removals, - smooth_updates): + smooth_updates, + hints): check = set() smoothbins = set() @@ -793,7 +797,7 @@ def find_smooth_updateable_binaries(binaries_to_check, cruftbins.add(binaries_s[parch][binary].pkg_id) # Maybe a candidate (cruft or removed binary): check if config allows us to smooth update it. - if is_smooth_update_allowed(binaries_t[parch][binary], smooth_updates): + if is_smooth_update_allowed(binaries_t[parch][binary], smooth_updates, hints): # if the package has reverse-dependencies which are # built from other sources, it's a valid candidate for # a smooth update. if not, it may still be a valid