Fix package.license support so that SLOT atoms
authorZac Medico <zmedico@gentoo.org>
Sat, 6 Oct 2007 19:19:43 +0000 (19:19 -0000)
committerZac Medico <zmedico@gentoo.org>
Sat, 6 Oct 2007 19:19:43 +0000 (19:19 -0000)
will work.

svn path=/main/trunk/; revision=7985

pym/emerge/__init__.py
pym/portage/__init__.py
pym/portage/dbapi/porttree.py

index 6f4875f3c61b0b629b57f31727b6721e20a7a581..d6410726336a4ea0c1213e8f8ab81d51726199d8 100644 (file)
@@ -1904,6 +1904,7 @@ class depgraph(object):
                                                        print "!!! One of the following masked packages is required to complete your request:"
                                                        oldcomment = ""
                                                        shown_licenses = []
+                                                       portdb_keys = ["LICENSE","SLOT"]
                                                        for p in alleb:
                                                                mreasons = portage.getmaskingstatus(p,
                                                                        settings=pkgsettings, portdb=portdb)
@@ -1918,19 +1919,20 @@ class depgraph(object):
                                                                                print comment
                                                                                oldcomment = comment
                                                                try:
-                                                                       licenses = portdb.aux_get(p, ["LICENSE"])[0]
+                                                                       metadata = dict(izip(portdb_keys,
+                                                                               portdb.aux_get(p, portdb_keys)))
                                                                except KeyError:
                                                                        # Corruption will have been reported above.
                                                                        continue
-                                                               uselist = []
-                                                               if "?" in licenses:
+                                                               metadata["USE"] = ""
+                                                               if "?" in metadata["LICENSE"]:
                                                                        pkgsettings.setcpv(p, mydb=portdb)
-                                                                       uselist = pkgsettings.get("USE", "").split()
+                                                                       metadata["USE"] = pkgsettings.get("USE", "")
                                                                missing_licenses = []
                                                                try:
                                                                        missing_licenses = \
                                                                                pkgsettings.getMissingLicenses(
-                                                                                       licenses, p, uselist)
+                                                                                       p, metadata)
                                                                except portage.exception.InvalidDependString:
                                                                        # This will have already been reported
                                                                        # above via mreasons.
index 505848f7ff13ae69ef3a1946e22450925ce33427..760819f41fe27c11bb6adca7b4626f72a049a7fa 100644 (file)
@@ -1834,19 +1834,17 @@ class config(object):
                if has_changed:
                        self.reset(keeping_pkg=1,use_cache=use_cache)
 
-       def getMissingLicenses(self, licenses, cpv, uselist):
+       def getMissingLicenses(self, cpv, metadata):
                """
                Take a LICENSE string and return a list any licenses that the user may
                may need to accept for the given package.  The returned list will not
                contain any licenses that have already been accepted.  This method
                can throw an InvalidDependString exception.
 
-               @param licenses: A raw LICENSE string as returned form dbapi.aux_get()
-               @type licenses: String
                @param cpv: The package name (for package.license support)
                @type cpv: String
-               @param uselist: A list of flags for evaluation of USE conditionals
-               @type uselist: List
+               @param metadata: A dictionary of raw package metadata
+               @type metadata: dict
                @rtype: List
                @return: A list of licenses that have not been accepted.
                """
@@ -1856,11 +1854,12 @@ class config(object):
                cpdict = self._plicensedict.get(dep_getkey(cpv), None)
                if cpdict:
                        acceptable_licenses = self._accept_license.copy()
-                       for atom in match_to_list(cpv, cpdict.keys()):
+                       cpv_slot = "%s:%s" % (cpv, metadata["SLOT"])
+                       for atom in match_to_list(cpv_slot, cpdict.keys()):
                                acceptable_licenses.update(cpdict[atom])
-               license_struct = portage.dep.paren_reduce(licenses)
+               license_struct = portage.dep.paren_reduce(metadata["LICENSE"])
                license_struct = portage.dep.use_reduce(
-                       license_struct, uselist=uselist)
+                       license_struct, uselist=metadata["USE"].split())
                license_struct = portage.dep.dep_opconvert(license_struct)
                return self._getMissingLicenses(license_struct, acceptable_licenses)
 
@@ -5013,8 +5012,8 @@ def getmaskingstatus(mycpv, settings=None, portdb=None):
 
        # keywords checking
        try:
-               mygroups, licenses, eapi = portdb.aux_get(
-                       mycpv, ["KEYWORDS", "LICENSE", "EAPI"])
+               eapi, mygroups, licenses, slot = portdb.aux_get(
+                       mycpv, ["EAPI", "KEYWORDS", "LICENSE", "SLOT"])
        except KeyError:
                # The "depend" phase apparently failed for some reason.  An associated
                # error message will have already been printed to stderr.
@@ -5074,13 +5073,13 @@ def getmaskingstatus(mycpv, settings=None, portdb=None):
        if kmask:
                rValue.append(kmask+" keyword")
 
-       uselist = []
+       use = ""
        if "?" in licenses:
                settings.setcpv(mycpv, mydb=portdb)
-               uselist = settings.get("USE", "").split()
+               use = settings.get("USE", "")
        try:
                missing_licenses = settings.getMissingLicenses(
-                       licenses, mycpv, uselist)
+                       mycpv, {"LICENSE":licenses, "SLOT":slot, "USE":use})
                if missing_licenses:
                        allowed_tokens = set(["||", "(", ")"])
                        allowed_tokens.update(missing_licenses)
index 03550033ab2d09b198c3439e7db76568c5920d34..3990a827e986bff5ff50cd3c8e5ce80ed999c057 100644 (file)
@@ -728,13 +728,13 @@ class portdbapi(dbapi):
                                        hasstable = True
                        if not match and ((hastesting and "~*" in pgroups) or (hasstable and "*" in pgroups) or "**" in pgroups):
                                match=1
-                       uselist = []
+                       use = ""
                        if "?" in licenses:
                                self.doebuild_settings.setcpv(mycpv, mydb=self)
-                               uselist = self.doebuild_settings.get("USE", "").split()
+                               use = self.doebuild_settings.get("USE", "")
                        try:
-                               if self.mysettings.getMissingLicenses(
-                                       licenses, mycpv, uselist):
+                               if self.mysettings.getMissingLicenses(mycpv,
+                                       {"LICENSE":licenses, "SLOT":slot, "USE":use}):
                                        match = 0
                        except InvalidDependString:
                                match = 0