commit:     d107da65c3234b3e73d3ec296a5f843bfde97260
Author:     Daniel M. Weeks <dan <AT> danweeks <DOT> net>
AuthorDate: Tue Jul 23 16:53:50 2019 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Tue Jul 23 21:23:09 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=d107da65

Fix emaint -c binhost support for binpkg-multi-instance

The check function should operate the same way as the fix function when
using FEATURES=binpkg-multi-instance (using the correct _instance_key)
otherwise packages will be erroneously reported as missing.

Fixes: 328dd4712f88 ("binpkg-multi-instance 3 of 7")
Closes: https://github.com/gentoo/portage/pull/439
Bug: https://bugs.gentoo.org/690446
Signed-off-by: Daniel M. Weeks <dan <AT> danweeks.net>
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>

 lib/portage/emaint/modules/binhost/binhost.py | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/lib/portage/emaint/modules/binhost/binhost.py 
b/lib/portage/emaint/modules/binhost/binhost.py
index d3df0cbce..4d1d63601 100644
--- a/lib/portage/emaint/modules/binhost/binhost.py
+++ b/lib/portage/emaint/modules/binhost/binhost.py
@@ -65,7 +65,8 @@ class BinhostHandler(object):
 
        def check(self, **kwargs):
                onProgress = kwargs.get('onProgress', None)
-               missing = []
+               bintree = self._bintree
+               _instance_key = bintree.dbapi._instance_key
                cpv_all = self._bintree.dbapi.cpv_all()
                cpv_all.sort()
                maxval = len(cpv_all)
@@ -73,17 +74,22 @@ class BinhostHandler(object):
                        onProgress(maxval, 0)
                pkgindex = self._pkgindex
                missing = []
+               stale = []
                metadata = {}
                for d in pkgindex.packages:
-                       metadata[d["CPV"]] = d
+                       cpv = _pkg_str(d["CPV"], metadata=d,
+                               settings=bintree.settings)
+                       d["CPV"] = cpv
+                       metadata[_instance_key(cpv)] = d
+                       if not bintree.dbapi.cpv_exists(cpv):
+                               stale.append(cpv)
                for i, cpv in enumerate(cpv_all):
-                       d = metadata.get(cpv)
+                       d = metadata.get(_instance_key(cpv))
                        if not d or self._need_update(cpv, d):
                                missing.append(cpv)
                        if onProgress:
                                onProgress(maxval, i+1)
                errors = ["'%s' is not in Packages" % cpv for cpv in missing]
-               stale = set(metadata).difference(cpv_all)
                for cpv in stale:
                        errors.append("'%s' is not in the repository" % cpv)
                if errors:
@@ -96,7 +102,6 @@ class BinhostHandler(object):
                _instance_key = bintree.dbapi._instance_key
                cpv_all = self._bintree.dbapi.cpv_all()
                cpv_all.sort()
-               missing = []
                maxval = 0
                if onProgress:
                        onProgress(maxval, 0)

Reply via email to