From 27608fb9a832c1f539b2ba9f6bfb4fa29d4741e6 Mon Sep 17 00:00:00 2001 From: Fabian Groffen Date: Wed, 7 Nov 2007 22:21:29 +0000 Subject: [PATCH] Try a more Python-like approach to getting what we need from EAPI, as suggested by zmedico. svn path=/main/branches/prefix/; revision=8456 --- configure.in | 2 +- pym/portage/__init__.py | 23 ++++++++++++----------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/configure.in b/configure.in index 7162caad3..b1a19633f 100644 --- a/configure.in +++ b/configure.in @@ -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"' diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py index 9a7638a11..8aa264e8e 100644 --- a/pym/portage/__init__.py +++ b/pym/portage/__init__.py @@ -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 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 -- 2.26.2