From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gentoo-commits+bounces-1385215-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 85EE615808B
	for <garchives@archives.gentoo.org>; Wed, 13 Apr 2022 15:34:43 +0000 (UTC)
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id B2442E0A4A;
	Wed, 13 Apr 2022 15:34:42 +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 8A08CE0A4A
	for <gentoo-commits@lists.gentoo.org>; Wed, 13 Apr 2022 15:34:42 +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))
	(No client certificate requested)
	by smtp.gentoo.org (Postfix) with ESMTPS id 70EDE341DD5
	for <gentoo-commits@lists.gentoo.org>; Wed, 13 Apr 2022 15:34:41 +0000 (UTC)
Received: from localhost.localdomain (localhost [IPv6:::1])
	by oystercatcher.gentoo.org (Postfix) with ESMTP id D099B395
	for <gentoo-commits@lists.gentoo.org>; Wed, 13 Apr 2022 15:34:39 +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: <1649864070.964c0e16172b76a8ebdd737cd8919870ae2b5f96.sam@gentoo>
Subject: [gentoo-commits] proj/portage:master commit in: lib/portage/dbapi/
X-VCS-Repository: proj/portage
X-VCS-Files: lib/portage/dbapi/vartree.py
X-VCS-Directories: lib/portage/dbapi/
X-VCS-Committer: sam
X-VCS-Committer-Name: Sam James
X-VCS-Revision: 964c0e16172b76a8ebdd737cd8919870ae2b5f96
X-VCS-Branch: master
Date: Wed, 13 Apr 2022 15:34:39 +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: c8b5e95b-0432-4f96-94c9-4939a54ae3f3
X-Archives-Hash: d879708dc339ce9db72ccd8e292e8718

commit:     964c0e16172b76a8ebdd737cd8919870ae2b5f96
Author:     Mike Frysinger <vapier <AT> chromium <DOT> org>
AuthorDate: Tue Mar 29 13:56:55 2022 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Wed Apr 13 15:34:30 2022 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=964c0e16

vartree: skip env-update if no updates were merged

This speeds up virtual/ installs by not constantly re-running env-update.

[sam: cherry-picked from chromiumos' third_party/portage_tool repo]
(cherry picked from commit 87ac3566ebb7155a57876d345849bd0fd6878c0e)

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

 lib/portage/dbapi/vartree.py | 38 +++++++++++++++++++++-----------------
 1 file changed, 21 insertions(+), 17 deletions(-)

diff --git a/lib/portage/dbapi/vartree.py b/lib/portage/dbapi/vartree.py
index 072bc1506..e7252790d 100644
--- a/lib/portage/dbapi/vartree.py
+++ b/lib/portage/dbapi/vartree.py
@@ -2608,14 +2608,16 @@ class dblink:
         else:
             self.settings.pop("PORTAGE_LOG_FILE", None)
 
-        env_update(
-            target_root=self.settings["ROOT"],
-            prev_mtimes=ldpath_mtimes,
-            contents=contents,
-            env=self.settings,
-            writemsg_level=self._display_merge,
-            vardbapi=self.vartree.dbapi,
-        )
+        # If we didn't unmerge anything, don't bother updating env.
+        if contents:
+            env_update(
+                target_root=self.settings["ROOT"],
+                prev_mtimes=ldpath_mtimes,
+                contents=contents,
+                env=self.settings,
+                writemsg_level=self._display_merge,
+                vardbapi=self.vartree.dbapi,
+            )
 
         unmerge_with_replacement = preserve_paths is not None
         if not unmerge_with_replacement:
@@ -5258,15 +5260,17 @@ class dblink:
                 ],
             )
 
-        # update environment settings, library paths. DO NOT change symlinks.
-        env_update(
-            target_root=self.settings["ROOT"],
-            prev_mtimes=prev_mtimes,
-            contents=contents,
-            env=self.settings,
-            writemsg_level=self._display_merge,
-            vardbapi=self.vartree.dbapi,
-        )
+        # Update environment settings, library paths. DO NOT change symlinks.
+        # Only do this if we actually installed something.
+        if contents:
+            env_update(
+                target_root=self.settings["ROOT"],
+                prev_mtimes=prev_mtimes,
+                contents=contents,
+                env=self.settings,
+                writemsg_level=self._display_merge,
+                vardbapi=self.vartree.dbapi,
+            )
 
         # For gcc upgrades, preserved libs have to be removed after the
         # the library path has been updated.