Try a more Python-like approach to getting what we need from EAPI, as
authorFabian Groffen <grobian@gentoo.org>
Wed, 7 Nov 2007 22:21:29 +0000 (22:21 -0000)
committerFabian Groffen <grobian@gentoo.org>
Wed, 7 Nov 2007 22:21:29 +0000 (22:21 -0000)
suggested by zmedico.

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

configure.in
pym/portage/__init__.py

index 7162caad34232ef3a6b168f4801832eb6e4b8e52..b1a19633fbb8023d9d2260e49b69d28103a7532c 100644 (file)
@@ -218,7 +218,7 @@ AC_HELP_STRING([--with-offset-prefix],
 if test "x$DOMAIN_PREFIX" = "x"
 then
        PORTAGE_EPREFIX='""'
-       EAPIPREFIX=''
+       EAPIPREFIX='None'
 else
        PORTAGE_EPREFIX='path.normpath("'"$DOMAIN_PREFIX"'")'
        EAPIPREFIX='"prefix"'
index 9a7638a11e26df01f8af31afa33001d115577f4e..8aa264e8e0c2173ff0b6e6986a47ef2b78b92f83 100644 (file)
@@ -3573,6 +3573,9 @@ def spawnebuild(mydo,actionmap,mysettings,debug,alwaysdep=0,logfile=None):
        return phase_retval
 
 
+_eapi_prefix_re = re.compile("(^|\s*)%s($|\s*)" % portage.const.EAPIPREFIX)
+_eapi_num_re    = re.compile("(^|\s*)[0-9]+($|\s*)")
+
 def eapi_is_supported(eapi):
        # PREFIX HACK/EXTENSION: in prefix we have "incompatible" ebuilds in
        # an consistent manner; regardless what the EAPI of the main tree
@@ -3586,23 +3589,21 @@ def eapi_is_supported(eapi):
        # unset EAPI would make main tree EAPI 0, and 'EAPI="prefix"' would
        # mean main tree EAPI 0, prefix tree EAPI 0.
        # However, back to reality, we just look for all <desc> we require,
-       # which because fixed to be at max 1 allows to do some optimisations
        # and don't do version tricks other than the main tree does.
 
-       # what we implement here, better be fast, so match what we want
-       # against what we have
-       o = 0
        eapi = str(eapi)
        if portage.const.EAPIPREFIX:
-               o = eapi.find(portage.const.EAPIPREFIX)
-               if o == -1:
+               if not _eapi_prefix_re.search(eapi):
                        return False
-               o += len(portage.const.EAPIPREFIX)
 
-       try:
-               eapi = int(eapi[o:].strip())
-       except ValueError:
-               eapi = -1
+       m = _eapi_num_re.search(eapi)
+       if not m:
+               eapi = 0
+       else:
+               try:
+                       eapi = int(m.string[m.start():m.end()].strip())
+               except ValueError:
+                       eapi = -1
        if eapi < 0:
                return False
        return eapi <= portage.const.EAPI