1 |
Fix action_build to populate binarytree instances with remote package |
2 |
metadata following config reload, using a new getbinpkg_refresh=False |
3 |
parameter to prevent redundant fetching of remote package metadata. |
4 |
|
5 |
X-Gentoo-bug: 614474 |
6 |
X-Gentoo-bug-url: https://bugs.gentoo.org/show_bug.cgi?id=614474 |
7 |
Fixes: e2d88ef3ff59 ("Add emerge --autounmask-continue option (bug 582624)") |
8 |
--- |
9 |
pym/_emerge/actions.py | 15 +++++++++++++++ |
10 |
pym/portage/dbapi/bintree.py | 19 +++++++++++++++---- |
11 |
2 files changed, 30 insertions(+), 4 deletions(-) |
12 |
|
13 |
diff --git a/pym/_emerge/actions.py b/pym/_emerge/actions.py |
14 |
index cc0269d..818fab9 100644 |
15 |
--- a/pym/_emerge/actions.py |
16 |
+++ b/pym/_emerge/actions.py |
17 |
@@ -347,6 +347,21 @@ def action_build(emerge_config, trees=DeprecationWarning, |
18 |
adjust_configs(emerge_config.opts, emerge_config.trees) |
19 |
settings, trees, mtimedb = emerge_config |
20 |
|
21 |
+ # After config reload, the freshly instantiated binarytree |
22 |
+ # instances need to load remote metadata if --getbinpkg |
23 |
+ # is enabled. Use getbinpkg_refresh=False to use cached |
24 |
+ # metadata, since the cache is already fresh. |
25 |
+ if "--getbinpkg" in emerge_config.opts: |
26 |
+ for root_trees in emerge_config.trees.values(): |
27 |
+ try: |
28 |
+ root_trees["bintree"].populate( |
29 |
+ getbinpkgs=True, |
30 |
+ getbinpkg_refresh=False) |
31 |
+ except ParseError as e: |
32 |
+ writemsg("\n\n!!!%s.\nSee make.conf(5) for more info.\n" |
33 |
+ % e, noiselevel=-1) |
34 |
+ return 1 |
35 |
+ |
36 |
if "--autounmask-only" in myopts: |
37 |
mydepgraph.display_problems() |
38 |
return 0 |
39 |
diff --git a/pym/portage/dbapi/bintree.py b/pym/portage/dbapi/bintree.py |
40 |
index 12c3d3e..ca90ba8 100644 |
41 |
--- a/pym/portage/dbapi/bintree.py |
42 |
+++ b/pym/portage/dbapi/bintree.py |
43 |
@@ -510,8 +510,16 @@ class binarytree(object): |
44 |
except PortageException: |
45 |
pass |
46 |
|
47 |
- def populate(self, getbinpkgs=0): |
48 |
- "populates the binarytree" |
49 |
+ def populate(self, getbinpkgs=False, getbinpkg_refresh=True): |
50 |
+ """ |
51 |
+ Populates the binarytree with package metadata. |
52 |
+ |
53 |
+ @param getbinpkgs: include remote packages |
54 |
+ @type getbinpkgs: bool |
55 |
+ @param getbinpkg_refresh: attempt to refresh the cache |
56 |
+ of remote package metadata if getbinpkgs is also True |
57 |
+ @type getbinpkg_refresh: bool |
58 |
+ """ |
59 |
|
60 |
if self._populating: |
61 |
return |
62 |
@@ -522,13 +530,13 @@ class binarytree(object): |
63 |
pkgindex_lock = lockfile(self._pkgindex_file, |
64 |
wantnewlockfile=1) |
65 |
self._populating = True |
66 |
- self._populate(getbinpkgs) |
67 |
+ self._populate(getbinpkgs, getbinpkg_refresh=getbinpkg_refresh) |
68 |
finally: |
69 |
if pkgindex_lock: |
70 |
unlockfile(pkgindex_lock) |
71 |
self._populating = False |
72 |
|
73 |
- def _populate(self, getbinpkgs=0): |
74 |
+ def _populate(self, getbinpkgs=False, getbinpkg_refresh=True): |
75 |
if (not os.path.isdir(self.pkgdir) and not getbinpkgs): |
76 |
return 0 |
77 |
|
78 |
@@ -832,6 +840,9 @@ class binarytree(object): |
79 |
url = base_url.rstrip("/") + "/Packages" |
80 |
f = None |
81 |
|
82 |
+ if not getbinpkg_refresh and local_timestamp: |
83 |
+ raise UseCachedCopyOfRemoteIndex() |
84 |
+ |
85 |
try: |
86 |
ttl = float(pkgindex.header.get("TTL", 0)) |
87 |
except ValueError: |
88 |
-- |
89 |
2.10.2 |