aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2023-12-26 14:24:59 -0800
committerZac Medico <zmedico@gentoo.org>2023-12-26 14:28:07 -0800
commit7100dfb769b9d98eb40a92c37d154cb4bc83292f (patch)
tree5fd432069b143efac84a1e1839db9cec0f1c1891
parentScheduler: Handle unpack_metadata SignatureException in _run_pkg_pretend (diff)
downloadportage-7100dfb769b9d98eb40a92c37d154cb4bc83292f.tar.gz
portage-7100dfb769b9d98eb40a92c37d154cb4bc83292f.tar.bz2
portage-7100dfb769b9d98eb40a92c37d154cb4bc83292f.zip
_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@gentoo.org>
-rw-r--r--lib/portage/_global_updates.py15
1 files changed, 10 insertions, 5 deletions
diff --git a/lib/portage/_global_updates.py b/lib/portage/_global_updates.py
index ba183e87b..f7997fc37 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()