From 7100dfb769b9d98eb40a92c37d154cb4bc83292f Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Tue, 26 Dec 2023 14:24:59 -0800 Subject: _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 --- 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 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() -- cgit v1.2.3-65-gdbad