diff options
author | 2012-09-08 16:25:45 +0100 | |
---|---|---|
committer | 2012-09-08 16:25:45 +0100 | |
commit | 714dd6f3faaf0d78ff1b531eeecfa87a970d4d69 (patch) | |
tree | 6ddc4daefc354e04e1be934ea4e1a274b8d95c15 | |
parent | fe67468145178e13d5100cb62dce98195e1d56f2 (diff) | |
download | paludis-714dd6f3faaf0d78ff1b531eeecfa87a970d4d69.tar.gz paludis-714dd6f3faaf0d78ff1b531eeecfa87a970d4d69.tar.xz |
Add usex function for EAPI 5
-rw-r--r-- | paludis/repositories/e/e_repository_TEST_4.cc | 46 | ||||
-rwxr-xr-x | paludis/repositories/e/e_repository_TEST_4_setup.sh | 16 | ||||
-rw-r--r-- | paludis/repositories/e/e_repository_TEST_5.cc | 46 | ||||
-rwxr-xr-x | paludis/repositories/e/e_repository_TEST_5_setup.sh | 58 | ||||
-rw-r--r-- | paludis/repositories/e/eapis/5.conf | 2 | ||||
-rw-r--r-- | paludis/repositories/e/ebuild/5/Makefile.am | 1 | ||||
-rw-r--r-- | paludis/repositories/e/ebuild/5/usex.bash | 31 |
7 files changed, 200 insertions, 0 deletions
diff --git a/paludis/repositories/e/e_repository_TEST_4.cc b/paludis/repositories/e/e_repository_TEST_4.cc index e8a1a569d..5bdfd99ff 100644 --- a/paludis/repositories/e/e_repository_TEST_4.cc +++ b/paludis/repositories/e/e_repository_TEST_4.cc @@ -552,3 +552,49 @@ TEST(ERepository, RequiredUse) } } +TEST(ERepository, NoUseX) +{ + FSPath root(FSPath::cwd() / "e_repository_TEST_4_dir" / "root"); + + TestEnvironment env; + std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>()); + keys->insert("format", "e"); + keys->insert("names_cache", "/var/empty"); + keys->insert("location", stringify(FSPath::cwd() / "e_repository_TEST_4_dir" / "repo")); + keys->insert("profiles", stringify(FSPath::cwd() / "e_repository_TEST_4_dir" / "repo/profiles/profile")); + keys->insert("layout", "traditional"); + keys->insert("eapi_when_unknown", "0"); + keys->insert("eapi_when_unspecified", "0"); + keys->insert("profile_eapi", "0"); + keys->insert("distdir", stringify(FSPath::cwd() / "e_repository_TEST_4_dir" / "distdir")); + keys->insert("builddir", stringify(FSPath::cwd() / "e_repository_TEST_4_dir" / "build")); + std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env, + std::bind(from_keys, keys, std::placeholders::_1))); + env.add_repository(1, repo); + + std::shared_ptr<FakeInstalledRepository> installed_repo(std::make_shared<FakeInstalledRepository>( + make_named_values<FakeInstalledRepositoryParams>( + n::environment() = &env, + n::name() = RepositoryName("installed"), + n::suitable_destination() = true, + n::supports_uninstall() = true + ))); + env.add_repository(2, installed_repo); + + { + PretendAction pretend_action(make_named_values<PretendActionOptions>( + n::destination() = installed_repo, + n::make_output_manager() = &make_standard_output_manager, + n::replacing() = std::make_shared<PackageIDSequence>() + )); + + const std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches( + PackageDepSpec(parse_user_package_dep_spec("=cat/no-usex-4::test-repo", + &env, { })), make_null_shared_ptr(), { }))]->last()); + ASSERT_TRUE(bool(id)); + EXPECT_EQ("4", visitor_cast<const MetadataValueKey<std::string> >(**id->find_metadata("EAPI"))->parse_value()); + id->perform_action(pretend_action); + ASSERT_TRUE(! pretend_action.failed()); + } +} + diff --git a/paludis/repositories/e/e_repository_TEST_4_setup.sh b/paludis/repositories/e/e_repository_TEST_4_setup.sh index dac100902..4fd6f6094 100755 --- a/paludis/repositories/e/e_repository_TEST_4_setup.sh +++ b/paludis/repositories/e/e_repository_TEST_4_setup.sh @@ -1194,6 +1194,22 @@ src_configure() { [[ $(use_enable cheese cheese "") == --enable-cheese= ]] || die } END +mkdir -p "cat/no-usex" +cat <<'END' > cat/no-usex/no-usex-4.ebuild || exit 1 +EAPI="4" +DESCRIPTION="The Description" +HOMEPAGE="http://example.com/" +SRC_URI="" +SLOT="0" +IUSE="spork" +LICENSE="GPL-2" +KEYWORDS="test" +S=${WORKDIR} + +pkg_pretend() { + [[ -z $(type -t usex) ]] || die +} +END cd .. cd .. diff --git a/paludis/repositories/e/e_repository_TEST_5.cc b/paludis/repositories/e/e_repository_TEST_5.cc index d001f4fa9..739597fbf 100644 --- a/paludis/repositories/e/e_repository_TEST_5.cc +++ b/paludis/repositories/e/e_repository_TEST_5.cc @@ -218,3 +218,49 @@ TEST(ERepository, RequiredUse) } } +TEST(ERepository, UseX) +{ + FSPath root(FSPath::cwd() / "e_repository_TEST_5_dir" / "root"); + + TestEnvironment env; + std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>()); + keys->insert("format", "e"); + keys->insert("names_cache", "/var/empty"); + keys->insert("location", stringify(FSPath::cwd() / "e_repository_TEST_5_dir" / "repo")); + keys->insert("profiles", stringify(FSPath::cwd() / "e_repository_TEST_5_dir" / "repo/profiles/profile")); + keys->insert("layout", "traditional"); + keys->insert("eapi_when_unknown", "0"); + keys->insert("eapi_when_unspecified", "0"); + keys->insert("profile_eapi", "0"); + keys->insert("distdir", stringify(FSPath::cwd() / "e_repository_TEST_5_dir" / "distdir")); + keys->insert("builddir", stringify(FSPath::cwd() / "e_repository_TEST_5_dir" / "build")); + std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env, + std::bind(from_keys, keys, std::placeholders::_1))); + env.add_repository(1, repo); + + std::shared_ptr<FakeInstalledRepository> installed_repo(std::make_shared<FakeInstalledRepository>( + make_named_values<FakeInstalledRepositoryParams>( + n::environment() = &env, + n::name() = RepositoryName("installed"), + n::suitable_destination() = true, + n::supports_uninstall() = true + ))); + env.add_repository(2, installed_repo); + + { + PretendAction pretend_action(make_named_values<PretendActionOptions>( + n::destination() = installed_repo, + n::make_output_manager() = &make_standard_output_manager, + n::replacing() = std::make_shared<PackageIDSequence>() + )); + + const std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches( + PackageDepSpec(parse_user_package_dep_spec("=cat/usex-5::test-repo", + &env, { })), make_null_shared_ptr(), { }))]->last()); + ASSERT_TRUE(bool(id)); + EXPECT_EQ("5", visitor_cast<const MetadataValueKey<std::string> >(**id->find_metadata("EAPI"))->parse_value()); + id->perform_action(pretend_action); + ASSERT_TRUE(! pretend_action.failed()); + } +} + diff --git a/paludis/repositories/e/e_repository_TEST_5_setup.sh b/paludis/repositories/e/e_repository_TEST_5_setup.sh index a3ee9637f..65c782034 100755 --- a/paludis/repositories/e/e_repository_TEST_5_setup.sh +++ b/paludis/repositories/e/e_repository_TEST_5_setup.sh @@ -111,5 +111,63 @@ EOF } END +mkdir -p "cat/usex" || exit 1 +cat << 'END' > cat/usex/usex-5.ebuild || exit 1 +EAPI="5" +DESCRIPTION="The Description" +HOMEPAGE="http://example.com/" +SRC_URI="" +SLOT="0" +IUSE="enabled disabled" +LICENSE="GPL-2" +KEYWORDS="test" + +S="${WORKDIR}" + +pkg_pretend() { + usex enabled >>"${T}"/usex.out || die + usex disabled >>"${T}"/usex.out || die + usex enabled foo >>"${T}"/usex.out || die + usex disabled foo >>"${T}"/usex.out || die + usex enabled foo bar >>"${T}"/usex.out || die + usex disabled foo bar >>"${T}"/usex.out || die + usex enabled foo bar xyzzy >>"${T}"/usex.out || die + usex disabled foo bar xyzzy >>"${T}"/usex.out || die + usex enabled foo bar xyzzy plugh >>"${T}"/usex.out || die + usex disabled foo bar xyzzy plugh >>"${T}"/usex.out || die + usex enabled "" bar xyzzy plugh >>"${T}"/usex.out || die + usex disabled "" bar xyzzy plugh >>"${T}"/usex.out || die + usex enabled foo "" xyzzy plugh >>"${T}"/usex.out || die + usex disabled foo "" xyzzy plugh >>"${T}"/usex.out || die + usex enabled foo bar "" plugh >>"${T}"/usex.out || die + usex disabled foo bar "" plugh >>"${T}"/usex.out || die + usex enabled foo bar xyzzy "" >>"${T}"/usex.out || die + usex disabled foo bar xyzzy "" >>"${T}"/usex.out || die + + cat >"${T}"/usex.expected <<EOF +yes +no +foo +no +foo +bar +fooxyzzy +bar +fooxyzzy +barplugh +xyzzy +barplugh +fooxyzzy +plugh +foo +barplugh +fooxyzzy +bar +EOF + + diff "${T}"/usex.{expected,out} || die +} +END + cd .. cd .. diff --git a/paludis/repositories/e/eapis/5.conf b/paludis/repositories/e/eapis/5.conf index 225a3ad58..954a37a94 100644 --- a/paludis/repositories/e/eapis/5.conf +++ b/paludis/repositories/e/eapis/5.conf @@ -11,4 +11,6 @@ utility_path_suffixes = 5 4 3 2 1 0 dependency_spec_tree_parse_options = ${dependency_spec_tree_parse_options} allow_at_most_one +load_modules = ${load_modules} usex + econf_extra_options_help_dependent = ${econf_extra_options_help_dependent} disable-silent-rules::--disable-silent-rules diff --git a/paludis/repositories/e/ebuild/5/Makefile.am b/paludis/repositories/e/ebuild/5/Makefile.am index 8e2370803..99d227dfd 100644 --- a/paludis/repositories/e/ebuild/5/Makefile.am +++ b/paludis/repositories/e/ebuild/5/Makefile.am @@ -5,6 +5,7 @@ SUBDIRS = . libexecprog5dir = $(libexecdir)/paludis/5 libexecprog5_SCRIPTS = \ + usex.bash \ output_functions.bash TESTS = diff --git a/paludis/repositories/e/ebuild/5/usex.bash b/paludis/repositories/e/ebuild/5/usex.bash new file mode 100644 index 000000000..2d30c1a4b --- /dev/null +++ b/paludis/repositories/e/ebuild/5/usex.bash @@ -0,0 +1,31 @@ +#!/usr/bin/env bash +# vim: set sw=4 sts=4 et : + +# Copyright (c) 2012 David Leverton +# +# Based in part upon ebuild.sh from Portage, which is Copyright 1995-2005 +# Gentoo Foundation and distributed under the terms of the GNU General +# Public License v2. +# +# This file is part of the Paludis package manager. Paludis is free software; +# you can redistribute it and/or modify it under the terms of the GNU General +# Public License, version 2, as published by the Free Software Foundation. +# +# Paludis is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +# details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., 59 Temple +# Place, Suite 330, Boston, MA 02111-1307 USA + +usex() +{ + if useq "${1}" ; then + echo "${2-yes}${4}" + else + echo "${3-no}${5}" + fi +} + |