commit:     69ce8a71cc806b4b333c2e707e7a9291c3d84664
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Sun Dec 10 22:13:09 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sun Dec 10 22:29:08 2023 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=69ce8a71

_emerge: BinpkgVerifier: give better error message on stale binpkg index

portage-3.0.52 defaults to FEATURES="pkgdir-index-trusted" (see NEWS) which
has a few benefits, but means that manually editing PKGDIR without regenerating
the index with 'emaint binhost -f' will confuse Portage.

Give a better error message mentioning that command if we fail to fetch a binpkg
but bintree.dbapi.cpv_exists says it should exist.

Bug: https://bugs.gentoo.org/915474
Bug: https://bugs.gentoo.org/918597
Signed-off-by: Sam James <sam <AT> gentoo.org>

 lib/_emerge/BinpkgVerifier.py | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/lib/_emerge/BinpkgVerifier.py b/lib/_emerge/BinpkgVerifier.py
index a7917453aa..7e044c6c43 100644
--- a/lib/_emerge/BinpkgVerifier.py
+++ b/lib/_emerge/BinpkgVerifier.py
@@ -41,11 +41,23 @@ class BinpkgVerifier(CompositeTask):
         except OSError as e:
             if e.errno not in (errno.ENOENT, errno.ESTALE):
                 raise
-            self.scheduler.output(
-                f"!!! Fetching Binary failed for '{self.pkg.cpv}'\n",
-                log_path=self.logfile,
-                background=self.background,
-            )
+
+            # We might end up here with FEATURES="pkgdir-index-trusted" if
+            # binpkgs have been removed manually without refreshing the index.
+            if bintree.dbapi.cpv_exists(self.pkg.cpv):
+                self.scheduler.output(
+                    f"!!! Tried to use non-existent binary for 
'{self.pkg.cpv}'\n"
+                    + f"!!! Likely caused by an outdated index. Run 'emaint 
binhost -f'.\n",
+                    log_path=self.logfile,
+                    background=self.background,
+                )
+            else:
+                self.scheduler.output(
+                    f"!!! Fetching Binary failed for '{self.pkg.cpv}'\n",
+                    log_path=self.logfile,
+                    background=self.background,
+                )
+
             self.returncode = 1
             self._async_wait()
             return

Reply via email to