Make clone_nuninst able to fully deep clone nuninst

Signed-off-by: Niels Thykier <niels@thykier.net>
ubuntu/rebased
Niels Thykier 6 years ago
parent bd0a96553c
commit 7bcbcb6282
No known key found for this signature in database
GPG Key ID: A65B78DBE67C7AAC

@ -2161,7 +2161,7 @@ class Britney(object):
# removed binaries. Otherwise, uninstallable binaries that were
# removed by the item would still be counted.
nuninst_after = clone_nuninst(nuninst_now, packages_t, affected_architectures)
nuninst_after = clone_nuninst(nuninst_now, packages_s=packages_t, architectures=affected_architectures)
must_be_installable = self.constraints['keep-installable']
# check the affected packages on all the architectures

@ -537,18 +537,28 @@ def is_nuninst_asgood_generous(constraints, architectures, old, new, break_arche
return True
def clone_nuninst(nuninst, packages_s, architectures):
"""Selectively deep clone nuninst
def clone_nuninst(nuninst, *, packages_s=None, architectures=None):
"""Completely or Selectively deep clone nuninst
Given nuninst table, the package table for a given suite and
a list of architectures, this function will clone the nuninst
table. Only the listed architectures will be deep cloned -
the rest will only be shallow cloned.
the rest will only be shallow cloned. When packages_s is given,
packages not listed in packages_s will be pruned from the clone
(if packages_s is omitted, the per architecture nuninst is cloned
as-is)
"""
clone = nuninst.copy()
if architectures is None:
return clone
if packages_s is not None:
for arch in architectures:
clone[arch] = set(x for x in nuninst[arch] if x in packages_s[arch])
clone[arch + "+all"] = set(x for x in nuninst[arch + "+all"] if x in packages_s[arch])
else:
for arch in architectures:
clone[arch] = set(nuninst[arch])
clone[arch + "+all"] = set(nuninst[arch + "+all"])
return clone

Loading…
Cancel
Save