From 7bcbcb6282041a1598bfec56a0eca98965de9802 Mon Sep 17 00:00:00 2001 From: Niels Thykier Date: Sun, 5 Aug 2018 13:07:46 +0000 Subject: [PATCH] Make clone_nuninst able to fully deep clone nuninst Signed-off-by: Niels Thykier --- britney.py | 2 +- britney2/utils.py | 22 ++++++++++++++++------ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/britney.py b/britney.py index 2f09573..f9c8ee9 100755 --- a/britney.py +++ b/britney.py @@ -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 diff --git a/britney2/utils.py b/britney2/utils.py index 0fa64c2..4e39fa7 100644 --- a/britney2/utils.py +++ b/britney2/utils.py @@ -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() - 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]) + 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