On Sat, 21 May 2016 00:26:40 +0200
Michał Górny <mgo...@gentoo.org> wrote:

> Ensure that all USE_EXPAND variables are properly filtered and exported
> in EAPI 5 and newer, as required by the PMS. This includes exporting
> an empty value if no matching flag is provided in IUSE.
> 
> Bug: https://bugs.gentoo.org/show_bug.cgi?id=582140
> ---
>  pym/portage/eapi.py                  |  6 +++++-
>  pym/portage/package/ebuild/config.py | 11 ++++++++---
>  2 files changed, 13 insertions(+), 4 deletions(-)
> 
> diff --git a/pym/portage/eapi.py b/pym/portage/eapi.py
> index 1709026..c4fb374 100644
> --- a/pym/portage/eapi.py
> +++ b/pym/portage/eapi.py
> @@ -50,6 +50,9 @@ def eapi_exports_EBUILD_PHASE_FUNC(eapi):
>  def eapi_exports_REPOSITORY(eapi):
>       return eapi in ("4-python", "5-progress")
>  
> +def eapi_exports_USE_EXPAND_variables(eapi):
> +     return eapi not in ("0", "1", "2", "3", "4", "4-python", "4-slot-abi")
> +
>  def eapi_has_pkg_pretend(eapi):
>       return eapi not in ("0", "1", "2", "3")
>  
> @@ -101,7 +104,7 @@ def eapi_has_targetroot(eapi):
>  
>  _eapi_attrs = collections.namedtuple('_eapi_attrs',
>       'dots_in_PN dots_in_use_flags exports_EBUILD_PHASE_FUNC '
> -     'feature_flag_test feature_flag_targetroot '
> +     'exports_USE_EXPAND_variables feature_flag_test feature_flag_targetroot 
> '
>       'hdepend iuse_defaults iuse_effective posixish_locale '
>       'repo_deps required_use required_use_at_most_one_of slot_operator 
> slot_deps '
>       'src_uri_arrows strong_blocks use_deps use_dep_defaults')
> @@ -128,6 +131,7 @@ def _get_eapi_attrs(eapi):
>               dots_in_PN = (eapi is None or eapi_allows_dots_in_PN(eapi)),
>               dots_in_use_flags = (eapi is None or 
> eapi_allows_dots_in_use_flags(eapi)),
>               exports_EBUILD_PHASE_FUNC = (eapi is None or 
> eapi_exports_EBUILD_PHASE_FUNC(eapi)),
> +             exports_USE_EXPAND_variables = (eapi is None or 
> eapi_exports_USE_EXPAND_variables(eapi)),
>               feature_flag_test = True,
>               feature_flag_targetroot = (eapi is not None and 
> eapi_has_targetroot(eapi)),
>               hdepend = (eapi is not None and eapi_has_hdepend(eapi)),
> diff --git a/pym/portage/package/ebuild/config.py 
> b/pym/portage/package/ebuild/config.py
> index 5f19996..ee1fadb 100644
> --- a/pym/portage/package/ebuild/config.py
> +++ b/pym/portage/package/ebuild/config.py
> @@ -1279,7 +1279,7 @@ class config(object):
>  
>               def __init__(self, settings, unfiltered_use,
>                       use, usemask, iuse_effective,
> -                     use_expand_split, use_expand_dict):
> +                     use_expand_split, use_expand_dict, 
> eapi_exports_USE_EXPAND_variables):
>                       self._settings = settings
>                       self._unfiltered_use = unfiltered_use
>                       self._use = use
> @@ -1287,6 +1287,7 @@ class config(object):
>                       self._iuse_effective = iuse_effective
>                       self._use_expand_split = use_expand_split
>                       self._use_expand_dict = use_expand_dict
> +                     self._eapi_exports_USE_EXPAND_variables = 
> eapi_exports_USE_EXPAND_variables
>  
>               def __getitem__(self, key):
>                       prefix = key.lower() + '_'
> @@ -1330,7 +1331,7 @@ class config(object):
>                                       filtered_var_split.append(x)
>                       var_split = filtered_var_split
>  
> -                     if var_split:
> +                     if var_split or self._eapi_exports_USE_EXPAND_variables:
>                               value = ' '.join(var_split)
>                       else:
>                               # Don't export empty USE_EXPAND vars unless the 
> user config
> @@ -1725,9 +1726,13 @@ class config(object):
>                       x in self.get('USE_EXPAND', '').split())
>               lazy_use_expand = self._lazy_use_expand(
>                       self, unfiltered_use, use, self.usemask,
> -                     portage_iuse, use_expand_split, self._use_expand_dict)
> +                     portage_iuse, use_expand_split, self._use_expand_dict,
> +                     eapi_attrs.exports_USE_EXPAND_variables)
>  
>               use_expand_iuses = {}
> +             if eapi_attrs.exports_USE_EXPAND_variables:
> +                     for k in use_expand_split:
> +                             use_expand_iuses[k] = set()
>               for x in portage_iuse:
>                       x_split = x.split('_')
>                       if len(x_split) == 1:

After some thinking, I'll prepare another patch that applies the change
to all EAPIs. The behavior for earlier EAPIs is implementation-defined
by PMS and having it inconsistent will only confuse users.

-- 
Best regards,
Michał Górny
<http://dev.gentoo.org/~mgorny/>

Attachment: pgpwxUpygWeHZ.pgp
Description: OpenPGP digital signature

Reply via email to