Skip to content

Commit

Permalink
emerge: fix --autounmask-continue to work with --getbinpkg (bug 614474)
Browse files Browse the repository at this point in the history
Fix action_build to populate binarytree instances with remote package
metadata following config reload, using a new getbinpkg_refresh=False
parameter to prevent redundant fetching of remote package metadata.

X-Gentoo-bug: 614474
X-Gentoo-bug-url: https://bugs.gentoo.org/show_bug.cgi?id=614474
Fixes: e2d88ef ("Add emerge --autounmask-continue option (bug 582624)")
Acked-by: Brian Dolbec <dolsen@gentoo.org>
  • Loading branch information
zmedico committed Apr 3, 2017
1 parent a83bb83 commit f479250
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
15 changes: 15 additions & 0 deletions pym/_emerge/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,21 @@ def action_build(emerge_config, trees=DeprecationWarning,
adjust_configs(emerge_config.opts, emerge_config.trees)
settings, trees, mtimedb = emerge_config

# After config reload, the freshly instantiated binarytree
# instances need to load remote metadata if --getbinpkg
# is enabled. Use getbinpkg_refresh=False to use cached
# metadata, since the cache is already fresh.
if "--getbinpkg" in emerge_config.opts:
for root_trees in emerge_config.trees.values():
try:
root_trees["bintree"].populate(
getbinpkgs=True,
getbinpkg_refresh=False)
except ParseError as e:
writemsg("\n\n!!!%s.\nSee make.conf(5) for more info.\n"
% e, noiselevel=-1)
return 1

if "--autounmask-only" in myopts:
mydepgraph.display_problems()
return 0
Expand Down
19 changes: 15 additions & 4 deletions pym/portage/dbapi/bintree.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,8 +510,16 @@ def _file_permissions(self, path):
except PortageException:
pass

def populate(self, getbinpkgs=0):
"populates the binarytree"
def populate(self, getbinpkgs=False, getbinpkg_refresh=True):
"""
Populates the binarytree with package metadata.
@param getbinpkgs: include remote packages
@type getbinpkgs: bool
@param getbinpkg_refresh: attempt to refresh the cache
of remote package metadata if getbinpkgs is also True
@type getbinpkg_refresh: bool
"""

if self._populating:
return
Expand All @@ -522,13 +530,13 @@ def populate(self, getbinpkgs=0):
pkgindex_lock = lockfile(self._pkgindex_file,
wantnewlockfile=1)
self._populating = True
self._populate(getbinpkgs)
self._populate(getbinpkgs, getbinpkg_refresh=getbinpkg_refresh)
finally:
if pkgindex_lock:
unlockfile(pkgindex_lock)
self._populating = False

def _populate(self, getbinpkgs=0):
def _populate(self, getbinpkgs=False, getbinpkg_refresh=True):
if (not os.path.isdir(self.pkgdir) and not getbinpkgs):
return 0

Expand Down Expand Up @@ -832,6 +840,9 @@ def _populate(self, getbinpkgs=0):
url = base_url.rstrip("/") + "/Packages"
f = None

if not getbinpkg_refresh and local_timestamp:
raise UseCachedCopyOfRemoteIndex()

try:
ttl = float(pkgindex.header.get("TTL", 0))
except ValueError:
Expand Down

0 comments on commit f479250

Please sign in to comment.