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 v2] Simplification of check_sets ref Alexander Berntsen's feedback man/color.map.5 | 11 ++++++++++ pym/_emerge/resolver/output.py | 28 +++++++++++++++++------- pym/_emerge/resolver/output_helpers.py | 8 ++++--- pym/portage/_sets/base.py | 3 +++ pym/portage/_sets/files.py | 3 +++ pym/portage/output.py | 39 ++++++++++++++++++---------------- 6 files changed, 63 insertions(+), 29 deletions(-) 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/pym/_emerge/resolver/output.py b/pym/_emerge/resolver/output.py index 400617d..36e4020 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,22 +705,28 @@ 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 the 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: system = system_set.findAtomForPackage( pkg, modified_use=self.conf.pkg_use_enabled(pkg)) world = world_set.findAtomForPackage( pkg, modified_use=self.conf.pkg_use_enabled(pkg)) + for set_name in root_config.sets: + if root_config.sets[set_name].isUserSet(): + user_set = root_config.sets[set_name].findAtomForPackage( + pkg, modified_use=self.conf.pkg_use_enabled(pkg)) + if user_set: break if not (self.conf.oneshot or world) and \ pkg.root == self.conf.target_root and \ self.conf.favorites.findAtomForPackage( @@ -726,7 +738,7 @@ class Display(object): except InvalidDependString: # This is reported elsewhere if relevant. pass - return system, world + return user_set, system, world @staticmethod @@ -863,8 +875,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..801774f 100644 --- a/pym/_emerge/resolver/output_helpers.py +++ b/pym/_emerge/resolver/output_helpers.py @@ -596,7 +596,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 +613,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/base.py b/pym/portage/_sets/base.py index ee20d36..a73fb93 100644 --- a/pym/portage/_sets/base.py +++ b/pym/portage/_sets/base.py @@ -173,6 +173,9 @@ class PackageSet(object): cpv_slot_list): yield atom + def isUserSet(self): + return False + class EditablePackageSet(PackageSet): def __init__(self, allow_wildcard=False, allow_repo=False): diff --git a/pym/portage/_sets/files.py b/pym/portage/_sets/files.py index e045701..7f844ef 100644 --- a/pym/portage/_sets/files.py +++ b/pym/portage/_sets/files.py @@ -174,6 +174,9 @@ class StaticFileSet(EditablePackageSet): greedy=greedy, dbapi=trees["vartree"].dbapi) return rValue multiBuilder = classmethod(multiBuilder) + + def isUserSet(self): + return True class ConfigFileSet(PackageSet): def __init__(self, filename): 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