From 82fa58df2066bfbd18f3de00ea5419960ae67d30 Mon Sep 17 00:00:00 2001 From: Niels Thykier Date: Thu, 3 Jan 2019 19:46:42 +0000 Subject: [PATCH] Extract a compute_item_name method Signed-off-by: Niels Thykier --- britney.py | 8 +++----- britney2/policies/policy.py | 8 +++----- britney2/utils.py | 6 ++++++ 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/britney.py b/britney.py index 380bedd..4edb57c 100755 --- a/britney.py +++ b/britney.py @@ -209,7 +209,7 @@ from britney2.utils import (log_and_format_old_libraries, get_dependency_solvers format_and_log_uninst, newly_uninst, write_excuses, write_heidi_delta, old_libraries, is_nuninst_asgood_generous, - clone_nuninst, + clone_nuninst, compute_item_name, invalidate_excuses, compile_nuninst, find_smooth_updateable_binaries, parse_provides, MigrationConstraintException, @@ -801,10 +801,8 @@ class Britney(object): sources_t = target_suite.sources sources_s = source_suite.sources for p in packages: - if p in sources_t and sources_t[p].version == sources_s[p].version: - excuse.add_dependency(DependencyType.DEPENDS, "%s/%s" % (p, arch), arch) - else: - excuse.add_dependency(DependencyType.DEPENDS, p, arch) + item_name = compute_item_name(sources_t, sources_s, p, arch) + excuse.add_dependency(DependencyType.DEPENDS, item_name, arch) else: for p in packages: excuse.add_break_dep(p, arch) diff --git a/britney2/policies/policy.py b/britney2/policies/policy.py index d732d53..2c08cae 100644 --- a/britney2/policies/policy.py +++ b/britney2/policies/policy.py @@ -13,7 +13,7 @@ from britney2 import SuiteClass from britney2.hints import Hint, split_into_one_hint_per_package from britney2.inputs.suiteloader import SuiteContentLoader from britney2.policies import PolicyVerdict -from britney2.utils import get_dependency_solvers +from britney2.utils import get_dependency_solvers, compute_item_name from britney2 import DependencyType @@ -821,10 +821,8 @@ class BuildDependsPolicy(BasePolicy): # for the solving packages, update the excuse to add the dependencies for p in packages: if arch not in self.options.break_arches: - if p in sources_t and sources_t[p].version == sources_s[p].version: - excuse.add_dependency(dep_type,"%s/%s" % (p, arch), arch) - else: - excuse.add_dependency(dep_type, p, arch) + item_name = compute_item_name(sources_t, sources_s, p, arch) + excuse.add_dependency(dep_type, item_name, arch) if arch in results: if results[arch] == BuildDepResult.FAILED: diff --git a/britney2/utils.py b/britney2/utils.py index e016f62..1a322bc 100644 --- a/britney2/utils.py +++ b/britney2/utils.py @@ -869,3 +869,9 @@ def parse_provides(provides_raw, pkg_id=None, logger=None): part = (provided, provided_version, sys.intern(op)) nprov.append(part) return nprov + + +def compute_item_name(sources_t, sources_s, source_name, parch): + if source_name in sources_t and sources_t[source_name].version == sources_s[source_name].version: + return "%s/%s" % (source_name, parch) + return source_name