Skip to content

Commit

Permalink
_global_updates: Acquire global vardbapi lock
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
zmedico committed Dec 26, 2023
1 parent fbd6909 commit 7100dfb
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions lib/portage/_global_updates.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 7100dfb

Please sign in to comment.