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

svn path=/main/branches/2.1.6/; revision=13205

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 e85fbd0d702b06bb52b79ba7f1cda574f34329e0..955b42668e297cd0d75160b9db55c3b9f6e1f629 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 protect\-owned
 This is identical to the \fIcollision\-protect\fR feature except that files
 may be overwritten if they are not explicitly listed in the contents of a
index 86667a792766dfcc97329ac3a5399e9c758feb30..1e31ba8d2f0556836ae881714e5f947399a7429d 100644 (file)
@@ -3018,9 +3018,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 8281d03edd29715669675e88352707b1ccad5e3c..f51c12be32bfe1f6c94c569ae80028f64ad4cbeb 100644 (file)
@@ -1780,9 +1780,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()
 
@@ -4646,8 +4649,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:
@@ -5041,6 +5050,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)
@@ -5050,7 +5073,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:
@@ -5114,13 +5144,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
@@ -5691,8 +5727,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: