From c7edb4d49338563f4149a91ff524a730b0f330ce Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Mon, 12 Jan 2009 08:24:29 +0000 Subject: [PATCH] Bug #55321 - Add support for package.keywords in profiles. In profiles, package.keywords modifies effective KEYWORDS values for a given ebuild. This behavior is notably different from /etc/portage/package.keywords, which instead modifies effective ACCEPT_KEYWORDS. (trunk r12409:12412) svn path=/main/branches/2.1.6/; revision=12468 --- man/portage.5 | 21 +++++++++++++++++++++ pym/portage/__init__.py | 35 ++++++++++++++++++++++++++++++++--- 2 files changed, 53 insertions(+), 3 deletions(-) diff --git a/man/portage.5 b/man/portage.5 index 5f431b3ed..765aa08d1 100644 --- a/man/portage.5 +++ b/man/portage.5 @@ -29,6 +29,7 @@ eapi make.defaults packages packages.build +package.keywords package.mask package.provided package.unmask @@ -584,6 +585,26 @@ A list of all the packages which will be displayed when you run `emerge info`. .BR info_vars A list of all the variables which will be displayed when you run `emerge info`. .TP +.BR package.keywords +Per\-profile KEYWORDS. Useful for cases in which the effective KEYWORDS of a +given package should vary depending on which profile the user has selected. + +.I Format: +.nf +\- comment lines begin with # (no inline comments) +\- one DEPEND atom per line followed by additional KEYWORDS +.fi + +.I Example: +.nf +# add stable keyword to libgd +media\-libs/libgd x86 +# remove stable keyword from mplayer and add unstable keyword +media\-video/mplayer \-x86 ~x86 +# remove all keywords from netcat +net-analyzer/netcat -* +.fi +.TP .BR package.mask This contains a list of DEPEND atoms for packages that should not be installed in any profile. Useful for adding the latest KDE betas and making sure no diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py index 0a1d1b72e..42d89c0da 100644 --- a/pym/portage/__init__.py +++ b/pym/portage/__init__.py @@ -1132,6 +1132,7 @@ class config(object): self.pusedict = copy.deepcopy(clone.pusedict) self.categories = copy.deepcopy(clone.categories) self.pkeywordsdict = copy.deepcopy(clone.pkeywordsdict) + self._pkeywords_list = copy.deepcopy(clone._pkeywords_list) self.pmaskdict = copy.deepcopy(clone.pmaskdict) self.punmaskdict = copy.deepcopy(clone.punmaskdict) self.prevmaskdict = copy.deepcopy(clone.prevmaskdict) @@ -1261,6 +1262,16 @@ class config(object): else: self.prevmaskdict[mycatpkg].append(x) + self._pkeywords_list = [] + rawpkeywords = [grabdict_package( + os.path.join(x, "package.keywords"), recursive=1) \ + for x in self.profiles] + for i in xrange(len(self.profiles)): + cpdict = {} + for k, v in rawpkeywords[i].iteritems(): + cpdict.setdefault(dep_getkey(k), {})[k] = v + self._pkeywords_list.append(cpdict) + # get profile-masked use flags -- INCREMENTAL Child over parent self.usemask_list = [grabfile(os.path.join(x, "use.mask")) \ for x in self.profiles] @@ -2230,6 +2241,25 @@ class config(object): return x return None + def _getKeywords(self, cpv, metadata): + cp = dep_getkey(cpv) + pkg = "%s:%s" % (cpv, metadata["SLOT"]) + keywords = [metadata["KEYWORDS"].split()] + pos = len(keywords) + for i in xrange(len(self.profiles)): + cpdict = self._pkeywords_list[i].get(cp, None) + if cpdict: + keys = list(cpdict) + while keys: + best_match = best_match_to_list(pkg, keys) + if best_match: + keys.remove(best_match) + keywords.insert(pos, cpdict[best_match]) + else: + break + pos = len(keywords) + return stack_lists(keywords, incremental=True) + def _getMissingKeywords(self, cpv, metadata): """ Take a package and return a list of any KEYWORDS that the user may @@ -2251,7 +2281,7 @@ class config(object): # object (bug #139600) egroups = self.configdict["backupenv"].get( "ACCEPT_KEYWORDS", "").split() - mygroups = metadata["KEYWORDS"].split() + mygroups = self._getKeywords(cpv, metadata) # Repoman may modify this attribute as necessary. pgroups = self["ACCEPT_KEYWORDS"].split() match=0 @@ -6950,7 +6980,7 @@ def getmaskingstatus(mycpv, settings=None, portdb=None): # keywords checking eapi = metadata["EAPI"] - mygroups = metadata["KEYWORDS"] + mygroups = settings._getKeywords(mycpv, metadata) licenses = metadata["LICENSE"] slot = metadata["SLOT"] if eapi.startswith("-"): @@ -6961,7 +6991,6 @@ def getmaskingstatus(mycpv, settings=None, portdb=None): return ["EAPI %s" % eapi] egroups = settings.configdict["backupenv"].get( "ACCEPT_KEYWORDS", "").split() - mygroups = mygroups.split() pgroups = settings["ACCEPT_KEYWORDS"].split() myarch = settings["ARCH"] if pgroups and myarch not in pgroups: -- 2.26.2