Add support for FEATURES=parse-eapi-glep-55. This feature is only intended for
authorZac Medico <zmedico@gentoo.org>
Tue, 24 Mar 2009 02:48:27 +0000 (02:48 -0000)
committerZac Medico <zmedico@gentoo.org>
Tue, 24 Mar 2009 02:48:27 +0000 (02:48 -0000)
experimental purposes and should not be enabled under normal circumstances.

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

bin/ebuild
man/make.conf.5
pym/_emerge/__init__.py
pym/portage/__init__.py
pym/portage/dbapi/porttree.py
pym/portage/manifest.py

index 55736dd3a63630e2b888ec5c2f56abdf04396311..8e1d4432fccbf7aef58f160a41385caac5c21d29 100755 (executable)
@@ -83,7 +83,14 @@ if portage.settings["NOCOLOR"] in ("yes","true") or not sys.stdout.isatty():
 
 ebuild = pargs.pop(0)
 
-if not ebuild.endswith(".ebuild"):
+pf = None
+if 'parse-eapi-glep-55' in portage.settings.features:
+       pf, eapi = portage._split_ebuild_name_glep55(
+               os.path.basename(ebuild))
+elif ebuild.endswith(".ebuild"):
+       pf = os.path.basename(ebuild)[:-7]
+
+if pf is None:
        portage.writemsg("'%s' does not end with '.ebuild'.\n" % \
                (ebuild,), noiselevel=-1)
        sys.exit(1)
@@ -120,8 +127,7 @@ if not os.path.exists(ebuild):
        sys.exit(1)
 
 ebuild_split = ebuild.split("/")
-del ebuild_split[-2]
-cpv = "/".join(ebuild_split[-2:])[:-7]
+cpv = "%s/%s" % (ebuild_split[-3], pf)
 
 if not portage.catpkgsplit(cpv):
        print "!!! %s does not follow correct package syntax." % (cpv)
@@ -158,8 +164,6 @@ def discard_digests(myebuild, mysettings, mydbapi):
                portage._doebuild_manifest_exempt_depend += 1
                pkgdir = os.path.dirname(myebuild)
                fetchlist_dict = portage.FetchlistDict(pkgdir, mysettings, mydbapi)
-               cat, pkg = pkgdir.split(os.sep)[-2:]
-               cpv = cat + "/" + os.path.basename(myebuild)[:-7]
                from portage.manifest import Manifest
                mf = Manifest(pkgdir, mysettings["DISTDIR"],
                        fetchlist_dict=fetchlist_dict, manifest1_compat=False)
index 268fd4c815a082c50320d7f6c9512c8e9881c174..92189fe7f59feb9cdc9ce6535bfa18c546282e71 100644 (file)
@@ -274,6 +274,11 @@ Parse \fBEAPI\fR from the head of the ebuild (first 30 lines). This feature
 is only intended for experimental purposes and should not be enabled under
 normal circumstances.
 .TP
+.B parse\-eapi\-glep\-55
+Parse \fBEAPI\fR from the file extension of the ebuild. This feature
+is only intended for experimental purposes and should not be enabled under
+normal circumstances.
+.TP
 .B preserve\-libs
 Preserve libraries when the sonames change during upgrade or downgrade.
 Libraries are preserved only if consumers of those libraries are detected.
index 4a673e19d51b7d571776778e624f6b69f1406b4a..f951a8a571475351fe730f0b536ed16c4b7f84bb 100644 (file)
@@ -3037,9 +3037,16 @@ class EbuildMetadataPhase(SubProcess):
                settings.setcpv(self.cpv)
                ebuild_path = self.ebuild_path
 
-               if 'parse-eapi-ebuild-head' in settings.features:
+               eapi = None
+               if 'parse-eapi-glep-55' in settings.features:
+                       pf, eapi = portage._split_ebuild_name_glep55(
+                               os.path.basename(ebuild_path))
+               if eapi is None and \
+                       'parse-eapi-ebuild-head' in settings.features:
                        eapi = portage._parse_eapi_ebuild_head(codecs.open(ebuild_path,
                                mode='r', encoding='utf_8', errors='replace'))
+
+               if eapi is not None:
                        if not portage.eapi_is_supported(eapi):
                                self.metadata_callback(self.cpv, self.ebuild_path,
                                        self.repo_path, {'EAPI' : eapi}, self.ebuild_mtime)
index 5c1cc1735947e01ad052bdaf1ef45dee5e0c50b4..ced078f6435e29d3e67e325cb225778b7b3cf443 100644 (file)
@@ -1790,9 +1790,12 @@ class config(object):
 
                        self["FEATURES"] = " ".join(sorted(self.features))
                        self.backup_changes("FEATURES")
