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