Merged from trunk 7908:7913
authorFabian Groffen <grobian@gentoo.org>
Fri, 5 Oct 2007 18:43:13 +0000 (18:43 -0000)
committerFabian Groffen <grobian@gentoo.org>
Fri, 5 Oct 2007 18:43:13 +0000 (18:43 -0000)
   | 7909    | Bump EAPI from 0 to 1 and fix eapi_is_supported() so that it |
   | zmedico | works properly with both 0 and 1.                            |

   | 7910    | When the metadata cache contains a negative EAPI, it means   |
   | zmedico | that the cache entry was generated by a version of portage   |
   |         | that did not support the eapi. When the user upgrades to a   |
   |         | version that now supports the previously unsupported EAPI,   |
   |         | those cache entries need to be regenerated. Therefore, when  |
   |         | a cache entry has a negative EAPI, check if the EAPI would   |
   |         | be supported and trigger a regen if appropriate.             |

   | 7911    | Non-integer EAPI isn't supported. In case it's supported in  |
   | zmedico | the future, assume that it's valid (rather than trigger a    |
   |         | regen).                                                      |

   | 7912    | Fix UnsupportedAPIException.__str__() to strip the leading   |
   | zmedico | negative sign (-) from the EAPI, to prevent confusion.       |

   | 7913    | Add EAPI masking support for binary packages.                |
   | zmedico |                                                              |

svn path=/main/branches/prefix/; revision=7954

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

index faa5ea7587fb6442f08bdf6258f7c5a770fd300c..ad63d57622cf1f6f4303a38749847109d19ea26f 100644 (file)
@@ -1770,8 +1770,11 @@ class depgraph(object):
                                        chost = pkgsettings["CHOST"]
                                        eprefix = pkgsettings["EPREFIX"]
                                        myeb_pkg_matches = []
+                                       bindb_keys = ["CHOST","EAPI"]
                                        for pkg in bindb.match(x):
-                                               if chost != bindb.aux_get(pkg, ["CHOST"])[0]:
+                                               metadata = dict(izip(bindb_keys,
+                                                       bindb.aux_get(pkg, bindb_keys)))
+                                               if chost != metadata["CHOST"]:
                                                        continue
 
                                                pkg_eprefix = bindb.aux_get(pkg, ["EPREFIX"])[0]
@@ -1781,6 +1784,8 @@ class depgraph(object):
                                                if len(pkg_eprefix) < len(eprefix):
                                                        continue
 
+                                               if not portage.eapi_is_supported(metadata["EAPI"]):
+                                                       continue
                                                # Remove any binary package entries that are
                                                # masked in the portage tree (#55871).
                                                if not usepkgonly and \
@@ -1938,15 +1943,24 @@ class depgraph(object):
                                                        if alleb:
                                                                chost = pkgsettings["CHOST"]
                                                                eprefix = pkgsettings["EPREFIX"]
+                                                               bindb_keys = ["CHOST","EAPI","EPREFIX"]
                                                                for p in alleb:
                                                                        mreasons = []
-                                                                       pkg_chost =  bindb.aux_get(p, ["CHOST"])[0]
-                                                                       if chost != pkg_chost:
-                                                                               mreasons.append("CHOST: %s" % pkg_chost)
-                                                                       pkg_eprefix = bindb.aux_get(p, ["EPREFIX"])[0]
-                                                                       if not pkg_eprefix:
+                                                                       metadata = dict(izip(bindb_keys,
+                                                                               bindb.aux_get(pkg, bindb_keys)))
+                                                                       if chost != metadata["CHOST"]:
+                                                                               mreasons.append("CHOST: %s" % \
+                                                                                       metadata["CHOST"])
+                                                                       if not portage.eapi_is_supported(
+                                                                               metadata["EAPI"]):
+                                                                               mreasons.append(("required EAPI %s" + \
+                                                                                       ", supported EAPI %s") % \
+                                                                                       (metadata["EAPI"],
+                                                                                       portage.const.EAPI))
+                                                                       if not metadata["EPREFIX"]:
                                                                                mreasons.append("missing EPREFIX")