-                       global _validate_cache_for_unsupported_eapis
+                       global _glep_55_enabled, _validate_cache_for_unsupported_eapis
                        if 'parse-eapi-ebuild-head' in self.features:
                                _validate_cache_for_unsupported_eapis = False
+                       if 'parse-eapi-glep-55' in self.features:
+                               _validate_cache_for_unsupported_eapis = False
+                               _glep_55_enabled = True
 
                        self._init_dirs()
 
@@ -4656,8 +4659,14 @@ def digestcheck(myfiles, mysettings, strict=0, justmanifest=0):
                writemsg("!!! Expected: %s\n" % e.value[3], noiselevel=-1)
                return 0
        # Make sure that all of the ebuilds are actually listed in the Manifest.
+       glep55 = 'parse-eapi-glep-55' in mysettings.features
        for f in os.listdir(pkgdir):
-               if f.endswith(".ebuild") and not mf.hasFile("EBUILD", f):
+               pf = None
+               if glep55:
+                       pf, eapi = _split_ebuild_name_glep55(f)
+               elif f[-7:] == '.ebuild':
+                       pf = f[:-7]
+               if pf is not None and not mf.hasFile("EBUILD", f):
                        writemsg("!!! A file is not listed in the Manifest: '%s'\n" % \
                                os.path.join(pkgdir, f), noiselevel=-1)
                        if strict:
@@ -5051,6 +5060,20 @@ def _parse_eapi_ebuild_head(f):
                        break
        return '0'
 
+# True when FEATURES=parse-eapi-glep-55 is enabled.
+_glep_55_enabled = False
+
+_split_ebuild_name_glep55_re = re.compile(r'^(.*)\.ebuild(-([^.]+))?$')
+
+def _split_ebuild_name_glep55(name):
+       """
+       @returns: (pkg-ver-rev, eapi)
+       """
+       m = _split_ebuild_name_glep55_re.match(name)
+       if m is None:
+               return (None, None)
+       return (m.group(1), m.group(3))
+
 def doebuild_environment(myebuild, mydo, myroot, mysettings, debug, use_cache, mydbapi):
 
        ebuild_path = os.path.abspath(myebuild)
