aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-05-05 06:50:48 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-05-05 06:50:48 +0000
commitc7218cf044f1573e3b849a022749be320d9cf462 (patch)
treeab56d5823e3086fbc11f2ca0520173a667f456a6
parent12c24d0e1654147601c1f182329d31c7f89d27de (diff)
downloadpaludis-c7218cf044f1573e3b849a022749be320d9cf462.tar.gz
paludis-c7218cf044f1573e3b849a022749be320d9cf462.tar.xz
Do the expand stuff a much simpler way
-rw-r--r--paludis/repositories/e/e_repository_TEST.cc18
-rwxr-xr-xpaludis/repositories/e/e_repository_TEST_setup.sh45
-rw-r--r--paludis/repositories/e/ebuild_entries.cc97
3 files changed, 95 insertions, 65 deletions
diff --git a/paludis/repositories/e/e_repository_TEST.cc b/paludis/repositories/e/e_repository_TEST.cc
index 89c6c52..d146685 100644
--- a/paludis/repositories/e/e_repository_TEST.cc
+++ b/paludis/repositories/e/e_repository_TEST.cc
@@ -1258,6 +1258,15 @@ namespace test_cases
TEST_CHECK(id);
id->perform_action(action);
}
+
+ {
+ TestMessageSuffix suffix("expand vars", true);
+ const std::tr1::shared_ptr<const PackageID> id(*env.package_database()->query(query::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/expand-vars-0",
+ UserPackageDepSpecOptions()))), qo_require_exactly_one)->last());
+ TEST_CHECK(id);
+ id->perform_action(action);
+ }
}
} test_e_repository_install_eapi_0;
@@ -1627,6 +1636,15 @@ namespace test_cases
TEST_CHECK(id);
id->perform_action(action);
}
+
+ {
+ TestMessageSuffix suffix("expand vars", true);
+ const std::tr1::shared_ptr<const PackageID> id(*env.package_database()->query(query::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/expand-vars-0",
+ UserPackageDepSpecOptions()))), qo_require_exactly_one)->last());
+ TEST_CHECK(id);
+ id->perform_action(action);
+ }
}
} test_e_repository_install_exheres_0;
diff --git a/paludis/repositories/e/e_repository_TEST_setup.sh b/paludis/repositories/e/e_repository_TEST_setup.sh
index 0ec4718..f2f1b94 100755
--- a/paludis/repositories/e/e_repository_TEST_setup.sh
+++ b/paludis/repositories/e/e_repository_TEST_setup.sh
@@ -506,6 +506,8 @@ USERLAND="GNU"
KERNEL="linux"
LIBC="glibc"
CHOST="i286-badger-linux-gnu"
+LINGUAS="enabled_en enabled_en_GB enabled_en_GB@UTF-8"
+USE_EXPAND="LINGUAS"
END
mkdir -p "cat/in-ebuild-die"
cat <<END > cat/in-ebuild-die/in-ebuild-die-1.ebuild || exit 1
@@ -856,6 +858,23 @@ src_install() {
dosym foo /usr/bin/bar
}
END
+mkdir -p "cat/expand-vars"
+cat <<"END" > cat/expand-vars/expand-vars-0.ebuild || exit 1
+DESCRIPTION="The Description"
+HOMEPAGE="http://example.com/"
+SRC_URI=""
+SLOT="0"
+IUSE="enabled-weasel broccoli"
+LICENSE="GPL-2"
+KEYWORDS="test"
+
+pkg_setup() {
+ [[ $USE == "enabled-weasel test linguas_enabled_en linguas_enabled_en_GB linguas_enabled_en_GB@UTF-8 " ]] \
+ || die "USE=$USE is wrong"
+ [[ $USERLAND == "GNU" ]] || die "USERLAND=$USERLAND is wrong"
+ [[ $LINGUAS == "enabled_en enabled_en_GB enabled_en_GB@UTF-8" ]] || die "LINGUAS=$LINGUAS is wrong"
+}
+END
cd ..
mkdir -p repo14/{profiles/profile,metadata,eclass} || exit 1
@@ -868,6 +887,10 @@ END
echo "cat" >> metadata/categories.conf || exit 1
cat <<END > profiles/profile/make.defaults
CHOST="i286-badger-linux-gnu"
+SUBOPTIONS="linguas"
+LINGUAS="en en_GB en_GB@UTF-8"
+USERLAND="GNU"
+OPTIONS="weasel spinach"
END
mkdir -p "packages/cat/in-ebuild-die"
cat <<END > packages/cat/in-ebuild-die/in-ebuild-die-1.ebuild || exit 1
@@ -1009,7 +1032,7 @@ SRC_URI=""
SLOT="0"
MYOPTIONS="spork"
LICENSE="GPL-2"
-PLATFORM="test"
+PLATFORMS="test"
pkg_setup() {
portageq match "${ROOT}" cat/foo | while read a ; do
@@ -1032,7 +1055,7 @@ SRC_URI=""
SLOT="0"
MYOPTIONS="spork"
LICENSE="GPL-2"
-PLATFORM="test"
+PLATFORMS="test"
pkg_setup() {
ever at_least 1.2 || die "at_least 1.2"
@@ -1053,7 +1076,7 @@ SRC_URI=""
SLOT="0"
MYOPTIONS="spork"
LICENSE="GPL-2"
-PLATFORM="test"
+PLATFORMS="test"
src_unpack() {
mkdir ${S}
@@ -1074,7 +1097,7 @@ SRC_URI=""
SLOT="0"
MYOPTIONS="enabled-hamster gerbil dormouse"
LICENSE="GPL-2"
-PLATFORM="test"
+PLATFORMS="test"
DEFAULT_SRC_CONFIGURE_PARAMS="--nice-juicy-steak"
DEFAULT_SRC_CONFIGURE_OPTION_ENABLES="enabled-hamster gerbil"
@@ -1093,6 +1116,20 @@ END2
chmod +x ${S}/configure
}
END
+mkdir -p "packages/cat/expand-vars"
+cat <<"END" > packages/cat/expand-vars/expand-vars-0.ebuild || exit 1
+DESCRIPTION="The Description"
+HOMEPAGE="http://example.com/"
+SRC_URI=""
+SLOT="0"
+MYOPTIONS="enabled-weasel broccoli linguas:enabled-en_GB"
+LICENSE="GPL-2"
+PLATFORMS="test"
+
+pkg_setup() {
+ [[ ${OPTIONS%%+( )} == "enabled-weasel linguas:enabled-en_GB" ]] || die "OPTIONS=$OPTIONS is wrong"
+}
+END
cd ..
mkdir -p repo15/{eclass,distfiles,profiles/profile/subprofile} || exit 1
diff --git a/paludis/repositories/e/ebuild_entries.cc b/paludis/repositories/e/ebuild_entries.cc
index 5122e55..135b66a 100644
--- a/paludis/repositories/e/ebuild_entries.cc
+++ b/paludis/repositories/e/ebuild_entries.cc
@@ -230,7 +230,7 @@ namespace
if (! (*id.eapi())[k::supported()])
{
Log::get_instance()->message("e.ebuild.unknown_eapi", ll_warning, lc_context)
- << "Don't know how to make a USE string for '" << id << "' because its EAPI is unsupported";
+ << "Can't make the USE string for '" << id << "' because its EAPI is unsupported";
return "";
}
@@ -243,8 +243,7 @@ namespace
use += stringify(i->flag) + " ";
if (! (*(*id.eapi())[k::supported()])[k::ebuild_environment_variables()][k::env_arch()].empty())
- use += profile->environment_variable((*(*id.eapi())[k::supported()])
- [k::ebuild_environment_variables()][k::env_arch()]) + " ";
+ use += profile->environment_variable((*(*id.eapi())[k::supported()])[k::ebuild_environment_variables()][k::env_arch()]) + " ";
return use;
}
@@ -256,12 +255,13 @@ namespace
std::string & use,
const std::string & expand_sep)
{
- std::tr1::shared_ptr<Map<std::string, std::string> > expand_vars(new Map<std::string, std::string>);
+ std::tr1::shared_ptr<Map<std::string, std::string> > expand_vars(
+ new Map<std::string, std::string>);
if (! (*e.eapi())[k::supported()])
{
Log::get_instance()->message("e.ebuild.unknown_eapi", ll_warning, lc_context)
- << "Don't know how to make USE_EXPAND strings for '" << e << "' because its EAPI is unsupported";
+ << "Can't make the USE_EXPAND strings for '" << e << "' because its EAPI is unsupported";
return expand_vars;
}
@@ -273,68 +273,43 @@ namespace
expand_vars->insert(stringify(*x), "");
- if ((*(*e.eapi())[k::supported()])[k::ebuild_options()].require_use_expand_in_iuse)
- {
- /* oh good. we just need to work from IUSE. no need to mess with the use parameter,
- * that's already handled by make_use. */
-
- if (e.iuse_key())
- for (IUseFlagSet::ConstIterator i(e.iuse_key()->value()->begin()),
- i_end(e.iuse_key()->value()->end()) ; i != i_end ; ++i)
- {
- std::string lower_i;
- std::transform(i->flag.data().begin(), i->flag.data().end(),
- std::back_inserter(lower_i), &::tolower);
- if (0 == lower_i.compare(0, lower_x.length() + 1, lower_x + expand_sep,
- 0, lower_x.length() + 1))
- {
- Map<std::string, std::string>::ConstIterator f(expand_vars->find(stringify(*x)));
- std::string value;
- if (expand_vars->end() != f)
- value = f->second + " ";
- value.append(stringify(*i).substr(lower_x.length() + 1));
- if (expand_vars->end() != f)
- expand_vars->erase(f);
- expand_vars->insert(stringify(*x), value);
- }
- }
- }
- else
+ /* possible values from profile */
+ std::set<UseFlagName> possible_values;
+ tokenise_whitespace(profile->environment_variable(stringify(*x)),
+ create_inserter<UseFlagName>(std::inserter(possible_values, possible_values.end())));
+
+ /* possible values from environment */
+ std::tr1::shared_ptr<const UseFlagNameSet> possible_values_from_env(
+ env->known_use_expand_names(*x, e));
+ for (UseFlagNameSet::ConstIterator i(possible_values_from_env->begin()),
+ i_end(possible_values_from_env->end()) ; i != i_end ; ++i)
+ possible_values.insert(UseFlagName(stringify(*i).substr(lower_x.length() + 1)));
+
+ for (std::set<UseFlagName>::const_iterator u(possible_values.begin()), u_end(possible_values.end()) ;
+ u != u_end ; ++u)
{
- /* pesky 0-based EAPI that takes USE_EXPAND things from everywhere, not from IUSE */
-
- /* possible values from profile */
- std::set<UseFlagName> possible_values;
- tokenise_whitespace(profile->environment_variable(stringify(*x)),
- create_inserter<UseFlagName>(std::inserter(possible_values, possible_values.end())));
-
- /* possible values from environment */
- std::tr1::shared_ptr<const UseFlagNameSet> possible_values_from_env(
- env->known_use_expand_names(*x, e));
- for (UseFlagNameSet::ConstIterator i(possible_values_from_env->begin()),
- i_end(possible_values_from_env->end()) ; i != i_end ; ++i)
- possible_values.insert(UseFlagName(stringify(*i).substr(lower_x.length() + 1)));
-
- for (std::set<UseFlagName>::const_iterator u(possible_values.begin()), u_end(possible_values.end()) ;
- u != u_end ; ++u)
- {
- if (! env->query_use(UseFlagName(lower_x + expand_sep + stringify(*u)), e))
+ if ((*(*e.eapi())[k::supported()])[k::ebuild_options()].require_use_expand_in_iuse)
+ if (e.iuse_key() && e.iuse_key()->value()->end() == e.iuse_key()->value()->find(
+ IUseFlag(*u, use_unspecified, std::string::npos)))
continue;
+ if (! env->query_use(UseFlagName(lower_x + expand_sep + stringify(*u)), e))
+ continue;
+
+ if (! (*(*e.eapi())[k::supported()])[k::ebuild_options()].require_use_expand_in_iuse)
use.append(lower_x + expand_sep + stringify(*u) + " ");
- std::string value;
- Map<std::string, std::string>::ConstIterator i(expand_vars->find(stringify(*x)));
- if (expand_vars->end() != i)
- {
- value = i->second;
- if (! value.empty())
- value.append(" ");
- expand_vars->erase(i);
- }
- value.append(stringify(*u));
- expand_vars->insert(stringify(*x), value);
+ std::string value;
+ Map<std::string, std::string>::ConstIterator i(expand_vars->find(stringify(*x)));
+ if (expand_vars->end() != i)
+ {
+ value = i->second;
+ if (! value.empty())
+ value.append(" ");
+ expand_vars->erase(i);
}
+ value.append(stringify(*u));
+ expand_vars->insert(stringify(*x), value);
}
}