From a9881a28da795ce2285187062bfaa822d4e55a18 Mon Sep 17 00:00:00 2001 From: Brian Dolbec Date: Thu, 7 Jun 2012 00:57:44 -0700 Subject: [PATCH] fix a bug in enalyze rebuild where it did not consider IUSE defaults for calculating the use flag differences. Discovered by mingdao in #gentoo. --- pym/gentoolkit/enalyze/lib.py | 23 +++++++++++++++-------- pym/gentoolkit/flag.py | 16 ++++++++++++++++ 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/pym/gentoolkit/enalyze/lib.py b/pym/gentoolkit/enalyze/lib.py index 015e23b..9dc28a3 100644 --- a/pym/gentoolkit/enalyze/lib.py +++ b/pym/gentoolkit/enalyze/lib.py @@ -14,7 +14,7 @@ from gentoolkit.dbapi import PORTDB, VARDB from gentoolkit import errors from gentoolkit.keyword import reduce_keywords from gentoolkit.flag import (reduce_flags, get_flags, get_all_cpv_use, - filter_flags, get_installed_use, get_iuse) + filter_flags, get_installed_use, get_iuse, defaulted_flags) #from gentoolkit.package import Package import portage @@ -65,10 +65,12 @@ class FlagAnalyzer(object): @return (plus, minus, unset) sets of USE flags """ installed = set(self.get_used(cpv, self.target)) - iuse = set(reduce_flags(self.get_flags(cpv))) - return self._analyse(installed, iuse) + _iuse = self.get_flags(cpv) + iuse = set(reduce_flags(_iuse)) + iuse_defaults = defaulted_flags(_iuse) + return self._analyse(installed, iuse, iuse_defaults) - def _analyse(self, installed, iuse): + def _analyse(self, installed, iuse, iuse_defaults): """Analyzes the supplied info and returns the flag settings that differ from the defaults @@ -78,6 +80,9 @@ class FlagAnalyzer(object): @param iuse: the current ebuilds IUSE """ defaults = self.system.intersection(iuse) + # update defaults with iuse_defaults + defaults.update(iuse_defaults['+']) + defaults = defaults.difference(iuse_defaults['-']) usedflags = iuse.intersection(set(installed)) if self.filter_defaults: plus = usedflags.difference(defaults) @@ -98,10 +103,12 @@ class FlagAnalyzer(object): @return (plus, minus, unset) sets of USE flags """ installed = set(self.pkg_used(pkg)) - print("installed =", installed) - iuse = set(reduce_flags(self.pkg_flags(pkg))) - print("iuse =", iuse) - return self._analyse(installed, iuse) + #print("installed =", installed) + _iuse = self.pkg_flags(pkg) + iuse = set(reduce_flags(_iuse)) + iuse_defaults = defaulted_flags(_iuse) + #print("iuse =", iuse) + return self._analyse(installed, iuse, iuse_defaults) def pkg_used(self, pkg): if self.target == "USE": diff --git a/pym/gentoolkit/flag.py b/pym/gentoolkit/flag.py index b5c8228..0377a81 100644 --- a/pym/gentoolkit/flag.py +++ b/pym/gentoolkit/flag.py @@ -13,6 +13,7 @@ __all__ = ( 'get_installed_use', 'reduce_flag', 'reduce_flags', + 'defaulted_flags', 'filter_flags', 'get_all_cpv_use', 'get_flags' @@ -84,6 +85,21 @@ def reduce_flags(the_list): return r +def defaulted_flags(the_list): + """Absolute value function for a USE flag list + + @type the_list: list + @param the_list: the use flags to get defaulted ones from. + @rtype: dict of lists + @return defaulted USE flags {'+': [...], '-': [...]} + """ + r={"+":[], "-": []} + for member in the_list: + if member[0] in ["+","-"]: + r[member[0]].append(member[1:]) + return r + + def filter_flags(use, use_expand_hidden, usemasked, useforced): """Filter function to remove hidden or otherwise not normally visible USE flags from a list. -- 2.26.2