Three new settings were added to /etc/portage/color.map: PKG_MERGE_USER_SET, PKG_BINARY_MERGE_USER_SET, and PKG_NOMERGE_USER_SET. These colors are applied when the package is selected from a set in /etc/portage/sets/
X-Gentoo-bug: 577720 X-Gentoo-bug-url: https://bugs.gentoo.org/show_bug.cgi?id=577720 --- [PATCH v5] Final touches. Almost there! [PATCH v4] Created one InternalPackageSet for each root [PATCH v3] Updates based on feedback from IRC meeting [PATCH v2] Simplification of check_sets ref Alexander Berntsen's feedback_ cnf/sets/portage.conf | 1 + doc/config/sets.docbook | 4 +++- man/color.map.5 | 11 ++++++++++ man/portage.5 | 1 + pym/_emerge/resolver/output.py | 25 +++++++++++++++------- pym/_emerge/resolver/output_helpers.py | 17 ++++++++++++--- pym/portage/_sets/__init__.py | 8 +++++++ pym/portage/_sets/base.py | 1 + pym/portage/output.py | 39 ++++++++++++++++++---------------- 9 files changed, 77 insertions(+), 30 deletions(-) diff --git a/cnf/sets/portage.conf b/cnf/sets/portage.conf index ac282d9..e990620 100644 --- a/cnf/sets/portage.conf +++ b/cnf/sets/portage.conf @@ -49,6 +49,7 @@ class = portage.sets.files.StaticFileSet multiset = true directory = %(PORTAGE_CONFIGROOT)setc/portage/sets world-candidate = True +user-set = True # Set to rebuild all packages that need a preserved lib that only remains due # to FEATURES=preserve-libs diff --git a/doc/config/sets.docbook b/doc/config/sets.docbook index 749b775..02135d6 100644 --- a/doc/config/sets.docbook +++ b/doc/config/sets.docbook @@ -57,6 +57,8 @@ is missing)</para></listitem> <listitem><para><varname>world-candidate</varname>, which determines if given package should be added to the <varname>world</varname> set</para></listitem> + <listitem><para><varname>user-set</varname>, which determines if + given package should be colorized as a user set</para></listitem> </itemizedlist> <para> Some handler classes might require additional options for their configuration, @@ -93,7 +95,7 @@ but to indicate that the section should generate multiple sets it's also necessary to set the <varname>multiset</varname> option to <parameter>true</parameter>. The <varname>world-candidate</varname> - option also supported like with + and <varname>user-set</varname> options are also supported like with single sets (they'll apply to all sets generated by the section). </para> <para> diff --git a/man/color.map.5 b/man/color.map.5 index 5543628..39f23f7 100644 --- a/man/color.map.5 +++ b/man/color.map.5 @@ -46,6 +46,9 @@ Defines color used for satisfied blockers. \fBPKG_MERGE\fR = \fI"darkgreen"\fR Defines color used for packages planned to be merged. .TP +\fBPKG_MERGE_USER_SET\fR = \fI"darkgreen"\fR +Defines color used for packages planned to be merged from a user defined set. +.TP \fBPKG_MERGE_SYSTEM\fR = \fI"darkgreen"\fR Defines color used for system packages planned to be merged. .TP @@ -55,6 +58,10 @@ Defines color used for world packages planned to be merged. \fBPKG_BINARY_MERGE\fR = \fI"purple"\fR Defines color used for packages planned to be merged using a binary package. .TP +\fBPKG_BINARY_MERGE_USER_SET\fR = \fI"purple"\fR +Defines color used for packages planned to be merged using a binary package +from a user defined set. +.TP \fBPKG_BINARY_MERGE_SYSTEM\fR = \fI"purple"\fR Defines color used for system packages planned to be merged using a binary package. @@ -66,6 +73,10 @@ package. \fBPKG_NOMERGE\fR = \fI"darkblue"\fR Defines color used for packages not planned to be merged. .TP +\fBPKG_NOMERGE_USER_SET\fR = \fI"darkblue"\fR +Defines color used for packages not planned to be merged from a user defined +set. +.TP \fBPKG_NOMERGE_SYSTEM\fR = \fI"darkblue"\fR Defines color used for system packages not planned to be merged. .TP diff --git a/man/portage.5 b/man/portage.5 index 7c2a8f7..3cc1f07 100644 --- a/man/portage.5 +++ b/man/portage.5 @@ -1114,6 +1114,7 @@ class = portage.sets.files.StaticFileSet multiset = true directory = %(PORTAGE_CONFIGROOT)setc/portage/sets world-candidate = True +user-set = True [module-rebuild] class = portage.sets.dbapi.OwnerSet diff --git a/pym/_emerge/resolver/output.py b/pym/_emerge/resolver/output.py index 400617d..7c70a3e 100644 --- a/pym/_emerge/resolver/output.py +++ b/pym/_emerge/resolver/output.py @@ -271,6 +271,8 @@ class Display(object): return colorize("PKG_BINARY_MERGE_SYSTEM", pkg_str) elif pkg_info.world: return colorize("PKG_BINARY_MERGE_WORLD", pkg_str) + elif pkg_info.user_set: + return colorize("PKG_BINARY_MERGE_USER_SET", pkg_str) else: return colorize("PKG_BINARY_MERGE", pkg_str) else: @@ -278,6 +280,8 @@ class Display(object): return colorize("PKG_MERGE_SYSTEM", pkg_str) elif pkg_info.world: return colorize("PKG_MERGE_WORLD", pkg_str) + elif pkg_info.user_set: + return colorize("PKG_MERGE_USER_SET", pkg_str) else: return colorize("PKG_MERGE", pkg_str) elif pkg_info.operation == "uninstall": @@ -287,6 +291,8 @@ class Display(object): return colorize("PKG_NOMERGE_SYSTEM", pkg_str) elif pkg_info.world: return colorize("PKG_NOMERGE_WORLD", pkg_str) + elif pkg_info.user_set: + return colorize("PKG_NOMERGE_USER_SET", pkg_str) else: return colorize("PKG_NOMERGE", pkg_str) @@ -699,18 +705,21 @@ class Display(object): return - def check_system_world(self, pkg): - """Checks for any occurances of the package in the system or world sets + def check_sets(self, pkg): + """Checks for any occurances of the package in portage sets @param pkg: _emerge.Package.Package instance - @rtype system and world booleans + @rtype user_set, system, and world booleans """ root_config = self.conf.roots[pkg.root] system_set = root_config.sets["system"] world_set = root_config.sets["selected"] - system = False - world = False + user_set = None + system = None + world = None try: + user_set = self.conf.user_sets[pkg.root].findAtomForPackage( + pkg, modified_use=self.conf.pkg_use_enabled(pkg)) system = system_set.findAtomForPackage( pkg, modified_use=self.conf.pkg_use_enabled(pkg)) world = world_set.findAtomForPackage( @@ -726,7 +735,7 @@ class Display(object): except InvalidDependString: # This is reported elsewhere if relevant. pass - return system, world + return user_set, system, world @staticmethod @@ -863,8 +872,8 @@ class Display(object): self.oldlp = self.conf.columnwidth - 30 self.newlp = self.oldlp - 30 pkg_info.oldbest = self.convert_myoldbest(pkg, pkg_info) - pkg_info.system, pkg_info.world = \ - self.check_system_world(pkg) + pkg_info.user_set, pkg_info.system, pkg_info.world = \ + self.check_sets(pkg) if 'interactive' in pkg.properties and \ pkg.operation == 'merge': pkg_info.attr_display.interactive = True diff --git a/pym/_emerge/resolver/output_helpers.py b/pym/_emerge/resolver/output_helpers.py index 70f7bc0..f3b2abc 100644 --- a/pym/_emerge/resolver/output_helpers.py +++ b/pym/_emerge/resolver/output_helpers.py @@ -13,6 +13,7 @@ __all__ = ( import io import re import sys +from itertools import chain from portage import os from portage import _encodings, _unicode_encode @@ -213,6 +214,14 @@ class _DisplayConfig(object): self.running_root = frozen_config._running_root self.roots = frozen_config.roots + # Create a single merged user set for each root + self.user_sets = {} + for root_name, root in self.roots.items(): + self.user_sets[root_name] = InternalPackageSet(initial_atoms= \ + chain.from_iterable(pkgset.getAtoms() \ + for pkgset in root.sets.values() \ + if pkgset.user_set)) + self.blocker_parents = dynamic_config._blocker_parents self.reinstall_nodes = dynamic_config._reinstall_nodes self.digraph = dynamic_config.digraph @@ -596,7 +605,8 @@ class PkgInfo(object): __slots__ = ("attr_display", "built", "cp", "ebuild_path", "fetch_symbol", "merge", "oldbest", "oldbest_list", "operation", "ordered", "previous_pkg", - "repo_name", "repo_path_real", "slot", "sub_slot", "system", "use", "ver", "world") + "repo_name", "repo_path_real", "user_set", "slot", "sub_slot", + "system", "use", "ver", "world") def __init__(self): @@ -612,12 +622,13 @@ class PkgInfo(object): self.previous_pkg = None self.repo_path_real = '' self.repo_name = '' + self.user_set = None self.slot = '' self.sub_slot = '' - self.system = False + self.system = None self.use = '' self.ver = '' - self.world = False + self.world = None self.attr_display = PkgAttrDisplay() class PkgAttrDisplay(SlotObject): diff --git a/pym/portage/_sets/__init__.py b/pym/portage/_sets/__init__.py index 91f9dd1..3203521 100644 --- a/pym/portage/_sets/__init__.py +++ b/pym/portage/_sets/__init__.py @@ -148,6 +148,7 @@ class SetConfig(object): parser.set("usersets", "multiset", "true") parser.set("usersets", "directory", "%(PORTAGE_CONFIGROOT)setc/portage/sets") parser.set("usersets", "world-candidate", "true") + parser.set("usersets", "user-set", "true") parser.remove_section("live-rebuild") parser.add_section("live-rebuild") @@ -176,6 +177,7 @@ class SetConfig(object): if not setname in self.psets: options["name"] = setname options["world-candidate"] = "False" + options["user-set"] = "False" # for the unlikely case that there is already a section with the requested setname import random @@ -244,6 +246,9 @@ class SetConfig(object): if parser.has_option(sname, "world-candidate") and \ parser.getboolean(sname, "world-candidate"): newsets[x].world_candidate = True + if parser.has_option(sname, "user-set") and \ + parser.getboolean(sname, "user-set"): + newsets[x].user_set = True self.psets.update(newsets) else: self.errors.append(_("Section '%(section)s' is configured as multiset, but '%(class)s' " @@ -263,6 +268,9 @@ class SetConfig(object): if parser.has_option(sname, "world-candidate") and \ parser.getboolean(sname, "world-candidate"): self.psets[setname].world_candidate = True + if parser.has_option(sname, "user-set") and \ + parser.getboolean(sname, "user-set"): + self.psets[setname].user_set = True except SetConfigError as e: self.errors.append(_("Configuration error in section '%s': %s") % (sname, str(e))) continue diff --git a/pym/portage/_sets/base.py b/pym/portage/_sets/base.py index ee20d36..7be9aab 100644 --- a/pym/portage/_sets/base.py +++ b/pym/portage/_sets/base.py @@ -28,6 +28,7 @@ class PackageSet(object): self.errors = [] self._nonatoms = set() self.world_candidate = False + self.user_set = False self._allow_wildcard = allow_wildcard self._allow_repo = allow_repo diff --git a/pym/portage/output.py b/pym/portage/output.py index bb7542b..80c67e8 100644 --- a/pym/portage/output.py +++ b/pym/portage/output.py @@ -128,24 +128,27 @@ _styles["HILITE"] = ( "teal", ) _styles["BRACKET"] = ( "blue", ) # Portage functions -_styles["INFORM"] = ( "darkgreen", ) -_styles["UNMERGE_WARN"] = ( "red", ) -_styles["SECURITY_WARN"] = ( "red", ) -_styles["MERGE_LIST_PROGRESS"] = ( "yellow", ) -_styles["PKG_BLOCKER"] = ( "red", ) -_styles["PKG_BLOCKER_SATISFIED"] = ( "darkblue", ) -_styles["PKG_MERGE"] = ( "darkgreen", ) -_styles["PKG_MERGE_SYSTEM"] = ( "darkgreen", ) -_styles["PKG_MERGE_WORLD"] = ( "green", ) -_styles["PKG_BINARY_MERGE"] = ( "purple", ) -_styles["PKG_BINARY_MERGE_SYSTEM"] = ( "purple", ) -_styles["PKG_BINARY_MERGE_WORLD"] = ( "fuchsia", ) -_styles["PKG_UNINSTALL"] = ( "red", ) -_styles["PKG_NOMERGE"] = ( "darkblue", ) -_styles["PKG_NOMERGE_SYSTEM"] = ( "darkblue", ) -_styles["PKG_NOMERGE_WORLD"] = ( "blue", ) -_styles["PROMPT_CHOICE_DEFAULT"] = ( "green", ) -_styles["PROMPT_CHOICE_OTHER"] = ( "red", ) +_styles["INFORM"] = ( "darkgreen", ) +_styles["UNMERGE_WARN"] = ( "red", ) +_styles["SECURITY_WARN"] = ( "red", ) +_styles["MERGE_LIST_PROGRESS"] = ( "yellow", ) +_styles["PKG_BLOCKER"] = ( "red", ) +_styles["PKG_BLOCKER_SATISFIED"] = ( "darkblue", ) +_styles["PKG_MERGE"] = ( "darkgreen", ) +_styles["PKG_MERGE_USER_SET"] = ( "darkgreen", ) +_styles["PKG_MERGE_SYSTEM"] = ( "darkgreen", ) +_styles["PKG_MERGE_WORLD"] = ( "green", ) +_styles["PKG_BINARY_MERGE"] = ( "purple", ) +_styles["PKG_BINARY_MERGE_USER_SET"] = ( "purple", ) +_styles["PKG_BINARY_MERGE_SYSTEM"] = ( "purple", ) +_styles["PKG_BINARY_MERGE_WORLD"] = ( "fuchsia", ) +_styles["PKG_UNINSTALL"] = ( "red", ) +_styles["PKG_NOMERGE"] = ( "darkblue", ) +_styles["PKG_NOMERGE_USER_SET"] = ( "darkblue", ) +_styles["PKG_NOMERGE_SYSTEM"] = ( "darkblue", ) +_styles["PKG_NOMERGE_WORLD"] = ( "blue", ) +_styles["PROMPT_CHOICE_DEFAULT"] = ( "green", ) +_styles["PROMPT_CHOICE_OTHER"] = ( "red", ) def _parse_color_map(config_root='/', onerror=None): """ -- 2.7.3