mirror of
https://git.launchpad.net/~ubuntu-release/britney/+git/britney2-ubuntu
synced 2025-03-13 04:11:07 +00:00
Always use pkg ids in the InstallabilityTester API
Signed-off-by: Niels Thykier <niels@thykier.net>
This commit is contained in:
parent
2914a8a51b
commit
a9ee64470e
23
britney.py
23
britney.py
@ -1785,7 +1785,8 @@ class Britney(object):
|
||||
nuninst[arch] = set()
|
||||
for pkg_name in binaries[arch][0]:
|
||||
pkgdata = binaries[arch][0][pkg_name]
|
||||
r = inst_tester.is_installable(pkg_name, pkgdata[VERSION], arch)
|
||||
pkg_id = (pkg_name, pkgdata[VERSION], arch)
|
||||
r = inst_tester.is_installable(pkg_id)
|
||||
if not r:
|
||||
nuninst[arch].add(pkg_name)
|
||||
|
||||
@ -2091,7 +2092,7 @@ class Britney(object):
|
||||
del provides_t_a[j]
|
||||
# finally, remove the binary package
|
||||
del binaries_t_a[binary]
|
||||
inst_tester.remove_testing_binary(binary, version, parch)
|
||||
inst_tester.remove_testing_binary(rm_pkg_id)
|
||||
# remove the source package
|
||||
if item.architecture == 'source':
|
||||
undo['sources'][item.package] = source
|
||||
@ -2110,7 +2111,7 @@ class Britney(object):
|
||||
affected.add(pkg_id)
|
||||
affected.update(inst_tester.reverse_dependencies_of(pkg_id))
|
||||
del binaries_t_a[item.package]
|
||||
inst_tester.remove_testing_binary(item.package, version, item.architecture)
|
||||
inst_tester.remove_testing_binary(pkg_id)
|
||||
|
||||
|
||||
# add the new binary packages (if we are not removing)
|
||||
@ -2137,14 +2138,14 @@ class Britney(object):
|
||||
# save the old binary package
|
||||
undo['binaries'][p] = old_pkg_data
|
||||
old_version = old_pkg_data[VERSION]
|
||||
old_pkg_id = (binary, old_version, parch)
|
||||
if not equivalent_replacement:
|
||||
old_pkg_id = (binary, old_version, parch)
|
||||
# all the reverse dependencies are affected by
|
||||
# the change
|
||||
affected.update(inst_tester.reverse_dependencies_of(old_pkg_id))
|
||||
# all the reverse conflicts
|
||||
affected.update(inst_tester.negative_dependencies_of(old_pkg_id))
|
||||
inst_tester.remove_testing_binary(binary, old_version, parch)
|
||||
inst_tester.remove_testing_binary(old_pkg_id)
|
||||
elif hint_undo:
|
||||
# the binary isn't in testing, but it may have been at
|
||||
# the start of the current hint and have been removed
|
||||
@ -2165,7 +2166,7 @@ class Britney(object):
|
||||
# add/update the binary package from the source suite
|
||||
new_pkg_data = packages_s[parch][0][binary]
|
||||
binaries_t_a[binary] = new_pkg_data
|
||||
inst_tester.add_testing_binary(binary, new_version, parch)
|
||||
inst_tester.add_testing_binary(updated_pkg_id)
|
||||
# register new provided packages
|
||||
for j in new_pkg_data[PROVIDES]:
|
||||
key = j + "/" + parch
|
||||
@ -2211,7 +2212,7 @@ class Britney(object):
|
||||
nuninst_arch = nuninst[parch]
|
||||
elif actual_arch == 'all':
|
||||
nuninst[parch].discard(name)
|
||||
self._installability_test(name, version, parch, broken, to_check, nuninst_arch)
|
||||
self._installability_test(name, pkg_id, broken, to_check, nuninst_arch)
|
||||
|
||||
# We have always overshot the affected set, so to_check does not
|
||||
# contain anything new.
|
||||
@ -2968,7 +2969,7 @@ class Britney(object):
|
||||
for stat in self._inst_tester.stats.stats():
|
||||
self.__log('> %s' % stat, type="I")
|
||||
|
||||
def _installability_test(self, pkg_name, pkg_version, pkg_arch, broken, to_check, nuninst_arch):
|
||||
def _installability_test(self, pkg_name, pkg_id, broken, to_check, nuninst_arch):
|
||||
"""Test for installability of a package on an architecture
|
||||
|
||||
(pkg_name, pkg_version, pkg_arch) is the package to check.
|
||||
@ -2981,17 +2982,17 @@ class Britney(object):
|
||||
If nuninst_arch is not None then it also updated in the same
|
||||
way as broken is.
|
||||
"""
|
||||
r = self._inst_tester.is_installable(pkg_name, pkg_version, pkg_arch)
|
||||
r = self._inst_tester.is_installable(pkg_id)
|
||||
if not r:
|
||||
# not installable
|
||||
if pkg_name not in broken:
|
||||
broken.add(pkg_name)
|
||||
to_check.append((pkg_name, pkg_version, pkg_arch))
|
||||
to_check.append(pkg_id)
|
||||
if nuninst_arch is not None and pkg_name not in nuninst_arch:
|
||||
nuninst_arch.add(pkg_name)
|
||||
else:
|
||||
if pkg_name in broken:
|
||||
to_check.append((pkg_name, pkg_version, pkg_arch))
|
||||
to_check.append(pkg_id)
|
||||
broken.remove(pkg_name)
|
||||
if nuninst_arch is not None and pkg_name in nuninst_arch:
|
||||
nuninst_arch.remove(pkg_name)
|
||||
|
@ -154,7 +154,7 @@ def undo_changes(lundo, inst_tester, sources, binaries,
|
||||
if item.architecture in ['source', arch]:
|
||||
version = binaries["testing"][arch][0][binary][VERSION]
|
||||
del binaries["testing"][arch][0][binary]
|
||||
inst_tester.remove_testing_binary(binary, version, arch)
|
||||
inst_tester.remove_testing_binary((binary, version, arch))
|
||||
|
||||
|
||||
# STEP 3
|
||||
@ -170,10 +170,10 @@ def undo_changes(lundo, inst_tester, sources, binaries,
|
||||
binaries_t_a = binaries['testing'][arch][0]
|
||||
if p in binaries_t_a:
|
||||
rmpkgdata = binaries_t_a[p]
|
||||
inst_tester.remove_testing_binary(binary, rmpkgdata[VERSION], arch)
|
||||
inst_tester.remove_testing_binary((binary, rmpkgdata[VERSION], arch))
|
||||
pkgdata = undo['binaries'][p]
|
||||
binaries_t_a[binary] = pkgdata
|
||||
inst_tester.add_testing_binary(binary, pkgdata[VERSION], arch)
|
||||
inst_tester.add_testing_binary((binary, pkgdata[VERSION], arch))
|
||||
|
||||
# STEP 4
|
||||
# undo all changes to virtual packages
|
||||
|
@ -157,22 +157,20 @@ class InstallabilityTester(object):
|
||||
"""
|
||||
return not self._testing.isdisjoint(pkgs)
|
||||
|
||||
def add_testing_binary(self, pkg_name, pkg_version, pkg_arch):
|
||||
def add_testing_binary(self, pkg_id):
|
||||
"""Add a binary package to "testing"
|
||||
|
||||
If the package is not known, this method will throw an
|
||||
KeyError.
|
||||
"""
|
||||
|
||||
t = (pkg_name, pkg_version, pkg_arch)
|
||||
if pkg_id not in self._universe:
|
||||
raise KeyError(str(pkg_id))
|
||||
|
||||
if t not in self._universe:
|
||||
raise KeyError(str(t))
|
||||
|
||||
if t in self._broken:
|
||||
self._testing.add(t)
|
||||
elif t not in self._testing:
|
||||
self._testing.add(t)
|
||||
if pkg_id in self._broken:
|
||||
self._testing.add(pkg_id)
|
||||
elif pkg_id not in self._testing:
|
||||
self._testing.add(pkg_id)
|
||||
if self._cache_inst:
|
||||
self._stats.cache_drops += 1
|
||||
self._cache_inst = set()
|
||||
@ -180,44 +178,42 @@ 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 t in self._essentials and t[2] in self._cache_ess:
|
||||
if pkg_id in self._essentials and pkg_id[2] in self._cache_ess:
|
||||
# Adds new essential => "pseudo-essential" set needs to be
|
||||
# recomputed
|
||||
del self._cache_ess[t[2]]
|
||||
del self._cache_ess[pkg_id[2]]
|
||||
|
||||
return True
|
||||
|
||||
def remove_testing_binary(self, pkg_name, pkg_version, pkg_arch):
|
||||
def remove_testing_binary(self, pkg_id):
|
||||
"""Remove a binary from "testing"
|
||||
|
||||
If the package is not known, this method will throw an
|
||||
Keyrror.
|
||||
"""
|
||||
|
||||
t = (pkg_name, pkg_version, pkg_arch)
|
||||
if pkg_id not in self._universe:
|
||||
raise KeyError(str(pkg_id))
|
||||
|
||||
if t not in self._universe:
|
||||
raise KeyError(str(t))
|
||||
self._cache_broken.discard(pkg_id)
|
||||
|
||||
self._cache_broken.discard(t)
|
||||
|
||||
if t in self._testing:
|
||||
self._testing.remove(t)
|
||||
if t[2] in self._cache_ess and t in self._cache_ess[t[2]][0]:
|
||||
if pkg_id in self._testing:
|
||||
self._testing.remove(pkg_id)
|
||||
if pkg_id[2] in self._cache_ess and pkg_id in self._cache_ess[pkg_id[2]][0]:
|
||||
# Removes a package from the "pseudo-essential set"
|
||||
del self._cache_ess[t[2]]
|
||||
del self._cache_ess[pkg_id[2]]
|
||||
|
||||
if t not in self._revuniverse:
|
||||
if pkg_id not in self._revuniverse:
|
||||
# no reverse relations - safe
|
||||
return True
|
||||
if t not in self._broken and t in self._cache_inst:
|
||||
if pkg_id not in self._broken and pkg_id in self._cache_inst:
|
||||
# It is in our cache (and not guaranteed to be broken) - throw out the cache
|
||||
self._cache_inst = set()
|
||||
self._stats.cache_drops += 1
|
||||
|
||||
return True
|
||||
|
||||
def is_installable(self, pkg_name, pkg_version, pkg_arch):
|
||||
def is_installable(self, pkg_id):
|
||||
"""Test if a package is installable in this package set
|
||||
|
||||
The package is assumed to be in "testing" and only packages in
|
||||
@ -228,21 +224,20 @@ class InstallabilityTester(object):
|
||||
"""
|
||||
|
||||
self._stats.is_installable_calls += 1
|
||||
t = (pkg_name, pkg_version, pkg_arch)
|
||||
|
||||
if t not in self._universe:
|
||||
raise KeyError(str(t))
|
||||
if pkg_id not in self._universe:
|
||||
raise KeyError(str(pkg_id))
|
||||
|
||||
if t not in self._testing or t in self._broken:
|
||||
if pkg_id not in self._testing or pkg_id in self._broken:
|
||||
self._stats.cache_hits += 1
|
||||
return False
|
||||
|
||||
if t in self._cache_inst:
|
||||
if pkg_id in self._cache_inst:
|
||||
self._stats.cache_hits += 1
|
||||
return True
|
||||
|
||||
self._stats.cache_misses += 1
|
||||
return self._check_inst(t)
|
||||
return self._check_inst(pkg_id)
|
||||
|
||||
|
||||
def _check_inst(self, t, musts=None, never=None, choices=None):
|
||||
|
Loading…
x
Reference in New Issue
Block a user