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