Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 593086

Summary: sys-apps/portage: UseManager should warn about USE-deps in package.use, and discard them
Product: Portage Development Reporter: Zac Medico <zmedico>
Component: Core - ConfigurationAssignee: Portage team <dev-portage>
Status: CONFIRMED ---    
Severity: normal Keywords: PATCH
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: All   
Package list:
Runtime testing required: ---

Description Zac Medico gentoo-dev 2016-09-07 23:11:36 UTC
USE-deps in package.use cause setcpv recursion, as show with this patch:

diff --git a/pym/portage/package/ebuild/ b/pym/portage/package/ebuild/
index 45b7d08..aa7f20b 100644
--- a/pym/portage/package/ebuild/
+++ b/pym/portage/package/ebuild/
@@ -1372,6 +1372,21 @@ class config(object):

                        return value

+       def _setcpv_recursion_gate(f):
+               """
+               Raise AssertionError for recursive setcpv calls.
+               """
+               def wrapper(self, *args, **kwargs):
+                       if hasattr(self, '_setcpv_active'):
+                               raise AssertionError('setcpv recursion detected')
+                       self._setcpv_active = True
+                       try:
+                               return f(self, *args, **kwargs)
+                       finally:
+                               del self._setcpv_active
+               return wrapper
+       @_setcpv_recursion_gate
        def setcpv(self, mycpv, use_cache=None, mydb=None):
                Load a particular CPV into the config, this lets us see the

Traceback (most recent call last):
  File "./bin/emerge", line 50, in <module>
    retval = emerge_main()
  File "pym/_emerge/", line 1224, in emerge_main
    return run_action(emerge_config)
  File "pym/_emerge/", line 3261, in run_action
    retval = action_build(emerge_config, spinner=spinner)
  File "pym/_emerge/", line 338, in action_build
    settings, trees, myopts, myparams, myaction, myfiles, spinner)
  File "pym/_emerge/", line 9247, in backtrack_depgraph
    myaction, myfiles, spinner)
  File "pym/_emerge/", line 9284, in _backtrack_depgraph
    success, favorites = mydepgraph.select_files(myfiles)
  File "pym/_emerge/", line 3606, in select_files
    return self._select_files(args)
  File "pym/_emerge/", line 3949, in _select_files
    return self._resolve(myfavorites)
  File "pym/_emerge/", line 4013, in _resolve
    myroot, atom, onlydeps=onlydeps)
  File "pym/_emerge/", line 5364, in _select_pkg_highest_available
    ret = self._select_pkg_highest_available_imp(root, atom, onlydeps=onlydeps, parent=parent)
  File "pym/_emerge/", line 5576, in _select_pkg_highest_available_imp
    root, atom, onlydeps=onlydeps, parent=parent)
  File "pym/_emerge/", line 5872, in _wrapped_select_pkg_highest_available_imp
  File "pym/_emerge/", line 5282, in _iter_match_pkgs_atom
    installed=installed, onlydeps=onlydeps, myrepo=repo)
  File "pym/_emerge/", line 6580, in _pkg
    if not self._pkg_visibility_check(pkg) and \
  File "pym/_emerge/", line 5620, in _pkg_visibility_check
    if pkg.visible:
  File "pym/_emerge/", line 177, in visible
    self._visible = self._eval_visiblity(self.masks)
  File "pym/_emerge/", line 171, in masks
    self._masks = self._eval_masks()
  File "pym/_emerge/", line 403, in _eval_masks
    self.cpv, self._metadata)
  File "pym/portage/package/ebuild/", line 2047, in _getMissingLicenses
    cpv, metadata["USE"], metadata["LICENSE"], metadata["SLOT"], metadata.get('repository'))
  File "pym/_emerge/", line 872, in __getitem__
    v = self._pkg._init_use()
  File "pym/_emerge/", line 664, in _init_use
    use_str = self._get_pkgsettings()["PORTAGE_USE"]
  File "pym/_emerge/", line 639, in _get_pkgsettings
  File "pym/portage/package/ebuild/", line 1384, in wrapper
    return f(self, *args, **kwargs)
  File "pym/portage/package/ebuild/", line 1562, in setcpv
    self.puse = self._use_manager.getPUSE(cpv_slot)
  File "pym/portage/package/ebuild/_config/", line 555, in getPUSE
    puse_matches = ordered_by_atom_specificity(cpdict, pkg)
  File "pym/portage/package/ebuild/_config/", line 34, in ordered_by_atom_specificity
    bestmatch = best_match_to_list(pkg, keys)
  File "pym/portage/dep/", line 2058, in best_match_to_list
    for x in match_to_list(mypkg, mylist):
  File "pym/portage/dep/", line 2026, in match_to_list
    if x not in matches and match_from_list(x, pkgs):
  File "pym/portage/dep/", line 2341, in match_from_list
    use = getattr(x, "use", None)
  File "pym/_emerge/", line 633, in use
  File "pym/_emerge/", line 664, in _init_use
    use_str = self._get_pkgsettings()["PORTAGE_USE"]
  File "pym/_emerge/", line 639, in _get_pkgsettings
  File "pym/portage/package/ebuild/", line 1381, in wrapper
    raise AssertionError('setcpv recursion detected')
AssertionError: setcpv recursion detected
Comment 1 Brian Dolbec (RETIRED) gentoo-dev 2016-09-08 01:58:20 UTC
What if we do simple substitution for occurrences of ["[", "]"] with a space, along with the error message.

If not that, then just puke out the error and exit rather than ignore the entry. That will force it to be fixed.

In my case I accidentally forgot to edit them out when copy/pasting the entry from an emerge complaint about needing that to satisfy some other pkg.  If it was ignored, I would be incensed wondering why it keeps giving me the same use complaint after I already added it (although incorrectly) to package.use.