Bug #292083 - Support package.accept_keywords in profiles.
authorZac Medico <zmedico@gentoo.org>
Sat, 21 Aug 2010 21:19:54 +0000 (14:19 -0700)
committerZac Medico <zmedico@gentoo.org>
Sat, 21 Aug 2010 21:19:54 +0000 (14:19 -0700)
man/portage.5
pym/portage/package/ebuild/config.py

index 7edeb171e3919d7d89c474e8467d3dfacad50dae..f3317da5345c55d621863184dde7dbc61e024771 100644 (file)
@@ -28,6 +28,7 @@ eapi
 make.defaults
 packages
 packages.build
+package.accept_keywords
 package.keywords
 package.mask
 package.provided
@@ -765,6 +766,12 @@ FSF-APPROVED @GPL-COMPATIBLE Apache-1.1 BSD-4 MPL-1.0 MPL-1.1
 GPL-COMPATIBLE Apache-2.0 BSD BSD-2 GPL-2 GPL-3 LGPL-2.1 LGPL-3 X11 ZLIB
 .fi
 .TP
+.BR package.accept_keywords
+Per\-package ACCEPT_KEYWORDS for profiles. This has the same format and
+behavior as /etc/portage/package.accept_keywords, including the ability
+to list atoms without any keywords in order to accept unstable variants
+of all stable keywords listed in ACCEPT_KEYWORDS.
+.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.
index 7a1f640b6f0ae24e2d81d01ddc46b3b84ba30506..6e20b1cb7961864bf9c429d0293a6137f1119d89 100644 (file)
@@ -544,6 +544,7 @@ class config(object):
                        self.pusedict   = copy.deepcopy(clone.pusedict)
                        self.pkeywordsdict = copy.deepcopy(clone.pkeywordsdict)
                        self._pkeywords_list = copy.deepcopy(clone._pkeywords_list)
+                       self._p_accept_keywords = copy.deepcopy(clone._p_accept_keywords)
                        self.pmaskdict = copy.deepcopy(clone.pmaskdict)
                        self.punmaskdict = copy.deepcopy(clone.punmaskdict)
                        self.prevmaskdict = copy.deepcopy(clone.prevmaskdict)
@@ -711,6 +712,19 @@ class config(object):
                                        cpdict.setdefault(k.cp, {})[k] = v
                                self._pkeywords_list.append(cpdict)
 
+                       self._p_accept_keywords = []
+                       raw_p_accept_keywords = [grabdict_package(
+                               os.path.join(x, "package.accept_keywords"), recursive=1) \
+                               for x in self.profiles]
+                       for d in raw_p_accept_keywords:
+                               if not d:
+                                       # Omit non-existent files from the stack.
+                                       continue
+                               cpdict = {}
+                               for k, v in d.items():
+                                       cpdict.setdefault(k.cp, {})[k] = tuple(v)
+                               self._p_accept_keywords.append(cpdict)
+
                        # get profile-masked use flags -- INCREMENTAL Child over parent
                        self.usemask_list = tuple(
                                tuple(grabfile(os.path.join(x, "use.mask"), recursive=1))
@@ -2056,10 +2070,26 @@ class config(object):
                mygroups = self._getKeywords(cpv, metadata)
                # Repoman may modify this attribute as necessary.
                pgroups = self["ACCEPT_KEYWORDS"].split()
-               match=0
+               matches = False
                cp = cpv_getkey(cpv)
+
+               if self._p_accept_keywords:
+                       cpv_slot = "%s:%s" % (cpv, metadata["SLOT"])
+                       accept_keywords_defaults = tuple('~' + keyword for keyword in \
+                               pgroups if keyword[:1] not in "~-")
+                       for d in self._p_accept_keywords:
+                               cpdict = d.get(cp)
+                               if cpdict:
+                                       pkg_accept_keywords = \
+                                               _ordered_by_atom_specificity(cpdict, cpv_slot)
+                                       if pkg_accept_keywords:
+                                               for x in pkg_accept_keywords:
+                                                       if not x:
+                                                               x = accept_keywords_defaults
+                                                       pgroups.extend(x)
+                                               matches = True
+
                pkgdict = self.pkeywordsdict.get(cp)
-               matches = False
                if pkgdict:
                        cpv_slot = "%s:%s" % (cpv, metadata["SLOT"])
                        pkg_accept_keywords = \
@@ -2082,6 +2112,8 @@ class config(object):
                                        inc_pgroups.add(x)
                        pgroups = inc_pgroups
                        del inc_pgroups
+
+               match = False
                hasstable = False
                hastesting = False
                for gp in mygroups: