From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gentoo-commits+bounces-1557754-garchives=archives.gentoo.org@lists.gentoo.org>
Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (2048 bits))
	(No client certificate requested)
	by finch.gentoo.org (Postfix) with ESMTPS id 0B3F7158089
	for <garchives@archives.gentoo.org>; Tue, 26 Sep 2023 21:09:50 +0000 (UTC)
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id 492692BC016;
	Tue, 26 Sep 2023 21:09:49 +0000 (UTC)
Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (4096 bits))
	(No client certificate requested)
	by pigeon.gentoo.org (Postfix) with ESMTPS id 29A0B2BC016
	for <gentoo-commits@lists.gentoo.org>; Tue, 26 Sep 2023 21:09:49 +0000 (UTC)
Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256)
	(No client certificate requested)
	by smtp.gentoo.org (Postfix) with ESMTPS id 392C0335CD2
	for <gentoo-commits@lists.gentoo.org>; Tue, 26 Sep 2023 21:09:48 +0000 (UTC)
Received: from localhost.localdomain (localhost [IPv6:::1])
	by oystercatcher.gentoo.org (Postfix) with ESMTP id 9FFC710D2
	for <gentoo-commits@lists.gentoo.org>; Tue, 26 Sep 2023 21:09:46 +0000 (UTC)
From: "Sam James" <sam@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Content-Transfer-Encoding: 8bit
Content-type: text/plain; charset=UTF-8
Reply-To: gentoo-dev@lists.gentoo.org, "Sam James" <sam@gentoo.org>
Message-ID: <1695762568.cec349d7cfcda634e3f76cd3ca0c1a89bc46f414.sam@gentoo>
Subject: [gentoo-commits] proj/portage:master commit in: lib/portage/dbapi/
X-VCS-Repository: proj/portage
X-VCS-Files: lib/portage/dbapi/bintree.py
X-VCS-Directories: lib/portage/dbapi/
X-VCS-Committer: sam
X-VCS-Committer-Name: Sam James
X-VCS-Revision: cec349d7cfcda634e3f76cd3ca0c1a89bc46f414
X-VCS-Branch: master
Date: Tue, 26 Sep 2023 21:09:46 +0000 (UTC)
Precedence: bulk
List-Post: <mailto:gentoo-commits@lists.gentoo.org>
List-Help: <mailto:gentoo-commits+help@lists.gentoo.org>
List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org>
List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org>
List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org>
X-BeenThere: gentoo-commits@lists.gentoo.org
X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply
X-Archives-Salt: e2e2225a-4623-48ad-bff3-37ecf0af14ac
X-Archives-Hash: 577cd8e6849663b0f5106ada91b96727

commit:     cec349d7cfcda634e3f76cd3ca0c1a89bc46f414
Author:     hypersyd <70613804+siddhanthrathod <AT> users <DOT> noreply <DOT> github <DOT> com>
AuthorDate: Sat Sep  9 13:51:31 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Tue Sep 26 21:09:28 2023 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=cec349d7

bintree: populate invalid_paths list for eclean-pkg

Enable eclean-pkg to handle incomplete merges from binhost.

It's an extension for gentoolkit's eclean-pkg clean invalids feature to deal with
binpkgs created by the new binhost without any tar header or format due to incomplete merges.

This results in gpkg.py --> class gpkg --> method _get_tar_format returning null which raises
PortagePackageException and SignatureException in binpkg.py --> Class binarytree.

Add an input for invalid paths api is being added so the eclean-pkg can clean it up.

Invalids feature: https://github.com/gentoo/gentoolkit/commit/a16d0d4fbfb4614832c4b682b41284a9050af29f, https://github.com/gentoo/portage/commit/71daef3ac877329a0479a72ba333a9c801a36bf3
Bug: https://bugs.gentoo.org/900224
Signed-off-by: Siddhanth Rathod <xsiddhanthrathod <AT> gmail.com>
Closes: https://github.com/gentoo/portage/pull/1091
Signed-off-by: Sam James <sam <AT> gentoo.org>

 lib/portage/dbapi/bintree.py | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/lib/portage/dbapi/bintree.py b/lib/portage/dbapi/bintree.py
index 42912b2eb5..580ce2f290 100644
--- a/lib/portage/dbapi/bintree.py
+++ b/lib/portage/dbapi/bintree.py
@@ -1050,6 +1050,10 @@ class binarytree:
                         else:
                             binpkg_format = "gpkg"
 
+                    for ext in SUPPORTED_XPAK_EXTENSIONS + SUPPORTED_GPKG_EXTENSIONS:
+                        if myfile.endswith(ext):
+                            mypkg = myfile[: -len(ext)]
+                            break
                     try:
                         pkg_metadata = self._read_metadata(
                             full_path,
@@ -1062,14 +1066,11 @@ class binarytree:
                             f"!!! Invalid binary package: '{full_path}', {e}\n",
                             noiselevel=-1,
                         )
+                        self.invalid_paths[mypkg] = [full_path]
                         continue
                     mycat = pkg_metadata.get("CATEGORY", "")
                     mypf = pkg_metadata.get("PF", "")
                     slot = pkg_metadata.get("SLOT", "")
-                    for ext in SUPPORTED_XPAK_EXTENSIONS + SUPPORTED_GPKG_EXTENSIONS:
-                        if myfile.endswith(ext):
-                            mypkg = myfile[: -len(ext)]
-                            break
                     if not mycat or not mypf or not slot:
                         # old-style or corrupt package
                         writemsg(