@@ -5060,7 +5083,14 @@ def doebuild_environment(myebuild, mydo, myroot, mysettings, debug, use_cache, m
                cat = mysettings.configdict["pkg"]["CATEGORY"]
        else:
                cat = os.path.basename(normalize_path(os.path.join(pkg_dir, "..")))
-       mypv = os.path.basename(ebuild_path)[:-7]       
+
+       eapi = None
+       if 'parse-eapi-glep-55' in mysettings.features:
+               mypv, eapi = portage._split_ebuild_name_glep55(
+                       os.path.basename(myebuild))
+       else:
+               mypv = os.path.basename(ebuild_path)[:-7]
+
        mycpv = cat+"/"+mypv
        mysplit=pkgsplit(mypv,silent=0)
        if mysplit is None:
@@ -5124,13 +5154,19 @@ def doebuild_environment(myebuild, mydo, myroot, mysettings, debug, use_cache, m
                mysettings["PORTAGE_QUIET"] = "1"
 
        if mydo == 'depend' and \
-               'EAPI' not in mysettings.configdict['pkg'] and \
-               'parse-eapi-ebuild-head' in mysettings.features:
-               eapi = _parse_eapi_ebuild_head(codecs.open(ebuild_path,
-                       mode='r', encoding='utf_8', errors='replace'))
-               if not eapi_is_supported(eapi):
-                       raise portage.exception.UnsupportedAPIException(mycpv, eapi)
-               mysettings.configdict['pkg']['EAPI'] = eapi
+               'EAPI' not in mysettings.configdict['pkg']:
+
+               if eapi is not None:
+                       # From parse-eapi-glep-55 above.
+                       mysettings.configdict['pkg']['EAPI'] = eapi
+               elif 'parse-eapi-ebuild-head' in mysettings.features:
+                       eapi = _parse_eapi_ebuild_head(codecs.open(ebuild_path,
+                               mode='r', encoding='utf_8', errors='replace'))
+
+               if eapi is not None:
+                       if not eapi_is_supported(eapi):
+                               raise portage.exception.UnsupportedAPIException(mycpv, eapi)
+                       mysettings.configdict['pkg']['EAPI'] = eapi
 
        if mydo != "depend":
                # Metadata vars such as EAPI and RESTRICT are
@@ -5701,8 +5737,14 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0,
 
                        # Make sure that all of the ebuilds are
                        # actually listed in the Manifest.
+                       glep55 = 'parse-eapi-glep-55' in mysettings.features
                        for f in os.listdir(pkgdir):
-                               if f.endswith(".ebuild") and not mf.hasFile("EBUILD", f):
+                               pf = None
+                               if glep55:
+                                       pf, eapi = _split_ebuild_name_glep55(f)
+                               elif f[-7:] == '.ebuild':
+                                       pf = f[:-7]
+                               if pf is not None and not mf.hasFile("EBUILD", f):
                                        f = os.path.join(pkgdir, f)
                                        if f not in _doebuild_broken_ebuilds:
                                                out = portage.output.EOutput()
index 4cbf7af303218531fdcf06b8a750662b181c199c..126d3606c5cc91c29614dc80069f57f716e499e4 100644 (file)
@@ -279,7 +279,23 @@ class portdbapi(dbapi):
                else:
                        mytrees = self.porttrees[:]
                        mytrees.reverse()
-               if psplit:
+               if 'parse-eapi-glep-55' in self.doebuild_settings.features:
+                       glep55_startswith = '%s.ebuild-' % mysplit[1]
+                       for x in mytrees:
+                               filename = os.path.join(x, mysplit[0], psplit[0],
+                                       mysplit[1] + ".ebuild")
+                               if os.access(filename, os.R_OK):
+                                       return (filename, x)
+
+                               pkgdir = os.path.join(x, mysplit[0], psplit[0])
+                               try:
+                                       files = os.listdir(pkgdir)
+                               except OSError:
+                                       continue
+                               for y in files:
+                                       if y.startswith(glep55_startswith):
+                                               return (os.path.join(pkgdir, y), x)
+               else:
                        for x in mytrees:
                                file=x+"/"+mysplit[0]+"/"+psplit[0]+"/"+mysplit[1]+".ebuild"
                                if os.access(file, os.R_OK):
@@ -421,9 +437,15 @@ class portdbapi(dbapi):
                        mydata = {}
                        eapi = None
 
-                       if 'parse-eapi-ebuild-head' in self.doebuild_settings.features:
+                       if 'parse-eapi-glep-55' in self.doebuild_settings.features:
+                               pf, eapi = portage._split_ebuild_name_glep55(
+                                       os.path.basename(myebuild))
+                       if eapi is None and \
+                               'parse-eapi-ebuild-head' in self.doebuild_settings.features:
                                eapi = portage._parse_eapi_ebuild_head(codecs.open(myebuild,
                                        mode='r', encoding='utf_8', errors='replace'))
+
+                       if eapi is not None:
                                self.doebuild_settings.configdict['pkg']['EAPI'] = eapi
 
                        if eapi is not None and not portage.eapi_is_supported(eapi):
@@ -666,6 +688,7 @@ class portdbapi(dbapi):
                                return cachelist[:]
                mysplit = mycp.split("/")
                invalid_category = mysplit[0] not in self._categories
+               glep55 = 'parse-eapi-glep-55' in self.doebuild_settings.features
                d={}
                if mytree:
                        mytrees = [mytree]
@@ -677,8 +700,14 @@ class portdbapi(dbapi):
                        except OSError:
                                continue
                        for x in file_list:
-                               if x.endswith(".ebuild"):
+
+                               pf = None
+                               if glep55:
+                                       pf, eapi = portage._split_ebuild_name_glep55(x)
+                               elif x[-7:] == '.ebuild':
                                        pf = x[:-7]
+
+                               if pf is not None:
                                        ps = pkgsplit(pf)
                                        if not ps:
                                                writemsg("\nInvalid ebuild name: %s\n" % \
index 9150674a958994226229d0862199ec39be017314..80a0c16424c8a5167c8b0706646846284dc0adb4 100644 (file)
@@ -27,6 +27,10 @@ def manifest2AuxfileFilter(filename):
 
 def manifest2MiscfileFilter(filename):
        filename = filename.strip(os.sep)
+       if portage._glep_55_enabled:
+               pf, eapi = portage._split_ebuild_name_glep55(filename)
+               if pf is not None:
+                       return False
        return not (filename in ["CVS", ".svn", "files", "Manifest"] or filename.endswith(".ebuild"))
 
 def guessManifestFileType(filename):
@@ -307,9 +311,13 @@ class Manifest(object):
                for f in pkgdir_files:
                        if f[:1] == ".":
                                continue
-                       elif f[-7:] == ".ebuild":
-                               mytype = "EBUILD"
+                       pf = None
+                       if portage._glep_55_enabled:
+                               pf, eapi = portage._split_ebuild_name_glep55(f)
+                       elif f[-7:] == '.ebuild':
                                pf = f[:-7]
+                       if pf is not None:
+                               mytype = "EBUILD"
                                ps = portage.versions.pkgsplit(pf)
                                cpv = "%s/%s" % (cat, pf)
                                if not ps: