Make sure we don't allow REQUIRED_USE in EAPIs that don't support it
authorSebastian Luther <SebastianLuther@gmx.de>
Wed, 11 Aug 2010 12:00:29 +0000 (14:00 +0200)
committerZac Medico <zmedico@gentoo.org>
Wed, 11 Aug 2010 18:10:28 +0000 (11:10 -0700)
bin/ebuild.sh
pym/_emerge/Package.py
pym/portage/tests/resolver/ResolverPlayground.py
pym/portage/tests/resolver/test_eapi.py

index 014229446f8523aac4cba43fa70b9a24f1242bf7..ee565b1f79c6194de63db342dce9d70192a33fac 100755 (executable)
@@ -2164,11 +2164,6 @@ ebuild_main() {
 
                #the extra $(echo) commands remove newlines
                [ -n "${EAPI}" ] || EAPI=0
-               case "$EAPI" in
-                       0|1|2|3)
-                               unset REQUIRED_USE
-                               ;;
-               esac
 
                if [ -n "${dbkey}" ] ; then
                        > "${dbkey}"
index 992851bb12195ca28d93be517afe82ccb84501df..90a5d03eb3efaa131c423b6d9f472368c685a6ef 100644 (file)
@@ -8,7 +8,7 @@ import portage
 from portage.cache.mappings import slot_dict_class
 from portage.dep import isvalidatom, use_reduce, \
        paren_enclose, _slot_re
-from portage.eapi import eapi_has_iuse_defaults
+from portage.eapi import eapi_has_iuse_defaults, eapi_has_required_use
 from _emerge.Task import Task
 
 if sys.hexversion >= 0x3000000:
@@ -52,6 +52,10 @@ class Package(Task):
                        not eapi_has_iuse_defaults(self.metadata["EAPI"]):
                        self._invalid_metadata('IUSE.invalid',
                                "IUSE contains defaults, but EAPI doesn't allow them")
+               if self.metadata["REQUIRED_USE"] and \
+                       not eapi_has_required_use(self.metadata["EAPI"]):
+                       self._invalid_metadata('REQUIRED_USE.invalid',
+                               "REQUIRED_USE set, but EAPI doesn't allow it")
                self.slot_atom = portage.dep.Atom("%s:%s" % (self.cp, slot))
                self.category, self.pf = portage.catsplit(self.cpv)
                self.cpv_split = portage.catpkgsplit(self.cpv)
index 5b82b9a6c8becc76f36350901238b1bf94a4f5ef..d9dcdc2c83f3f77b5e2d9527bb952eeb1e5d5026 100644 (file)
@@ -66,6 +66,7 @@ class ResolverPlayground(object):
                        depend = metadata.get("DEPEND", "")
                        rdepend = metadata.get("RDEPEND", None)
                        pdepend = metadata.get("PDEPEND", None)
+                       required_use = metadata.get("REQUIRED_USE", None)
 
                        f = open(ebuild_path, "w")
                        f.write('EAPI="' + str(eapi) + '"\n')
@@ -77,6 +78,8 @@ class ResolverPlayground(object):
                                f.write('RDEPEND="' + str(rdepend) + '"\n')
                        if rdepend is not None:
                                f.write('PDEPEND="' + str(pdepend) + '"\n')
+                       if required_use is not None:
+                               f.write('REQUIRED_USE="' + str(required_use) + '"\n')
                        f.close()
 
        def _create_ebuild_manifests(self, ebuilds):
@@ -110,6 +113,7 @@ class ResolverPlayground(object):
                        depend = metadata.get("DEPEND", "")
                        rdepend = metadata.get("RDEPEND", None)
                        pdepend = metadata.get("PDEPEND", None)
+                       required_use = metadata.get("REQUIRED_USE", None)
                        
                        def write_key(key, value):
                                f = open(os.path.join(vdb_pkg_dir, key), "w")
@@ -126,6 +130,8 @@ class ResolverPlayground(object):
                                write_key("RDEPEND", rdepend)
                        if rdepend is not None:
                                write_key("PDEPEND", pdepend)
+                       if required_use is not None:
+                               write_key("REQUIRED_USE", required_use)
 
        def _create_profile(self, ebuilds, installed, profile):
                #Create $PORTDIR/profiles/categories
index dec1008fbfa0b35bb02f86e38b7eba19f374ea87..65dd0108bb4d204098a83ee021b961050e917cc0 100644 (file)
@@ -49,6 +49,13 @@ class EAPITestCase(TestCase):
                        #~ "dev-libs/A-6.2": { "EAPI": 2, "DEPEND": "dev-libs/B[bar(+)]" }, 
                        #~ "dev-libs/A-6.3": { "EAPI": 3, "DEPEND": "dev-libs/B[bar(+)]" }, 
                        #~ "dev-libs/A-6.4": { "EAPI": 4, "DEPEND": "dev-libs/B[bar(+)]" }, 
+                       
+                       #EAPI-4: REQUIRED_USE
+                       "dev-libs/A-7.0": { "EAPI": 0, "IUSE": "foo bar", "REQUIRED_USE": "|| ( foo bar )" }, 
+                       "dev-libs/A-7.1": { "EAPI": 1, "IUSE": "foo +bar", "REQUIRED_USE": "|| ( foo bar )" }, 
+                       "dev-libs/A-7.2": { "EAPI": 2, "IUSE": "foo +bar", "REQUIRED_USE": "|| ( foo bar )" }, 
+                       "dev-libs/A-7.3": { "EAPI": 3, "IUSE": "foo +bar", "REQUIRED_USE": "|| ( foo bar )" }, 
+                       #~ "dev-libs/A-7.4": { "EAPI": 4, "IUSE": "foo +bar", "REQUIRED_USE": "|| ( foo bar )" }, 
 
                        "dev-libs/B-1": {"EAPI": 1, "IUSE": "+foo"}, 
                        }
@@ -89,6 +96,12 @@ class EAPITestCase(TestCase):
                        #~ ResolverPlaygroundTestCase(["=dev-libs/A-6.2"], success = False),
                        #~ ResolverPlaygroundTestCase(["=dev-libs/A-6.3"], success = False),
                        #~ ResolverPlaygroundTestCase(["=dev-libs/A-6.4"], success = True, mergelist = ["dev-libs/B-1", "dev-libs/A-6.4"]),
+                       
+                       ResolverPlaygroundTestCase(["=dev-libs/A-7.0"], success = False),
+                       ResolverPlaygroundTestCase(["=dev-libs/A-7.1"], success = False),
+                       ResolverPlaygroundTestCase(["=dev-libs/A-7.2"], success = False),
+                       ResolverPlaygroundTestCase(["=dev-libs/A-7.3"], success = False),
+                       #~ ResolverPlaygroundTestCase(["=dev-libs/A-7.4"], success = True, mergelist = ["dev-libs/A-7.4"]),
                )
 
                playground = ResolverPlayground(ebuilds=ebuilds)