aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar David Leverton <levertond@googlemail.com> 2009-03-05 21:35:27 +0000
committerAvatar David Leverton <levertond@googlemail.com> 2009-03-05 21:35:27 +0000
commit2a9578aabd95712bfe4bc1c747ae8dbbfab0bc42 (patch)
treee2764e4fac4e9a96ba7e38dfffaed2e033e8b81c
parent072ee1455a4a9547e49f44bffdb1f8031af4c81b (diff)
downloadpaludis-2a9578aabd95712bfe4bc1c747ae8dbbfab0bc42.tar.gz
paludis-2a9578aabd95712bfe4bc1c747ae8dbbfab0bc42.tar.xz
Make masked/forced/profile-package.used USE_EXPAND flags show up even if not in IUSE
-rw-r--r--paludis/repositories/e/e_repository_TEST.cc22
-rwxr-xr-xpaludis/repositories/e/e_repository_TEST_setup.sh17
-rw-r--r--paludis/repositories/e/e_repository_profile.cc63
-rw-r--r--paludis/repositories/e/e_repository_profile.hh3
4 files changed, 95 insertions, 10 deletions
diff --git a/paludis/repositories/e/e_repository_TEST.cc b/paludis/repositories/e/e_repository_TEST.cc
index edef15c..54442cd 100644
--- a/paludis/repositories/e/e_repository_TEST.cc
+++ b/paludis/repositories/e/e_repository_TEST.cc
@@ -587,10 +587,12 @@ namespace test_cases
{
ERepositoryQueryUseTest() : TestCase("USE query") { }
- void test_choice(const std::tr1::shared_ptr<const PackageID> & p, const std::string & n, bool enabled, bool enabled_by_default, bool locked)
+ void test_choice(const std::tr1::shared_ptr<const PackageID> & p, const std::string & n, bool enabled, bool enabled_by_default, bool locked, const std::string & u = "")
{
TestMessageSuffix s(stringify(*p) + "[" + n + "]", true);
std::tr1::shared_ptr<const ChoiceValue> choice(p->choices_key()->value()->find_by_name_with_prefix(ChoiceNameWithPrefix(n)));
+ TEST_CHECK(choice);
+ TEST_CHECK_EQUAL(choice->unprefixed_name(), UnprefixedChoiceName(u.empty() ? n : u));
TEST_CHECK_EQUAL(choice->enabled(), enabled);
TEST_CHECK_EQUAL(choice->enabled_by_default(), enabled_by_default);
TEST_CHECK_EQUAL(choice->locked(), locked);
@@ -605,7 +607,7 @@ namespace test_cases
keys->insert("format", "ebuild");
keys->insert("names_cache", "/var/empty");
keys->insert("location", stringify(FSEntry::cwd() / "e_repository_TEST_dir" / "repo9"));
- keys->insert("profiles", stringify(FSEntry::cwd() / "e_repository_TEST_dir" / "repo9/profiles/profile"));
+ keys->insert("profiles", stringify(FSEntry::cwd() / "e_repository_TEST_dir" / "repo9/profiles/child"));
keys->insert("builddir", stringify(FSEntry::cwd() / "e_repository_TEST_dir" / "build"));
std::tr1::shared_ptr<ERepository> repo(std::tr1::static_pointer_cast<ERepository>(ERepository::repository_factory_create(&env,
std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1))));
@@ -653,6 +655,22 @@ namespace test_cases
test_choice(p1, "test", true, true, true);
test_choice(p1, "test2", false, false, true);
+
+ test_choice(p1, "not_in_iuse_ennobled", true, true, false, "ennobled");
+ test_choice(p1, "not_in_iuse_masked", false, false, true, "masked");
+ test_choice(p1, "not_in_iuse_forced", true, true, true, "forced");
+ test_choice(p1, "not_in_iuse_ennobled_package", true, true, false, "ennobled_package");
+ test_choice(p1, "not_in_iuse_disabled_package", false, false, false, "disabled_package");
+ test_choice(p1, "not_in_iuse_masked_package", false, false, true, "masked_package");
+ test_choice(p1, "not_in_iuse_forced_package", false, false, false, "forced_package");
+
+ test_choice(p2, "not_in_iuse_ennobled", false, false, false, "ennobled");
+ test_choice(p2, "not_in_iuse_masked", false, false, true, "masked");
+ test_choice(p2, "not_in_iuse_forced", true, true, true, "forced");
+ test_choice(p2, "not_in_iuse_ennobled_package", false, false, false, "ennobled_package");
+ test_choice(p2, "not_in_iuse_disabled_package", false, false, false, "disabled_package");
+ test_choice(p2, "not_in_iuse_masked_package", false, false, false, "masked_package");
+ test_choice(p2, "not_in_iuse_forced_package", true, true, true, "forced_package");
}
}
} test_e_repository_query_use;
diff --git a/paludis/repositories/e/e_repository_TEST_setup.sh b/paludis/repositories/e/e_repository_TEST_setup.sh
index 8f60fc1..0c4bef4 100755
--- a/paludis/repositories/e/e_repository_TEST_setup.sh
+++ b/paludis/repositories/e/e_repository_TEST_setup.sh
@@ -191,7 +191,7 @@ END
cd ..
-mkdir -p repo9/{eclass,distfiles,profiles/profile,cat-one/pkg-one,cat-two/pkg-one} || exit 1
+mkdir -p repo9/{eclass,distfiles,profiles/{profile,child},cat-one/pkg-one,cat-two/pkg-one} || exit 1
mkdir -p repo9/{cat-one/pkg-one,cat-two/pkg-two} || exit 1
cd repo9 || exit 1
echo "test-repo-9" > profiles/repo_name || exit 1
@@ -206,21 +206,34 @@ END
cat <<END >profiles/profile/make.defaults || exit 1
ARCH=test
USE="flag1 flag2 flag3 -flag4 -flag5 -enabled2 disabled2"
+USE_EXPAND="NOT_IN_IUSE"
+NOT_IN_IUSE="ennobled"
END
cat <<END >profiles/profile/use.mask || exit 1
flag2
enabled3
+not_in_iuse_masked
END
cat <<END >profiles/profile/use.force || exit 1
flag4
disabled3
+not_in_iuse_forced
+END
+cat <<END >profiles/profile/package.use || exit 1
+cat-one/pkg-one not_in_iuse_ennobled_package
+cat-two/pkg-two -not_in_iuse_disabled_package -not_in_iuse_ennobled
END
cat <<END >profiles/profile/package.use.mask || exit 1
cat-two/pkg-two flag3
>=cat-one/pkg-one-2 flag3
+cat-one/pkg-one not_in_iuse_masked_package
END
-cat <<END >profiles/profile/package.use.force || exit 1
+cat <<END >profiles/child/package.use.force || exit 1
cat-two/pkg-two flag5
+cat-two/pkg-two not_in_iuse_forced_package
+END
+cat <<END >profiles/child/parent || exit 1
+../profile
END
cat <<END > cat-one/pkg-one/pkg-one-1.ebuild || exit 1
EAPI=1
diff --git a/paludis/repositories/e/e_repository_profile.cc b/paludis/repositories/e/e_repository_profile.cc
index 1b58d74..7182f1b 100644
--- a/paludis/repositories/e/e_repository_profile.cc
+++ b/paludis/repositories/e/e_repository_profile.cc
@@ -167,6 +167,8 @@ namespace paludis
std::tr1::shared_ptr<Set<std::string> > use_expand;
std::tr1::shared_ptr<Set<std::string> > use_expand_hidden;
KnownMap known_choice_value_names;
+ mutable Mutex known_choice_value_names_for_separator_mutex;
+ mutable std::tr1::unordered_map<char, KnownMap> known_choice_value_names_for_separator;
StackedValuesList stacked_values_list;
///\}
@@ -843,18 +845,69 @@ ERepositoryProfile::use_state_ignoring_masks(
return result;
}
+namespace
+{
+ void
+ add_flag_status_map(const std::tr1::shared_ptr<Set<UnprefixedChoiceName> > result,
+ const FlagStatusMap & m, const std::string & prefix)
+ {
+ for (FlagStatusMap::const_iterator it(m.begin()),
+ it_end(m.end()); it_end != it; ++it)
+ if (0 == stringify(it->first).compare(0, prefix.length(), prefix))
+ result->insert(UnprefixedChoiceName(stringify(it->first).substr(prefix.length())));
+ }
+
+ void
+ add_package_flag_status_map_list(const std::tr1::shared_ptr<Set<UnprefixedChoiceName> > result,
+ const PackageFlagStatusMapList & m, const std::string & prefix)
+ {
+ for (PackageFlagStatusMapList::const_iterator it(m.begin()),
+ it_end(m.end()); it_end != it; ++it)
+ add_flag_status_map(result, it->second, prefix);
+ }
+}
+
std::tr1::shared_ptr<const Set<UnprefixedChoiceName> >
ERepositoryProfile::known_choice_value_names(
- const std::tr1::shared_ptr<const PackageID> &,
+ const std::tr1::shared_ptr<const ERepositoryID> & id,
const std::tr1::shared_ptr<const Choice> & choice
) const
{
+ Lock l(_imp->known_choice_value_names_for_separator_mutex);
+
+ char separator(id->eapi()->supported()->choices_options()->use_expand_separator());
+ std::tr1::unordered_map<char, KnownMap>::iterator it(_imp->known_choice_value_names_for_separator.find(separator));
+ if (_imp->known_choice_value_names_for_separator.end() == it)
+ it = _imp->known_choice_value_names_for_separator.insert(std::make_pair(separator, KnownMap())).first;
+
std::string lower_x;
std::transform(choice->raw_name().begin(), choice->raw_name().end(), std::back_inserter(lower_x), &::tolower);
- KnownMap::const_iterator i(_imp->known_choice_value_names.find(lower_x));
- if (_imp->known_choice_value_names.end() == i)
- throw InternalError(PALUDIS_HERE, lower_x);
- return i->second;
+ KnownMap::const_iterator it2(it->second.find(lower_x));
+ if (it->second.end() == it2)
+ {
+ std::tr1::shared_ptr<Set<UnprefixedChoiceName> > result(new Set<UnprefixedChoiceName>);
+ it2 = it->second.insert(std::make_pair(lower_x, result)).first;
+
+ KnownMap::const_iterator i(_imp->known_choice_value_names.find(lower_x));
+ if (_imp->known_choice_value_names.end() == i)
+ throw InternalError(PALUDIS_HERE, lower_x);
+ std::copy(i->second->begin(), i->second->end(), result->inserter());
+
+ std::string prefix(lower_x);
+ prefix += separator;
+
+ for (StackedValuesList::const_iterator sit(_imp->stacked_values_list.begin()),
+ sit_end(_imp->stacked_values_list.end()); sit_end != sit; ++sit)
+ {
+ add_flag_status_map(result, sit->use_mask, prefix);
+ add_flag_status_map(result, sit->use_force, prefix);
+ add_package_flag_status_map_list(result, sit->package_use, prefix);
+ add_package_flag_status_map_list(result, sit->package_use_mask, prefix);
+ add_package_flag_status_map_list(result, sit->package_use_force, prefix);
+ }
+ }
+
+ return it2->second;
}
std::string
diff --git a/paludis/repositories/e/e_repository_profile.hh b/paludis/repositories/e/e_repository_profile.hh
index d7d634e..b8336b8 100644
--- a/paludis/repositories/e/e_repository_profile.hh
+++ b/paludis/repositories/e/e_repository_profile.hh
@@ -35,6 +35,7 @@
#include <paludis/util/wrapped_forward_iterator-fwd.hh>
#include <paludis/util/mutex-fwd.hh>
#include <paludis/util/named_value.hh>
+#include <paludis/repositories/e/e_repository_id.hh>
#include <string>
/** \file
@@ -129,7 +130,7 @@ namespace paludis
) const PALUDIS_ATTRIBUTE((warn_unused_result));
std::tr1::shared_ptr<const Set<UnprefixedChoiceName> > known_choice_value_names(
- const std::tr1::shared_ptr<const PackageID> &,
+ const std::tr1::shared_ptr<const erepository::ERepositoryID> &,
const std::tr1::shared_ptr<const Choice> &
) const PALUDIS_ATTRIBUTE((warn_unused_result));