commit:     7100dfb769b9d98eb40a92c37d154cb4bc83292f
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Tue Dec 26 22:24:59 2023 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Tue Dec 26 22:28:07 2023 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=7100dfb7

_global_updates: Acquire global vardbapi lock

Also use bindbapi.writable attribute in case the
PKGDIR is missing for some reason.

Bug: https://bugs.gentoo.org/587088
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>

 lib/portage/_global_updates.py | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/lib/portage/_global_updates.py b/lib/portage/_global_updates.py
index ba183e87b5..f7997fc37c 100644
--- a/lib/portage/_global_updates.py
+++ b/lib/portage/_global_updates.py
@@ -1,4 +1,4 @@
-# Copyright 2010-2020 Gentoo Authors
+# Copyright 2010-2023 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 import stat
@@ -38,9 +38,14 @@ def _global_updates(trees, prev_mtimes, quiet=False, 
if_mtime_changed=True):
     if secpass < 2 or "SANDBOX_ACTIVE" in os.environ or len(trees) != 1:
         return False
 
-    return _do_global_updates(
-        trees, prev_mtimes, quiet=quiet, if_mtime_changed=if_mtime_changed
-    )
+    vardb = trees[trees._running_eroot]["vartree"].dbapi
+    vardb.lock()
+    try:
+        return _do_global_updates(
+            trees, prev_mtimes, quiet=quiet, if_mtime_changed=if_mtime_changed
+        )
+    finally:
+        vardb.unlock()
 
 
 def _do_global_updates(trees, prev_mtimes, quiet=False, if_mtime_changed=True):
@@ -127,7 +132,7 @@ def _do_global_updates(trees, prev_mtimes, quiet=False, 
if_mtime_changed=True):
                 retupd = True
 
     if retupd:
-        if os.access(bindb.bintree.pkgdir, os.W_OK):
+        if bindb.writable:
             # Call binarytree.populate(), since we want to make sure it's
             # only populated with local packages here (getbinpkgs=0).
             bindb.bintree.populate()

Reply via email to