-                                                                       elif len(pkg_eprefix.strip()) < len(eprefix):
+                                                                       elif len(metadata["EPREFIX"].strip()) < \
+                                                                                       len(eprefix):
                                                                                mreasons.append("EPREFIX too small")
                                                                        print "- "+p+" (masked by: "+", ".join(mreasons)+")"
                                                        print "!!! "+red("There are no packages available to satisfy: ")+green(xinfo)
index 88c197a9132f4cda8f40913ad6b19abae66d6be1..8481620bc823681e203be915223c632859c13d7f 100644 (file)
@@ -3328,7 +3328,20 @@ def spawnebuild(mydo,actionmap,mysettings,debug,alwaysdep=0,logfile=None):
 
 
 def eapi_is_supported(eapi):
-       return str(eapi).strip() == str(portage.const.EAPI).strip()
+       # PREFIX HACK: in prefix we still use EAPI="prefix".  To avoid
+       # getting eapi = -1 here and an error by Python because
+       # portage.const.EAPI is a string, we revert to a string compare for
+       # now.  Once we use a number, we should remove this crude hack.
+       if portage.const.EAPI == "prefix":
+               return str(eapi).strip() == str(portage.const.EAPI).strip()
+
+       try:
+               eapi = int(str(eapi).strip())
+       except ValueError:
+               eapi = -1
+       if eapi < 0:
+               return False
+       return eapi <= portage.const.EAPI
 
 def doebuild_environment(myebuild, mydo, myroot, mysettings, debug, use_cache, mydbapi):
 
index 9fcff61cd92f57b7b0188ae8085fee87ace31fab..9e32971a097c3d9f38817bfc9ddcded21aad20d2 100644 (file)
@@ -27,7 +27,7 @@ class bindbapi(fakedbapi):
                self.settings = settings
                self._match_cache = {}
                # Selectively cache metadata in order to optimize dep matching.
-               self._aux_cache_keys = set(["CHOST","SLOT","EPREFIX"])
+               self._aux_cache_keys = set(["CHOST","EAPI","SLOT","EPREFIX"])
                self._aux_cache = {}
 
        def match(self, *pargs, **kwargs):
index dc54efe5c488614fadb7f9164a9c3677d6541969..83c568fa061969ca19d7aada6a77cb7c60ecd4e3 100644 (file)
@@ -282,7 +282,19 @@ class portdbapi(dbapi):
 
                try:
                        mydata = self.auxdb[mylocation][mycpv]
-                       if emtime != long(mydata.get("_mtime_", 0)):
+                       eapi = mydata.get("EAPI","").strip()
+                       if not eapi:
+                               eapi = 0
+                       try:
+                               eapi = int(eapi)
+                       except ValueError:
+                               # Non-integer EAPI isn't supported. In case it's supported in
+                               # the future, assume that it's valid (rather than trigger a
+                               # regen).
+                               eapi = None
+                       if eapi is not None and eapi < 0 and eapi_is_supported(-eapi):
+                               doregen = True
+                       elif emtime != long(mydata.get("_mtime_", 0)):
                                doregen = True
                        elif len(mydata.get("_eclasses_", [])) > 0:
                                doregen = not self.eclassdb.is_eclass_data_valid(mydata["_eclasses_"])
index 3d590a5638b42fa30a9b13e6a278440f6e7a8728..7802b801680090bfaf3a6c6632bbcc271f6c861b 100644 (file)
@@ -80,7 +80,11 @@ class UnsupportedAPIException(PortagePackageException):
        def __init__(self, cpv, eapi):
                self.cpv, self.eapi = cpv, eapi
        def __str__(self):
-               return "Unable to do any operations on '%s', due to the fact it's EAPI is higher then this portage versions.  Please upgrade to a portage version that supports EAPI %s" % (self.cpv, self.eapi)
+               msg = ("Unable to do any operations on '%s', since " + \
+               "it's EAPI is higher than this portage version's. Please upgrade" + \
+               " to a portage version that supports EAPI '%s'.") % \
+               (self.cpv, str(self.eapi).lstrip("-"))
+               return msg