From af52e04dd1709b5b4d48fdee90b2d04f67617234 Mon Sep 17 00:00:00 2001 From: Sebastian Luther Date: Wed, 11 Aug 2010 14:00:29 +0200 Subject: [PATCH] Make sure we don't allow REQUIRED_USE in EAPIs that don't support it --- bin/ebuild.sh | 5 ----- pym/_emerge/Package.py | 6 +++++- pym/portage/tests/resolver/ResolverPlayground.py | 6 ++++++ pym/portage/tests/resolver/test_eapi.py | 13 +++++++++++++ 4 files changed, 24 insertions(+), 6 deletions(-) diff --git a/bin/ebuild.sh b/bin/ebuild.sh index 014229446..ee565b1f7 100755 --- a/bin/ebuild.sh +++ b/bin/ebuild.sh @@ -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}" diff --git a/pym/_emerge/Package.py b/pym/_emerge/Package.py index 992851bb1..90a5d03eb 100644 --- a/pym/_emerge/Package.py +++ b/pym/_emerge/Package.py @@ -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) diff --git a/pym/portage/tests/resolver/ResolverPlayground.py b/pym/portage/tests/resolver/ResolverPlayground.py index 5b82b9a6c..d9dcdc2c8 100644 --- a/pym/portage/tests/resolver/ResolverPlayground.py +++ b/pym/portage/tests/resolver/ResolverPlayground.py @@ -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 diff --git a/pym/portage/tests/resolver/test_eapi.py b/pym/portage/tests/resolver/test_eapi.py index dec1008fb..65dd0108b 100644 --- a/pym/portage/tests/resolver/test_eapi.py +++ b/pym/portage/tests/resolver/test_eapi.py @@ -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) -- 2.26.2