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.

Reply via email to