From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gentoo-commits+bounces-1334155-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 E9C37158086
	for <garchives@archives.gentoo.org>; Thu, 28 Oct 2021 04:52:43 +0000 (UTC)
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id AD616E088D;
	Thu, 28 Oct 2021 04:52:41 +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) server-digest SHA256)
	(No client certificate requested)
	by pigeon.gentoo.org (Postfix) with ESMTPS id 96E48E088D
	for <gentoo-commits@lists.gentoo.org>; Thu, 28 Oct 2021 04:52:41 +0000 (UTC)
Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84])
	(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 4A5D6343B24
	for <gentoo-commits@lists.gentoo.org>; Thu, 28 Oct 2021 04:52:40 +0000 (UTC)
Received: from localhost.localdomain (localhost [IPv6:::1])
	by oystercatcher.gentoo.org (Postfix) with ESMTP id D1A2817D
	for <gentoo-commits@lists.gentoo.org>; Thu, 28 Oct 2021 04:52:38 +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: <1635396752.216e962ae494e8291b667665007d045788b3e391.sam@gentoo>
Subject: [gentoo-commits] proj/portage:master commit in: lib/_emerge/
X-VCS-Repository: proj/portage
X-VCS-Files: lib/_emerge/Binpkg.py
X-VCS-Directories: lib/_emerge/
X-VCS-Committer: sam
X-VCS-Committer-Name: Sam James
X-VCS-Revision: 216e962ae494e8291b667665007d045788b3e391
X-VCS-Branch: master
Date: Thu, 28 Oct 2021 04:52:38 +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: 85461c9f-af42-4494-b3bf-595644783a1a
X-Archives-Hash: 2d7be01d1ac0ef5e449bc283c8947e9a

commit:     216e962ae494e8291b667665007d045788b3e391
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Thu Oct 28 04:40:09 2021 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Thu Oct 28 04:52:32 2021 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=216e962a

Binpkg.py: check for inconsistent PROVIDES/image when unpacking binpkg

This is part of a series of fixes for the linked bug (failure
to preserve libraries in some situations).

When unpacking a binpkg to be installed, we should check
for the existence of PROVIDES if we're installing any
dynamic libraries. If PROVIDES does not exist in that case,
this suggests that e.g. scanelf malfunctioned or some corruption occurred.

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

 lib/_emerge/Binpkg.py | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/lib/_emerge/Binpkg.py b/lib/_emerge/Binpkg.py
index c7dde69bd..001283611 100644
--- a/lib/_emerge/Binpkg.py
+++ b/lib/_emerge/Binpkg.py
@@ -2,7 +2,6 @@
 # Distributed under the terms of the GNU General Public License v2
 
 import functools
-
 import _emerge.emergelog
 from _emerge.EbuildPhase import EbuildPhase
 from _emerge.BinpkgFetcher import BinpkgFetcher
@@ -13,8 +12,10 @@ from _emerge.EbuildMerge import EbuildMerge
 from _emerge.EbuildBuildDir import EbuildBuildDir
 from _emerge.SpawnProcess import SpawnProcess
 from portage.eapi import eapi_exports_replace_vars
+from portage.output import colorize
 from portage.util import ensure_dirs
 from portage.util._async.AsyncTaskFuture import AsyncTaskFuture
+from portage.util._dyn_libs.dyn_libs import check_dyn_libs_inconsistent
 import portage
 from portage import os
 from portage import shutil
@@ -425,6 +426,18 @@ class Binpkg(CompositeTask):
             self._async_unlock_builddir(returncode=self.returncode)
             return
 
+        # Before anything else, let's do an integrity check.
+        (provides,) = self._bintree.dbapi.aux_get(self.pkg.cpv, ["PROVIDES"])
+        if check_dyn_libs_inconsistent(self.settings["D"], provides):
+            self._writemsg_level(
+                colorize(
+                    "BAD",
+                    "!!! Error! Installing dynamic libraries (.so) with blank PROVIDES!",
+                ),
+                noiselevel=-1,
+                level=logging.ERROR,
+            )
+
         try:
             with io.open(
                 _unicode_encode(