aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-07-01 14:23:32 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-07-01 14:23:32 +0100
commit3723adb541decb77e3bec96fb85c47f9197ccf11 (patch)
tree81fad7b114a1ddd6cad6a72e3fc50afa4a507004
parentfc75b73046cee4ae8400fcf36824cadef9c6b15a (diff)
downloadpaludis-3723adb541decb77e3bec96fb85c47f9197ccf11.tar.gz
paludis-3723adb541decb77e3bec96fb85c47f9197ccf11.tar.xz
Fix PortageEnvironment -flags in USE.
Fixes: ticket:597.
-rw-r--r--paludis/environments/portage/portage_environment.cc26
-rw-r--r--paludis/environments/portage/portage_environment_TEST.cc2
-rwxr-xr-xpaludis/environments/portage/portage_environment_TEST_setup.sh4
3 files changed, 18 insertions, 14 deletions
diff --git a/paludis/environments/portage/portage_environment.cc b/paludis/environments/portage/portage_environment.cc
index 1b036d7..708404f 100644
--- a/paludis/environments/portage/portage_environment.cc
+++ b/paludis/environments/portage/portage_environment.cc
@@ -80,7 +80,7 @@ namespace paludis
std::tr1::shared_ptr<KeyValueConfigFile> vars;
- std::set<std::string> use_with_expands;
+ std::list<std::string> use_with_expands;
std::set<std::string> use_expand;
std::set<std::string> accept_keywords;
std::multimap<std::string, std::string> mirrors;
@@ -208,8 +208,7 @@ namespace
new_values.clear();
else if ('-' == v->at(0))
new_values.erase(v->substr(1));
- else
- new_values.insert(*v);
+ new_values.insert(*v);
}
return join(new_values.begin(), new_values.end(), " ");
@@ -286,10 +285,8 @@ PortageEnvironment::PortageEnvironment(const std::string & s) :
/* use etc */
- tokenise_whitespace(_imp->vars->get("USE"), std::inserter(_imp->use_with_expands,
- _imp->use_with_expands.begin()));
- tokenise_whitespace(_imp->vars->get("USE_EXPAND"), std::inserter(_imp->use_expand,
- _imp->use_expand.begin()));
+ tokenise_whitespace(_imp->vars->get("USE"), std::back_inserter(_imp->use_with_expands));
+ tokenise_whitespace(_imp->vars->get("USE_EXPAND"), std::inserter(_imp->use_expand, _imp->use_expand.begin()));
for (std::set<std::string>::const_iterator i(_imp->use_expand.begin()), i_end(_imp->use_expand.end()) ;
i != i_end ; ++i)
{
@@ -301,7 +298,7 @@ PortageEnvironment::PortageEnvironment(const std::string & s) :
values.begin()));
for (std::set<std::string>::const_iterator v(values.begin()), v_end(values.end()) ;
v != v_end ; ++v)
- _imp->use_with_expands.insert(lower_i + "_" + *v);
+ _imp->use_with_expands.push_back(lower_i + "_" + *v);
}
/* accept keywords */
@@ -570,9 +567,14 @@ PortageEnvironment::query_use(const UseFlagName & f, const PackageID & e) const
state = (*e.repository())[k::use_interface()]->query_use(f, e);
/* check use: general user config */
- std::set<std::string>::const_iterator u(_imp->use_with_expands.find(stringify(f)));
- if (u != _imp->use_with_expands.end())
- state = use_enabled;
+ for (std::list<std::string>::const_iterator i(_imp->use_with_expands.begin()), i_end(_imp->use_with_expands.end()) ;
+ i != i_end ; ++i)
+ if (*i == "-*")
+ state = use_disabled;
+ else if (*i == stringify(f))
+ state = use_enabled;
+ else if (*i == "-" + stringify(f))
+ state = use_disabled;
/* check use: per package config */
for (PackageUse::const_iterator i(_imp->package_use.begin()), i_end(_imp->package_use.end()) ;
@@ -685,7 +687,7 @@ PortageEnvironment::known_use_expand_names(const UseFlagName & prefix,
std::transform(prefix.data().begin(), prefix.data().end(), std::back_inserter(prefix_lower), &::tolower);
prefix_lower.append("_");
- for (std::set<std::string>::const_iterator i(_imp->use_with_expands.begin()),
+ for (std::list<std::string>::const_iterator i(_imp->use_with_expands.begin()),
i_end(_imp->use_with_expands.end()) ; i != i_end ; ++i)
if (0 == i->compare(0, prefix_lower.length(), prefix_lower, 0, prefix_lower.length()))
result->insert(UseFlagName(*i));
diff --git a/paludis/environments/portage/portage_environment_TEST.cc b/paludis/environments/portage/portage_environment_TEST.cc
index 40b75e3..01dd9b1 100644
--- a/paludis/environments/portage/portage_environment_TEST.cc
+++ b/paludis/environments/portage/portage_environment_TEST.cc
@@ -84,12 +84,14 @@ namespace test_cases
TEST_CHECK(! env.query_use(UseFlagName("three"), *idx));
TEST_CHECK(! env.query_use(UseFlagName("four"), *idx));
TEST_CHECK(! env.query_use(UseFlagName("five"), *idx));
+ TEST_CHECK(! env.query_use(UseFlagName("six"), *idx));
TEST_CHECK(! env.query_use(UseFlagName("one"), *id1));
TEST_CHECK(env.query_use(UseFlagName("two"), *id1));
TEST_CHECK(! env.query_use(UseFlagName("three"), *id1));
TEST_CHECK(env.query_use(UseFlagName("four"), *id1));
TEST_CHECK(! env.query_use(UseFlagName("five"), *id1));
+ TEST_CHECK(! env.query_use(UseFlagName("six"), *id1));
}
} test_query_use;
diff --git a/paludis/environments/portage/portage_environment_TEST_setup.sh b/paludis/environments/portage/portage_environment_TEST_setup.sh
index f260eab..4b71aa8 100755
--- a/paludis/environments/portage/portage_environment_TEST_setup.sh
+++ b/paludis/environments/portage/portage_environment_TEST_setup.sh
@@ -11,7 +11,7 @@ ARCH="arch"
ACCEPT_KEYWORDS="arch"
USE_EXPAND="FOO_CARDS"
FOO_CARDS="four"
-USE="foo_c"
+USE="foo_c six"
END
mkdir -p var/db/pkg
@@ -30,7 +30,7 @@ touch repo/cat-one/pkg-x/pkg-x-1.ebuild || exit 4
mkdir -p query_use/${SYSCONFDIR}/portage
ln -s $(pwd )/profile query_use/${SYSCONFDIR}/make.profile
cat <<END > query_use/${SYSCONFDIR}/make.conf
-USE="one two -three"
+USE="one two -three -six"
PORTDIR="`pwd`/repo"
END
cat <<"END" > query_use/${SYSCONFDIR}/portage/package.use