commit:     71daef3ac877329a0479a72ba333a9c801a36bf3
Author:     Siddhanth Rathod <xsiddhanthrathod <AT> gmail <DOT> com>
AuthorDate: Thu Mar 23 16:28:14 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Mon Aug 21 05:15:05 2023 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=71daef3a

bintree: Add invalid_paths member to API

Add object invalid_paths for new eclean feature to deal with invalid binpkgs.

This is needed for gentoolkit's eclean to handle cleaning up invalid binpkgs.

gentoolkit side PR: https://github.com/gentoo/gentoolkit/pull/28
Bug: https://bugs.gentoo.org/900224
Signed-off-by: Siddhanth Rathod <xsiddhanthrathod <AT> gmail.com>
Closes: https://github.com/gentoo/portage/pull/1016
Signed-off-by: Sam James <sam <AT> gentoo.org>

 NEWS                                    | 7 +++++++
 lib/portage/dbapi/bintree.py            | 4 ++++
 lib/portage/tests/dbapi/test_bintree.py | 1 +
 3 files changed, 12 insertions(+)

diff --git a/NEWS b/NEWS
index a59af3818b..d770e0b7e9 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,10 @@
+portage-3.0.52 (UNRELEASED)
+--------------
+
+Features:
+* bintree: Add new API member (invalid_paths) to allow gentoolkit to later
+  clean up invalid binpkgs (bug #900224).
+
 portage-3.0.51 (2023-08-20)
 --------------
 

diff --git a/lib/portage/dbapi/bintree.py b/lib/portage/dbapi/bintree.py
index 5f58c548d6..af2113bd84 100644
--- a/lib/portage/dbapi/bintree.py
+++ b/lib/portage/dbapi/bintree.py
@@ -485,6 +485,7 @@ class binarytree:
         self._remotepkgs = None  # remote metadata indexed by cpv
         self._additional_pkgs = {}
         self.invalids = []
+        self.invalid_paths: dict[str, list[str]] = {}
         self.settings = settings
         self._pkg_paths = {}
         self._populating = False
@@ -1017,12 +1018,14 @@ class binarytree:
                             noiselevel=-1,
                         )
                         self.invalids.append(myfile[:-5])
+                        self.invalid_paths[myfile] = [full_path]
                         continue
 
                     try:
                         binpkg_format = get_binpkg_format(myfile)
                     except InvalidBinaryPackageFormat:
                         self.invalids.append(myfile[:-5])
+                        self.invalid_paths[myfile[:-5]] = [full_path]
                         continue
 
                     if gpkg_only:
@@ -1089,6 +1092,7 @@ class binarytree:
                         for line in textwrap.wrap("".join(msg), 72):
                             writemsg(f"!!! {line}\n", noiselevel=-1)
                         self.invalids.append(mypkg)
+                        self.invalid_paths[mypkg] = [full_path]
                         continue
 
                     multi_instance = False

diff --git a/lib/portage/tests/dbapi/test_bintree.py 
b/lib/portage/tests/dbapi/test_bintree.py
index 383d5585e7..60785b4e59 100644
--- a/lib/portage/tests/dbapi/test_bintree.py
+++ b/lib/portage/tests/dbapi/test_bintree.py
@@ -46,6 +46,7 @@ class BinarytreeTestCase(TestCase):
             "_remotepkgs",
             "_additional_pkgs",
             "invalids",
+            "invalid_paths",
             "settings",
             "_pkg_paths",
             "_populating",

Reply via email to