Gentoo Archives: gentoo-portage-dev

From: "Michał Górny" <mgorny@g.o>
To: gentoo-portage-dev@l.g.o
Subject: Re: [gentoo-portage-dev] [PATCH 2/2] ebuild.config: Fix filtering all USE_EXPAND variables in EAPI 5+
Date: Sat, 21 May 2016 06:48:21
Message-Id: 20160521084809.33f53d7f.mgorny@gentoo.org
In Reply to: [gentoo-portage-dev] [PATCH 2/2] ebuild.config: Fix filtering all USE_EXPAND variables in EAPI 5+ by "Michał Górny"
1 On Sat, 21 May 2016 00:26:40 +0200
2 Michał Górny <mgorny@g.o> wrote:
3
4 > Ensure that all USE_EXPAND variables are properly filtered and exported
5 > in EAPI 5 and newer, as required by the PMS. This includes exporting
6 > an empty value if no matching flag is provided in IUSE.
7 >
8 > Bug: https://bugs.gentoo.org/show_bug.cgi?id=582140
9 > ---
10 > pym/portage/eapi.py | 6 +++++-
11 > pym/portage/package/ebuild/config.py | 11 ++++++++---
12 > 2 files changed, 13 insertions(+), 4 deletions(-)
13 >
14 > diff --git a/pym/portage/eapi.py b/pym/portage/eapi.py
15 > index 1709026..c4fb374 100644
16 > --- a/pym/portage/eapi.py
17 > +++ b/pym/portage/eapi.py
18 > @@ -50,6 +50,9 @@ def eapi_exports_EBUILD_PHASE_FUNC(eapi):
19 > def eapi_exports_REPOSITORY(eapi):
20 > return eapi in ("4-python", "5-progress")
21 >
22 > +def eapi_exports_USE_EXPAND_variables(eapi):
23 > + return eapi not in ("0", "1", "2", "3", "4", "4-python", "4-slot-abi")
24 > +
25 > def eapi_has_pkg_pretend(eapi):
26 > return eapi not in ("0", "1", "2", "3")
27 >
28 > @@ -101,7 +104,7 @@ def eapi_has_targetroot(eapi):
29 >
30 > _eapi_attrs = collections.namedtuple('_eapi_attrs',
31 > 'dots_in_PN dots_in_use_flags exports_EBUILD_PHASE_FUNC '
32 > - 'feature_flag_test feature_flag_targetroot '
33 > + 'exports_USE_EXPAND_variables feature_flag_test feature_flag_targetroot '
34 > 'hdepend iuse_defaults iuse_effective posixish_locale '
35 > 'repo_deps required_use required_use_at_most_one_of slot_operator slot_deps '
36 > 'src_uri_arrows strong_blocks use_deps use_dep_defaults')
37 > @@ -128,6 +131,7 @@ def _get_eapi_attrs(eapi):
38 > dots_in_PN = (eapi is None or eapi_allows_dots_in_PN(eapi)),
39 > dots_in_use_flags = (eapi is None or eapi_allows_dots_in_use_flags(eapi)),
40 > exports_EBUILD_PHASE_FUNC = (eapi is None or eapi_exports_EBUILD_PHASE_FUNC(eapi)),
41 > + exports_USE_EXPAND_variables = (eapi is None or eapi_exports_USE_EXPAND_variables(eapi)),
42 > feature_flag_test = True,
43 > feature_flag_targetroot = (eapi is not None and eapi_has_targetroot(eapi)),
44 > hdepend = (eapi is not None and eapi_has_hdepend(eapi)),
45 > diff --git a/pym/portage/package/ebuild/config.py b/pym/portage/package/ebuild/config.py
46 > index 5f19996..ee1fadb 100644
47 > --- a/pym/portage/package/ebuild/config.py
48 > +++ b/pym/portage/package/ebuild/config.py
49 > @@ -1279,7 +1279,7 @@ class config(object):
50 >
51 > def __init__(self, settings, unfiltered_use,
52 > use, usemask, iuse_effective,
53 > - use_expand_split, use_expand_dict):
54 > + use_expand_split, use_expand_dict, eapi_exports_USE_EXPAND_variables):
55 > self._settings = settings
56 > self._unfiltered_use = unfiltered_use
57 > self._use = use
58 > @@ -1287,6 +1287,7 @@ class config(object):
59 > self._iuse_effective = iuse_effective
60 > self._use_expand_split = use_expand_split
61 > self._use_expand_dict = use_expand_dict
62 > + self._eapi_exports_USE_EXPAND_variables = eapi_exports_USE_EXPAND_variables
63 >
64 > def __getitem__(self, key):
65 > prefix = key.lower() + '_'
66 > @@ -1330,7 +1331,7 @@ class config(object):
67 > filtered_var_split.append(x)
68 > var_split = filtered_var_split
69 >
70 > - if var_split:
71 > + if var_split or self._eapi_exports_USE_EXPAND_variables:
72 > value = ' '.join(var_split)
73 > else:
74 > # Don't export empty USE_EXPAND vars unless the user config
75 > @@ -1725,9 +1726,13 @@ class config(object):
76 > x in self.get('USE_EXPAND', '').split())
77 > lazy_use_expand = self._lazy_use_expand(
78 > self, unfiltered_use, use, self.usemask,
79 > - portage_iuse, use_expand_split, self._use_expand_dict)
80 > + portage_iuse, use_expand_split, self._use_expand_dict,
81 > + eapi_attrs.exports_USE_EXPAND_variables)
82 >
83 > use_expand_iuses = {}
84 > + if eapi_attrs.exports_USE_EXPAND_variables:
85 > + for k in use_expand_split:
86 > + use_expand_iuses[k] = set()
87 > for x in portage_iuse:
88 > x_split = x.split('_')
89 > if len(x_split) == 1:
90
91 After some thinking, I'll prepare another patch that applies the change
92 to all EAPIs. The behavior for earlier EAPIs is implementation-defined
93 by PMS and having it inconsistent will only confuse users.
94
95 --
96 Best regards,
97 Michał Górny
98 <http://dev.gentoo.org/~mgorny/>