From 8c8fa3ca346742229127875387d2b1116080bd65 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Mon, 12 Feb 2018 12:04:43 -0800 Subject: [PATCH] binarytree: ignore all but 1 package per cpv for multi-binhost (bug 647076) Restore multi-binhost behavior prior to commit 328dd4712f88cbb8ef390ae9eb471afa1ef781d7, so that all but one package per cpv is ignored. Binhosts specified later in PORTAGE_BINHOST will override those that are specified later. This is the same behavior as the original multi-binhost support that was added in commit 7f84548b516d30de43118d58e6bc03c8739a0967. --- pym/portage/dbapi/bintree.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/pym/portage/dbapi/bintree.py b/pym/portage/dbapi/bintree.py index 201666c41..c40ed0635 100644 --- a/pym/portage/dbapi/bintree.py +++ b/pym/portage/dbapi/bintree.py @@ -811,7 +811,10 @@ class binarytree(object): self._remote_has_index = False self._remotepkgs = {} - for base_url in self.settings["PORTAGE_BINHOST"].split(): + binhosts = self.settings["PORTAGE_BINHOST"].split() + # chromeos multi-binhost unique cpv logic + cpv_unique = {} if len(binhosts) > 1 else None + for base_url in binhosts: parsed_url = urlparse(base_url) host = parsed_url.netloc port = parsed_url.port @@ -1029,6 +1032,17 @@ class binarytree(object): for d in pkgindex.packages: cpv = _pkg_str(d["CPV"], metadata=d, settings=self.settings) + current_key = self.dbapi._instance_key(cpv) + if cpv_unique is not None: + previous = cpv_unique.get(cpv) + if previous is not None: + # Delete previous instance with same cpv but + # different instance key. + previous_key = self.dbapi._instance_key(previous) + if previous_key != current_key: + self.dbapi.cpv_remove(previous) + del self._remotepkgs[previous_key] + cpv_unique[cpv] = cpv # Local package instances override remote instances # with the same instance_key. if self.dbapi.cpv_exists(cpv): -- 2.13.6