From 8867ef0cf96b5354f87da9e0ee0d7cfc30ad95d2 Mon Sep 17 00:00:00 2001 From: Niels Thykier Date: Thu, 1 Nov 2018 06:43:23 +0000 Subject: [PATCH] Let the BinaryPackageUniverse track essential packages Signed-off-by: Niels Thykier --- britney2/installability/builder.py | 3 +-- britney2/installability/tester.py | 9 +++------ britney2/installability/universe.py | 12 +++++++++++- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/britney2/installability/builder.py b/britney2/installability/builder.py index 2eab495..e094d4a 100644 --- a/britney2/installability/builder.py +++ b/britney2/installability/builder.py @@ -308,12 +308,11 @@ class InstallabilityTesterBuilder(object): relations, eqv_table = self._build_eqv_packages_table(package_table, reverse_package_table) - universe = BinaryPackageUniverse(relations) + universe = BinaryPackageUniverse(relations, intern_set(self._essentials)) solver = InstallabilityTester(universe, self._testing, self._broken, - self._essentials, eqv_table) return universe, solver diff --git a/britney2/installability/tester.py b/britney2/installability/tester.py index 055a403..3c2d29b 100644 --- a/britney2/installability/tester.py +++ b/britney2/installability/tester.py @@ -22,7 +22,7 @@ from britney2.utils import iter_except class InstallabilityTester(object): - def __init__(self, universe, testing, broken, essentials, eqv_table): + def __init__(self, universe, testing, broken, eqv_table): """Create a new installability tester universe is a BinaryPackageUniverse @@ -33,8 +33,6 @@ class InstallabilityTester(object): broken is a (mutable) set of package ids that are known to be uninstallable. - essentials is a set of packages with "Essential: yes". - Package id: (pkg_name, pkg_version, pkg_arch) - NB: arch:all packages are "re-mapped" to given architecture. (simplifies caches and dependency checking) @@ -43,7 +41,6 @@ class InstallabilityTester(object): self._universe = universe self._testing = testing self._broken = broken - self._essentials = essentials self._eqv_table = eqv_table self._stats = InstallabilityStats() logger_name = ".".join((self.__class__.__module__, self.__class__.__name__)) @@ -136,7 +133,7 @@ class InstallabilityTester(object): # Re-add broken packages as some of them may now be installable self._testing |= self._cache_broken self._cache_broken = set() - if pkg_id in self._essentials and pkg_id.architecture in self._cache_ess: + if pkg_id in self._universe.essential_packages and pkg_id.architecture in self._cache_ess: # Adds new essential => "pseudo-essential" set needs to be # recomputed del self._cache_ess[pkg_id.architecture] @@ -519,7 +516,7 @@ class InstallabilityTester(object): universe = self._universe stats = self._stats - ess_base = [x for x in self._essentials if x.architecture == arch and x in testing] + ess_base = [x for x in self._universe.essential_packages if x.architecture == arch and x in testing] start = set(ess_base) ess_never = set() ess_choices = set() diff --git a/britney2/installability/universe.py b/britney2/installability/universe.py index 12d304b..8f08b76 100644 --- a/britney2/installability/universe.py +++ b/britney2/installability/universe.py @@ -38,8 +38,9 @@ class BinaryPackageUniverse(object): in that suite?". """ - def __init__(self, relations): + def __init__(self, relations, essential_packages): self._relations = relations + self._essential_packages = essential_packages def dependencies_of(self, pkg_id): """Returns the set of dependencies of a given package @@ -109,6 +110,15 @@ class BinaryPackageUniverse(object): """ return self._relations[pkg_id] + @property + def essential_packages(self): + """A frozenset of all "Essential: yes" binaries in the universe + + :return A frozenset of BinaryPackageIds of all binaries that are + marked as essential. + """ + return self._essential_packages + def __contains__(self, pkg_id): return pkg_id in self._relations