aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-09-22 04:23:09 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-09-22 04:23:09 +0000
commit3ef8b4de9b51e30c517202c7b6179c6b40dfa849 (patch)
tree75cfb3840f0e3a430893d240c0fc9c359fc4cf10
parent72f7f59679107e8e33266eb1b24d38d0481cd552 (diff)
downloadpaludis-3ef8b4de9b51e30c517202c7b6179c6b40dfa849.tar.gz
paludis-3ef8b4de9b51e30c517202c7b6179c6b40dfa849.tar.xz
New USE_EXPAND code
-rwxr-xr-xebuild/ebuild.bash6
-rw-r--r--paludis/default_environment.cc82
-rw-r--r--paludis/default_environment.hh4
-rw-r--r--paludis/environment.cc12
-rw-r--r--paludis/environment.hh10
-rw-r--r--paludis/qa/dep_flags_check.cc4
-rw-r--r--paludis/repositories/fake/fake_repository_base.cc35
-rw-r--r--paludis/repositories/fake/fake_repository_base.hh26
-rw-r--r--paludis/repositories/portage/portage_repository.cc137
-rw-r--r--paludis/repositories/portage/portage_repository.hh28
-rw-r--r--paludis/repositories/portage/portage_repository_ebin_entries.cc62
-rw-r--r--paludis/repositories/portage/portage_repository_ebuild_entries.cc77
-rw-r--r--paludis/repositories/vdb/vdb_repository.cc48
-rw-r--r--paludis/repositories/vdb/vdb_repository.hh26
-rw-r--r--paludis/repository.cc9
-rw-r--r--paludis/repository.hh50
-rw-r--r--paludis/test_environment.cc5
-rw-r--r--paludis/test_environment.hh3
-rw-r--r--paludis/util/collection.hh7
-rw-r--r--paludis/util/collection_concrete.hh11
-rw-r--r--src/paludis/use.cc23
21 files changed, 343 insertions, 322 deletions
diff --git a/ebuild/ebuild.bash b/ebuild/ebuild.bash
index 19a1734..11fde3a 100755
--- a/ebuild/ebuild.bash
+++ b/ebuild/ebuild.bash
@@ -112,7 +112,7 @@ ebuild_source_profile()
fi
}
-save_vars="USE USE_EXPAND"
+save_vars="USE USE_EXPAND ${USE_EXPAND} ${!USE_EXPAND}"
for var in ${save_vars} ; do
eval "export save_var_${var}='${!var}'"
@@ -137,8 +137,8 @@ for f in ${PALUDIS_BASHRC_FILES} ; do
fi
done
-for var in ${save_vars}; do
- if [[ -n ${!var} ]]; then
+for var in ${save_vars} ; do
+ if [[ -n ${!var} ]] ; then
die "${var} should not be set in bashrc. Aborting."
fi
done
diff --git a/paludis/default_environment.cc b/paludis/default_environment.cc
index 3e3b61e..ee2f523 100644
--- a/paludis/default_environment.cc
+++ b/paludis/default_environment.cc
@@ -300,67 +300,6 @@ DefaultEnvironment::paludis_command() const
return DefaultConfig::get_instance()->paludis_command();
}
-UseFlagNameCollection::Pointer
-DefaultEnvironment::query_enabled_use_matching(const std::string & prefix,
- const PackageDatabaseEntry * e) const
-{
- UseFlagNameCollection::Pointer result(new UseFlagNameCollection::Concrete);
-
- for (DefaultConfig::DefaultUseIterator
- u(DefaultConfig::get_instance()->begin_default_use()),
- u_end(DefaultConfig::get_instance()->end_default_use()) ;
- u != u_end ; ++u)
- {
- if (0 != u->first.data().compare(0, prefix.length(), prefix))
- continue;
-
- switch (u->second)
- {
- case use_enabled:
- result->insert(u->first);
- break;
-
- case use_disabled:
- result->erase(u->first);
- break;
-
- case use_unspecified:
- break;
- }
- }
-
- if (e)
- {
- for (DefaultConfig::UseConfigIterator
- u(DefaultConfig::get_instance()->begin_use_config(e->name)),
- u_end(DefaultConfig::get_instance()->end_use_config(e->name)) ;
- u != u_end ; ++u)
- {
- if (0 != u->flag_name.data().compare(0, prefix.length(), prefix))
- continue;
-
- if (! match_package(this, *u->dep_atom, *e))
- continue;
-
- switch (u->flag_state)
- {
- case use_enabled:
- result->insert(u->flag_name);
- break;
-
- case use_disabled:
- result->erase(u->flag_name);
- break;
-
- case use_unspecified:
- break;
- }
- }
- }
-
- return result;
-}
-
namespace
{
void add_one_hook(const std::string & base, std::list<FSEntry> & result)
@@ -546,3 +485,24 @@ DefaultEnvironment::end_mirrors(const std::string & mirror) const
return DefaultConfig::get_instance()->end_mirrors(mirror);
}
+UseFlagNameCollection::ConstPointer
+DefaultEnvironment::known_use_expand_names(const UseFlagName & prefix, const PackageDatabaseEntry * pde) const
+{
+ UseFlagNameCollection::Pointer result(new UseFlagNameCollection::Concrete);
+
+ std::string prefix_lower;
+ std::transform(prefix.data().begin(), prefix.data().end(), std::back_inserter(prefix_lower), &::tolower);
+ for (DefaultConfig::DefaultUseIterator i(DefaultConfig::get_instance()->begin_default_use()),
+ i_end(DefaultConfig::get_instance()->end_default_use()) ; i != i_end ; ++i)
+ if (0 == i->first.data().compare(0, prefix_lower.length(), prefix_lower, 0, prefix_lower.length()))
+ result->insert(i->first);
+
+ if (pde)
+ for (DefaultConfig::UseConfigIterator i(DefaultConfig::get_instance()->begin_use_config(pde->name)),
+ i_end(DefaultConfig::get_instance()->end_use_config(pde->name)) ; i != i_end ; ++i)
+ if (0 == i->flag_name.data().compare(0, prefix_lower.length(), prefix_lower, 0, prefix_lower.length()))
+ result->insert(i->flag_name);
+
+ return result;
+}
+
diff --git a/paludis/default_environment.hh b/paludis/default_environment.hh
index 37f0e0a..c1d416d 100644
--- a/paludis/default_environment.hh
+++ b/paludis/default_environment.hh
@@ -69,8 +69,8 @@ namespace paludis
virtual std::string paludis_command() const;
- virtual UseFlagNameCollection::Pointer query_enabled_use_matching(
- const std::string & prefix, const PackageDatabaseEntry *) const;
+ virtual UseFlagNameCollection::ConstPointer known_use_expand_names(const UseFlagName &,
+ const PackageDatabaseEntry *) const;
virtual void perform_hook(const Hook & hook) const;
diff --git a/paludis/environment.cc b/paludis/environment.cc
index 096f657..98927b6 100644
--- a/paludis/environment.cc
+++ b/paludis/environment.cc
@@ -404,12 +404,6 @@ Environment::query_use(const UseFlagName & f, const PackageDatabaseEntry * e) co
}
}
-UseFlagNameCollection::Pointer
-Environment::query_enabled_use_matching(const std::string &, const PackageDatabaseEntry *) const
-{
- return UseFlagNameCollection::Pointer(new UseFlagNameCollection::Concrete);
-}
-
bool
Environment::accept_keyword(const KeywordName & keyword, const PackageDatabaseEntry * const) const
{
@@ -472,3 +466,9 @@ Environment::perform_hook(const Hook &) const
{
}
+UseFlagNameCollection::ConstPointer
+Environment::known_use_expand_names(const UseFlagName &, const PackageDatabaseEntry *) const
+{
+ return UseFlagNameCollection::ConstPointer(new UseFlagNameCollection::Concrete);
+}
+
diff --git a/paludis/environment.hh b/paludis/environment.hh
index 8fd0549..1f0bd31 100644
--- a/paludis/environment.hh
+++ b/paludis/environment.hh
@@ -131,13 +131,13 @@ namespace paludis
virtual bool query_use(const UseFlagName &, const PackageDatabaseEntry *) const;
/**
- * Fetch a list of enabled USE flags that start with a given prefix,
- * for USE_EXPAND.
+ * Fetch any known use expand names (excluding prefix) that start with a
+ * given prefix.
*
- * Default behaviour: no USE flags.
+ * Default behaviour: no names known.
*/
- virtual UseFlagNameCollection::Pointer query_enabled_use_matching(
- const std::string & prefix, const PackageDatabaseEntry *) const;
+ virtual UseFlagNameCollection::ConstPointer known_use_expand_names(const UseFlagName &,
+ const PackageDatabaseEntry *) const;
/**
* Is the specified KEYWORD accepted?
diff --git a/paludis/qa/dep_flags_check.cc b/paludis/qa/dep_flags_check.cc
index 147b3be..04a34de 100644
--- a/paludis/qa/dep_flags_check.cc
+++ b/paludis/qa/dep_flags_check.cc
@@ -69,7 +69,7 @@ namespace
if (! r->use_interface)
throw InternalError(PALUDIS_HERE, "Confused: Repository does not have a UseInterface.");
- if (r->use_interface->is_arch_flag(u->flag()))
+ if (r->use_interface->arch_flags()->count(u->flag()))
{
if (role == "DEPEND" || role == "RDEPEND" || role == "PDEPEND")
{
@@ -81,7 +81,7 @@ namespace
result << Message(qal_major, "Arch flag '" + stringify(u->flag()) +
"' in " + role);
}
- else if (r->use_interface->is_expand_flag(u->flag()))
+ else if (r->use_interface->use_expand_flags()->count(u->flag()))
{
}
else if (iuse.end() == iuse.find(u->flag()))
diff --git a/paludis/repositories/fake/fake_repository_base.cc b/paludis/repositories/fake/fake_repository_base.cc
index 5415eac..efbec73 100644
--- a/paludis/repositories/fake/fake_repository_base.cc
+++ b/paludis/repositories/fake/fake_repository_base.cc
@@ -216,32 +216,43 @@ FakeRepositoryBase::do_arch_flags() const
}
bool
-FakeRepositoryBase::do_is_expand_flag(const UseFlagName &) const
+FakeRepositoryBase::do_is_licence(const std::string &) const
{
return false;
}
+void
+FakeRepositoryBase::invalidate() const
+{
+}
-bool
-FakeRepositoryBase::do_is_expand_hidden_flag(const UseFlagName &) const
+UseFlagNameCollection::ConstPointer
+FakeRepositoryBase::do_use_expand_flags() const
{
- return false;
+ return UseFlagNameCollection::ConstPointer(new UseFlagNameCollection::Concrete);
}
-std::string::size_type
-FakeRepositoryBase::do_expand_flag_delim_pos(const UseFlagName &) const
+UseFlagNameCollection::ConstPointer
+FakeRepositoryBase::do_use_expand_hidden_prefixes() const
{
- return 0;
+ return UseFlagNameCollection::ConstPointer(new UseFlagNameCollection::Concrete);
}
-bool
-FakeRepositoryBase::do_is_licence(const std::string &) const
+UseFlagNameCollection::ConstPointer
+FakeRepositoryBase::do_use_expand_prefixes() const
{
- return false;
+ return UseFlagNameCollection::ConstPointer(new UseFlagNameCollection::Concrete);
}
-void
-FakeRepositoryBase::invalidate() const
+UseFlagName
+FakeRepositoryBase::do_use_expand_name(const UseFlagName & u) const
+{
+ return u;
+}
+
+UseFlagName
+FakeRepositoryBase::do_use_expand_value(const UseFlagName & u) const
{
+ return u;
}
diff --git a/paludis/repositories/fake/fake_repository_base.hh b/paludis/repositories/fake/fake_repository_base.hh
index e80c9af..03e3a1f 100644
--- a/paludis/repositories/fake/fake_repository_base.hh
+++ b/paludis/repositories/fake/fake_repository_base.hh
@@ -46,6 +46,20 @@ namespace paludis
private PrivateImplementationPattern<FakeRepositoryBase>
{
protected:
+ /* RepositoryUseInterface */
+
+ virtual UseFlagState do_query_use(const UseFlagName &, const PackageDatabaseEntry *) const;
+ virtual bool do_query_use_mask(const UseFlagName &, const PackageDatabaseEntry *) const;
+ virtual bool do_query_use_force(const UseFlagName &, const PackageDatabaseEntry *) const;
+ virtual UseFlagNameCollection::ConstPointer do_arch_flags() const;
+ virtual UseFlagNameCollection::ConstPointer do_use_expand_flags() const;
+ virtual UseFlagNameCollection::ConstPointer do_use_expand_hidden_prefixes() const;
+ virtual UseFlagNameCollection::ConstPointer do_use_expand_prefixes() const;
+ virtual UseFlagName do_use_expand_name(const UseFlagName & u) const;
+ virtual UseFlagName do_use_expand_value(const UseFlagName & u) const;
+
+ /* end of RepositoryUseInterface */
+
virtual bool do_has_category_named(const CategoryNamePart &) const;
virtual bool do_has_package_named(const QualifiedPackageName &) const;
@@ -71,18 +85,6 @@ namespace paludis
virtual bool do_query_profile_masks(const QualifiedPackageName &,
const VersionSpec &) const;
- virtual UseFlagState do_query_use(const UseFlagName &, const PackageDatabaseEntry *) const;
-
- virtual bool do_query_use_mask(const UseFlagName &, const PackageDatabaseEntry *) const;
-
- virtual bool do_query_use_force(const UseFlagName &, const PackageDatabaseEntry *) const;
-
- virtual UseFlagNameCollection::ConstPointer do_arch_flags() const;
-
- virtual bool do_is_expand_flag(const UseFlagName &) const;
- virtual bool do_is_expand_hidden_flag(const UseFlagName &) const;
- virtual std::string::size_type do_expand_flag_delim_pos(const UseFlagName &) const;
-
virtual bool do_is_licence(const std::string &) const;
protected:
diff --git a/paludis/repositories/portage/portage_repository.cc b/paludis/repositories/portage/portage_repository.cc
index d073c6f..cb64483 100644
--- a/paludis/repositories/portage/portage_repository.cc
+++ b/paludis/repositories/portage/portage_repository.cc
@@ -619,55 +619,6 @@ PortageRepository::do_arch_flags() const
}
bool
-PortageRepository::do_is_expand_flag(const UseFlagName & u) const
-{
- _imp->need_profiles();
-
- for (PortageRepositoryProfile::UseExpandIterator i(_imp->profile_ptr->begin_use_expand()),
- i_end(_imp->profile_ptr->end_use_expand()) ; i != i_end ; ++i)
- if (0 == strncasecmp(
- stringify(u).c_str(),
- (stringify(*i) + "_").c_str(),
- stringify(*i).length() + 1))
- return true;
-
- return false;
-}
-
-bool
-PortageRepository::do_is_expand_hidden_flag(const UseFlagName & u) const
-{
- _imp->need_profiles();
-
- for (PortageRepositoryProfile::UseExpandIterator i(_imp->profile_ptr->begin_use_expand_hidden()),
- i_end(_imp->profile_ptr->end_use_expand_hidden()) ; i != i_end ; ++i)
- if (0 == strncasecmp(
- stringify(u).c_str(),
- (stringify(*i) + "_").c_str(),
- stringify(*i).length() + 1))
- return true;
-
- return false;
-}
-
-std::string::size_type
-PortageRepository::do_expand_flag_delim_pos(const UseFlagName & u) const
-{
- _imp->need_profiles();
-
- for (PortageRepositoryProfile::UseExpandIterator i(_imp->profile_ptr->begin_use_expand()),
- i_end(_imp->profile_ptr->end_use_expand()) ; i != i_end ; ++i)
- if (0 == strncasecmp(
- stringify(u).c_str(),
- (stringify(*i) + "_").c_str(),
- stringify(*i).length() + 1))
- return stringify(*i).length();
-
- throw InternalError(PALUDIS_HERE, "Use flag '" +
- stringify(u) + "' not an expand flag?");
-}
-
-bool
PortageRepository::do_is_licence(const std::string & s) const
{
FSEntry l(_imp->params.location);
@@ -931,3 +882,91 @@ PortageRepository::virtual_package_version_metadata(const RepositoryVirtualsEntr
}
+UseFlagNameCollection::ConstPointer
+PortageRepository::do_use_expand_flags() const
+{
+ _imp->need_profiles();
+
+ UseFlagNameCollection::Pointer result(new UseFlagNameCollection::Concrete);
+ for (PortageRepositoryProfile::UseExpandIterator i(_imp->profile_ptr->begin_use_expand()),
+ i_end(_imp->profile_ptr->end_use_expand()) ; i != i_end ; ++i)
+ {
+ std::list<std::string> values;
+ WhitespaceTokeniser::get_instance()->tokenise(_imp->profile_ptr->environment_variable(
+ stringify(*i)), std::back_inserter(values));
+ for (std::list<std::string>::const_iterator j(values.begin()), j_end(values.end()) ;
+ j != j_end ; ++j)
+ {
+ std::string f(stringify(*i) + "_" + *j), lower_f;
+ std::transform(f.begin(), f.end(), std::back_inserter(lower_f), &::tolower);
+ result->insert(UseFlagName(lower_f));
+ }
+ }
+
+ return result;
+}
+
+UseFlagNameCollection::ConstPointer
+PortageRepository::do_use_expand_prefixes() const
+{
+ _imp->need_profiles();
+
+ UseFlagNameCollection::Pointer result(new UseFlagNameCollection::Concrete);
+ for (PortageRepositoryProfile::UseExpandIterator i(_imp->profile_ptr->begin_use_expand()),
+ i_end(_imp->profile_ptr->end_use_expand()) ; i != i_end ; ++i)
+ {
+ std::string lower_i;
+ std::transform(i->data().begin(), i->data().end(), std::back_inserter(lower_i), &::tolower);
+ result->insert(UseFlagName(lower_i));
+ }
+
+ return result;
+}
+
+UseFlagNameCollection::ConstPointer
+PortageRepository::do_use_expand_hidden_prefixes() const
+{
+ _imp->need_profiles();
+
+ UseFlagNameCollection::Pointer result(new UseFlagNameCollection::Concrete);
+ for (PortageRepositoryProfile::UseExpandIterator i(_imp->profile_ptr->begin_use_expand_hidden()),
+ i_end(_imp->profile_ptr->end_use_expand_hidden()) ; i != i_end ; ++i)
+ {
+ std::string lower_i;
+ std::transform(i->data().begin(), i->data().end(), std::back_inserter(lower_i), &::tolower);
+ result->insert(UseFlagName(lower_i));
+ }
+
+ return result;
+}
+
+UseFlagName
+PortageRepository::do_use_expand_name(const UseFlagName & u) const
+{
+ for (PortageRepositoryProfile::UseExpandIterator i(_imp->profile_ptr->begin_use_expand()),
+ i_end(_imp->profile_ptr->end_use_expand()) ; i != i_end ; ++i)
+ {
+ std::string lower_i;
+ std::transform(i->data().begin(), i->data().end(), std::back_inserter(lower_i), ::tolower);
+ if (0 == lower_i.compare(0, lower_i.length(), stringify(u), 0, lower_i.length()))
+ return *i;
+ }
+
+ throw InternalError(PALUDIS_HERE, "Not a use expand name: '" + stringify(u) + "'");
+}
+
+UseFlagName
+PortageRepository::do_use_expand_value(const UseFlagName & u) const
+{
+ for (PortageRepositoryProfile::UseExpandIterator i(_imp->profile_ptr->begin_use_expand()),
+ i_end(_imp->profile_ptr->end_use_expand()) ; i != i_end ; ++i)
+ {
+ std::string lower_i;
+ std::transform(i->data().begin(), i->data().end(), std::back_inserter(lower_i), ::tolower);
+ if (0 == lower_i.compare(0, lower_i.length(), stringify(u), 0, lower_i.length()))
+ return UseFlagName(stringify(u).substr(lower_i.length() + 1));
+ }
+
+ throw InternalError(PALUDIS_HERE, "Not a use expand name: '" + stringify(u) + "'");
+}
+
diff --git a/paludis/repositories/portage/portage_repository.hh b/paludis/repositories/portage/portage_repository.hh
index f283abc..153bd15 100644
--- a/paludis/repositories/portage/portage_repository.hh
+++ b/paludis/repositories/portage/portage_repository.hh
@@ -94,20 +94,6 @@ namespace paludis
virtual bool do_query_profile_masks(const QualifiedPackageName &,
const VersionSpec &) const;
- virtual UseFlagState do_query_use(const UseFlagName &, const PackageDatabaseEntry *) const;
-
- virtual bool do_query_use_mask(const UseFlagName &, const PackageDatabaseEntry *) const;
-
- virtual bool do_query_use_force(const UseFlagName &, const PackageDatabaseEntry *) const;
-
- virtual UseFlagNameCollection::ConstPointer do_arch_flags() const;
-
- virtual bool do_is_expand_flag(const UseFlagName &) const;
-
- virtual bool do_is_expand_hidden_flag(const UseFlagName &) const;
-
- virtual std::string::size_type do_expand_flag_delim_pos(const UseFlagName &) const;
-
virtual bool do_is_licence(const std::string &) const;
virtual void do_install(const QualifiedPackageName &, const VersionSpec &,
@@ -122,6 +108,20 @@ namespace paludis
virtual VersionMetadata::ConstPointer virtual_package_version_metadata(
const RepositoryVirtualsEntry &, const VersionSpec & v) const;
+ /* RepositoryUseInterface */
+
+ virtual UseFlagState do_query_use(const UseFlagName &, const PackageDatabaseEntry *) const;
+ virtual bool do_query_use_mask(const UseFlagName &, const PackageDatabaseEntry *) const;
+ virtual bool do_query_use_force(const UseFlagName &, const PackageDatabaseEntry *) const;
+ virtual UseFlagNameCollection::ConstPointer do_arch_flags() const;
+ virtual UseFlagNameCollection::ConstPointer do_use_expand_flags() const;
+ virtual UseFlagNameCollection::ConstPointer do_use_expand_hidden_prefixes() const;
+ virtual UseFlagName do_use_expand_name(const UseFlagName & u) const;
+ virtual UseFlagName do_use_expand_value(const UseFlagName & u) const;
+ virtual UseFlagNameCollection::ConstPointer do_use_expand_prefixes() const;
+
+ /* end of RepositoryUseInterface */
+
public:
virtual RepositoryInfo::ConstPointer info(bool verbose) const;
diff --git a/paludis/repositories/portage/portage_repository_ebin_entries.cc b/paludis/repositories/portage/portage_repository_ebin_entries.cc
index 5137c58..3489abd 100644
--- a/paludis/repositories/portage/portage_repository_ebin_entries.cc
+++ b/paludis/repositories/portage/portage_repository_ebin_entries.cc
@@ -222,46 +222,46 @@ PortageRepositoryEbinEntries::install(const QualifiedPackageName & q, const Vers
}
use += p->environment_variable("ARCH") + " ";
+
+ /* add expand to use (iuse isn't reliable for use_expand things), and make the expand
+ * environment variables */
+ AssociativeCollection<std::string, std::string>::Pointer expand_vars(
+ new AssociativeCollection<std::string, std::string>::Concrete);
for (PortageRepositoryProfile::UseExpandIterator x(p->begin_use_expand()),
x_end(p->end_use_expand()) ; x != x_end ; ++x)
{
std::string lower_x;
- std::transform(x->data().begin(), x->data().end(), std::back_inserter(lower_x),
- &::tolower);
+ std::transform(x->data().begin(), x->data().end(), std::back_inserter(lower_x), &::tolower);
- std::list<std::string> uses;
- WhitespaceTokeniser::get_instance()->tokenise(
- p->environment_variable(stringify(*x)),
- std::back_inserter(uses));
+ /* possible values from profile */
+ std::set<UseFlagName> possible_values;
+ WhitespaceTokeniser::get_instance()->tokenise(p->environment_variable(stringify(*x)),
+ create_inserter<UseFlagName>(std::inserter(possible_values, possible_values.end())));
- for (std::list<std::string>::const_iterator u(uses.begin()), u_end(uses.end()) ;
+ /* possible values from environment */
+ UseFlagNameCollection::ConstPointer possible_values_from_env(_imp->params.environment->
+ known_use_expand_names(*x, &e));
+ std::copy(possible_values_from_env->begin(), possible_values_from_env->end(),
+ std::inserter(possible_values, possible_values.end()));
+
+ for (std::set<UseFlagName>::const_iterator u(possible_values.begin()), u_end(possible_values.end()) ;
u != u_end ; ++u)
- use += lower_x + "_" + *u + " ";
+ {
+ if (! _imp->params.environment->query_use(UseFlagName(lower_x + "_" + stringify(*u)), &e))
+ continue;
- UseFlagNameCollection::Pointer u(_imp->params.environment->query_enabled_use_matching(
- lower_x + "_", &e));
- for (UseFlagNameCollection::Iterator uu(u->begin()), uu_end(u->end()) ;
- uu != uu_end ; ++uu)
- use += stringify(*uu) + " ";
- }
+ use.append(lower_x + "_" + stringify(*u) + " ");
- AssociativeCollection<std::string, std::string>::Pointer expand_vars(
- new AssociativeCollection<std::string, std::string>::Concrete);
- for (PortageRepositoryProfile::UseExpandIterator
- u(p->begin_use_expand()), u_end(p->end_use_expand()) ; u != u_end ; ++u)
- {
- std::string prefix;
- std::transform(u->data().begin(), u->data().end(), std::back_inserter(prefix),
- &::tolower);
- prefix.append("_");
-
- UseFlagNameCollection::Pointer x(_imp->params.environment->query_enabled_use_matching(prefix, &e));
- std::string value;
- for (UseFlagNameCollection::Iterator xx(x->begin()), xx_end(x->end()) ;
- xx != xx_end ; ++xx)
- value.append(stringify(*xx).erase(0, stringify(*u).length() + 1) + " ");
-
- expand_vars->insert(stringify(*u), value);
+ std::string value;
+ AssociativeCollection<std::string, std::string>::Iterator i(expand_vars->find(stringify(*x)));
+ if (expand_vars->end() != i)
+ {
+ value = i->second + " ";
+ expand_vars->erase(i);
+ }
+ value.append(stringify(*u));
+ expand_vars->insert(stringify(*x), value);
+ }
}
binaries = strip_trailing(binaries, " ");
diff --git a/paludis/repositories/portage/portage_repository_ebuild_entries.cc b/paludis/repositories/portage/portage_repository_ebuild_entries.cc
index 60d1628..50a9375 100644
--- a/paludis/repositories/portage/portage_repository_ebuild_entries.cc
+++ b/paludis/repositories/portage/portage_repository_ebuild_entries.cc
@@ -384,6 +384,14 @@ PortageRepositoryEbuildEntries::install(const QualifiedPackageName & q, const Ve
}
}
+ /* Strip trailing space. Some ebuilds rely upon this. From kde-meta.eclass:
+ * [[ -n ${A/${TARBALL}/} ]] && unpack ${A/${TARBALL}/}
+ * Rather annoying.
+ */
+ archives = strip_trailing(archives, " ");
+ all_archives = strip_trailing(all_archives, " ");
+
+ /* make use */
std::string use;
{
std::set<UseFlagName> iuse;
@@ -396,55 +404,48 @@ PortageRepositoryEbuildEntries::install(const QualifiedPackageName & q, const Ve
}
use += p->environment_variable("ARCH") + " ";
+
+ /* add expand to use (iuse isn't reliable for use_expand things), and make the expand
+ * environment variables */
+ AssociativeCollection<std::string, std::string>::Pointer expand_vars(
+ new AssociativeCollection<std::string, std::string>::Concrete);
for (PortageRepositoryProfile::UseExpandIterator x(p->begin_use_expand()),
x_end(p->end_use_expand()) ; x != x_end ; ++x)
{
std::string lower_x;
- std::transform(x->data().begin(), x->data().end(), std::back_inserter(lower_x),
- &::tolower);
+ std::transform(x->data().begin(), x->data().end(), std::back_inserter(lower_x), &::tolower);
- std::list<std::string> uses;
- WhitespaceTokeniser::get_instance()->tokenise(
- p->environment_variable(stringify(*x)),
- std::back_inserter(uses));
+ /* possible values from profile */
+ std::set<UseFlagName> possible_values;
+ WhitespaceTokeniser::get_instance()->tokenise(p->environment_variable(stringify(*x)),
+ create_inserter<UseFlagName>(std::inserter(possible_values, possible_values.end())));
- for (std::list<std::string>::const_iterator u(uses.begin()), u_end(uses.end()) ;
+ /* possible values from environment */
+ UseFlagNameCollection::ConstPointer possible_values_from_env(_imp->params.environment->
+ known_use_expand_names(*x, &e));
+ std::copy(possible_values_from_env->begin(), possible_values_from_env->end(),
+ std::inserter(possible_values, possible_values.end()));
+
+ for (std::set<UseFlagName>::const_iterator u(possible_values.begin()), u_end(possible_values.end()) ;
u != u_end ; ++u)
- use += lower_x + "_" + *u + " ";
+ {
+ if (! _imp->params.environment->query_use(UseFlagName(lower_x + "_" + stringify(*u)), &e))
+ continue;
- UseFlagNameCollection::Pointer u(_imp->params.environment->query_enabled_use_matching(
- lower_x + "_", &e));
- for (UseFlagNameCollection::Iterator uu(u->begin()), uu_end(u->end()) ;
- uu != uu_end ; ++uu)
- use += stringify(*uu) + " ";
- }
+ use.append(lower_x + "_" + stringify(*u) + " ");
- AssociativeCollection<std::string, std::string>::Pointer expand_vars(
- new AssociativeCollection<std::string, std::string>::Concrete);
- for (PortageRepositoryProfile::UseExpandIterator
- u(p->begin_use_expand()), u_end(p->end_use_expand()) ; u != u_end ; ++u)
- {
- std::string prefix;
- std::transform(u->data().begin(), u->data().end(), std::back_inserter(prefix),
- &::tolower);
- prefix.append("_");
-
- UseFlagNameCollection::Pointer x(_imp->params.environment->query_enabled_use_matching(prefix, &e));
- std::string value;
- for (UseFlagNameCollection::Iterator xx(x->begin()), xx_end(x->end()) ;
- xx != xx_end ; ++xx)
- value.append(stringify(*xx).erase(0, stringify(*u).length() + 1) + " ");
-
- expand_vars->insert(stringify(*u), value);
+ std::string value;
+ AssociativeCollection<std::string, std::string>::Iterator i(expand_vars->find(stringify(*x)));
+ if (expand_vars->end() != i)
+ {
+ value = i->second + " ";
+ expand_vars->erase(i);
+ }
+ value.append(stringify(*u));
+ expand_vars->insert(stringify(*x), value);
+ }
}
- /* Strip trailing space. Some ebuilds rely upon this. From kde-meta.eclass:
- * [[ -n ${A/${TARBALL}/} ]] && unpack ${A/${TARBALL}/}
- * Rather annoying.
- */
- archives = strip_trailing(archives, " ");
- all_archives = strip_trailing(all_archives, " ");
-
EbuildFetchCommand fetch_cmd(EbuildCommandParams::create()
.environment(_imp->params.environment)
.db_entry(&e)
diff --git a/paludis/repositories/vdb/vdb_repository.cc b/paludis/repositories/vdb/vdb_repository.cc
index 24ebab9..63b7d28 100644
--- a/paludis/repositories/vdb/vdb_repository.cc
+++ b/paludis/repositories/vdb/vdb_repository.cc
@@ -767,24 +767,6 @@ VDBRepositoryKeyReadError::VDBRepositoryKeyReadError(
}
bool
-VDBRepository::do_is_expand_flag(const UseFlagName &) const
-{
- return false;
-}
-
-bool
-VDBRepository::do_is_expand_hidden_flag(const UseFlagName &) const
-{
- return false;
-}
-
-std::string::size_type
-VDBRepository::do_expand_flag_delim_pos(const UseFlagName &) const
-{
- return 0;
-}
-
-bool
VDBRepository::do_is_licence(const std::string &) const
{
return false;
@@ -1137,3 +1119,33 @@ VDBRepository::do_arch_flags() const
return UseFlagNameCollection::ConstPointer(new UseFlagNameCollection::Concrete);
}
+UseFlagNameCollection::ConstPointer
+VDBRepository::do_use_expand_flags() const
+{
+ return UseFlagNameCollection::ConstPointer(new UseFlagNameCollection::Concrete);
+}
+
+UseFlagNameCollection::ConstPointer
+VDBRepository::do_use_expand_prefixes() const
+{
+ return UseFlagNameCollection::ConstPointer(new UseFlagNameCollection::Concrete);
+}
+
+UseFlagNameCollection::ConstPointer
+VDBRepository::do_use_expand_hidden_prefixes() const
+{
+ return UseFlagNameCollection::ConstPointer(new UseFlagNameCollection::Concrete);
+}
+
+UseFlagName
+VDBRepository::do_use_expand_name(const UseFlagName & u) const
+{
+ return u;
+}
+
+UseFlagName
+VDBRepository::do_use_expand_value(const UseFlagName & u) const
+{
+ return u;
+}
+
diff --git a/paludis/repositories/vdb/vdb_repository.hh b/paludis/repositories/vdb/vdb_repository.hh
index 970a8da..6b35463 100644
--- a/paludis/repositories/vdb/vdb_repository.hh
+++ b/paludis/repositories/vdb/vdb_repository.hh
@@ -78,18 +78,6 @@ namespace paludis
const QualifiedPackageName &,
const VersionSpec &) const;
- virtual UseFlagState do_query_use(const UseFlagName &, const PackageDatabaseEntry *) const;
-
- virtual bool do_query_use_mask(const UseFlagName &, const PackageDatabaseEntry *) const;
-
- virtual bool do_query_use_force(const UseFlagName &, const PackageDatabaseEntry *) const;
-
- virtual UseFlagNameCollection::ConstPointer do_arch_flags() const;
-
- virtual bool do_is_expand_flag(const UseFlagName &) const;
- virtual bool do_is_expand_hidden_flag(const UseFlagName &) const;
- virtual std::string::size_type do_expand_flag_delim_pos(const UseFlagName &) const;
-
virtual bool do_is_licence(const std::string &) const;
virtual void do_uninstall(const QualifiedPackageName &, const VersionSpec &,
@@ -97,6 +85,20 @@ namespace paludis
virtual DepAtom::Pointer do_package_set(const std::string &, const PackageSetOptions & o) const;
+ /* RepositoryUseInterface */
+
+ virtual UseFlagState do_query_use(const UseFlagName &, const PackageDatabaseEntry *) const;
+ virtual bool do_query_use_mask(const UseFlagName &, const PackageDatabaseEntry *) const;
+ virtual bool do_query_use_force(const UseFlagName &, const PackageDatabaseEntry *) const;
+ virtual UseFlagNameCollection::ConstPointer do_arch_flags() const;
+ virtual UseFlagNameCollection::ConstPointer do_use_expand_flags() const;
+ virtual UseFlagNameCollection::ConstPointer do_use_expand_hidden_prefixes() const;
+ virtual UseFlagName do_use_expand_name(const UseFlagName & u) const;
+ virtual UseFlagName do_use_expand_value(const UseFlagName & u) const;
+ virtual UseFlagNameCollection::ConstPointer do_use_expand_prefixes() const;
+
+ /* end of RepositoryUseInterface */
+
public:
/**
* Constructor.
diff --git a/paludis/repository.cc b/paludis/repository.cc
index 54a2436..23d293b 100644
--- a/paludis/repository.cc
+++ b/paludis/repository.cc
@@ -179,12 +179,3 @@ RepositoryInfo::end_sections() const
return SectionIterator(_imp->sections.end());
}
-UseFlagName
-RepositoryUseInterface::expand_flag_name(const UseFlagName & u) const
-{
- std::string upper_u;
- std::transform(u.data().begin(), u.data().end(), std::back_inserter(upper_u),
- &::toupper);
- return UseFlagName(upper_u.substr(0, do_expand_flag_delim_pos(u)));
-}
-
diff --git a/paludis/repository.hh b/paludis/repository.hh
index 7d67f6e..754c82a 100644
--- a/paludis/repository.hh
+++ b/paludis/repository.hh
@@ -387,22 +387,19 @@ namespace paludis
virtual UseFlagNameCollection::ConstPointer do_arch_flags() const = 0;
/**
- * Override in descendents: is this an expand flag?
+ * Override in descendents: fetch all use expand flags.
*/
- virtual bool do_is_expand_flag(const UseFlagName &) const = 0;
+ virtual UseFlagNameCollection::ConstPointer do_use_expand_flags() const = 0;
/**
- * Override in descendents: is this an expand flag that should be
- * ignored?
+ * Override in descendents: fetch all use expand hidden prefixes.
*/
- virtual bool do_is_expand_hidden_flag(const UseFlagName &) const = 0;
+ virtual UseFlagNameCollection::ConstPointer do_use_expand_hidden_prefixes() const = 0;
/**
- * Override in descendents: for a UseFlagName where is_expand_flag
- * is true, return the position of the delimiting underscore that
- * splits name and value.
+ * Override in descendents: fetch all use expand prefixes.
*/
- virtual std::string::size_type do_expand_flag_delim_pos(const UseFlagName &) const = 0;
+ virtual UseFlagNameCollection::ConstPointer do_use_expand_prefixes() const = 0;
public:
/**
@@ -435,15 +432,6 @@ namespace paludis
}
/**
- * Query whether the specified use flag is an arch flag.
- */
- bool is_arch_flag(const UseFlagName & u) const
- {
- UseFlagNameCollection::ConstPointer uu(do_arch_flags());
- return uu->end() != uu->find(u);
- }
-
- /**
* Fetch all arch flags.
*/
UseFlagNameCollection::ConstPointer arch_flags() const
@@ -452,35 +440,27 @@ namespace paludis
}
/**
- * Query whether the specified use flag is an expand flag.
+ * Fetch all expand flags.
*/
- bool is_expand_flag(const UseFlagName & u) const
+ UseFlagNameCollection::ConstPointer use_expand_flags() const
{
- return do_is_expand_flag(u);
+ return do_use_expand_flags();
}
/**
- * Query whether the specified use flag is an expand flag that
- * is ignored in visible output.
+ * Fetch all expand hidden flags.
*/
- bool is_expand_hidden_flag(const UseFlagName & u) const
+ UseFlagNameCollection::ConstPointer use_expand_hidden_prefixes() const
{
- return do_is_expand_hidden_flag(u);
+ return do_use_expand_hidden_prefixes();
}
/**
- * Fetch the expand flag name for a given use flag where
- * is_expand_flag returns true.
- */
- UseFlagName expand_flag_name(const UseFlagName & u) const;
-
- /**
- * Fetch the expand flag value for a given use flag where
- * is_expand_flag returns true.
+ * Fetch all use expand prefixes.
*/
- UseFlagName expand_flag_value(const UseFlagName & u) const
+ UseFlagNameCollection::ConstPointer use_expand_prefixes() const
{
- return UseFlagName(stringify(u).substr(do_expand_flag_delim_pos(u) + 1));
+ return do_use_expand_prefixes();
}
virtual ~RepositoryUseInterface() { }
diff --git a/paludis/test_environment.cc b/paludis/test_environment.cc
index daa4b91..496ab34 100644
--- a/paludis/test_environment.cc
+++ b/paludis/test_environment.cc
@@ -82,9 +82,4 @@ TestEnvironment::end_mirrors(const std::string &) const
return MirrorIterator(test_environment_mirrors.end());
}
-UseFlagNameCollection::Pointer
-TestEnvironment::query_enabled_use_matching(const std::string &, const PackageDatabaseEntry *) const
-{
- return UseFlagNameCollection::Pointer(new UseFlagNameCollection::Concrete);
-}
diff --git a/paludis/test_environment.hh b/paludis/test_environment.hh
index de02844..586aa10 100644
--- a/paludis/test_environment.hh
+++ b/paludis/test_environment.hh
@@ -71,9 +71,6 @@ namespace paludis
return "false";
}
- virtual UseFlagNameCollection::Pointer query_enabled_use_matching(
- const std::string &, const PackageDatabaseEntry *) const;
-
virtual void perform_hook(const Hook &) const
{
}
diff --git a/paludis/util/collection.hh b/paludis/util/collection.hh
index 0c702d3..0980f7d 100644
--- a/paludis/util/collection.hh
+++ b/paludis/util/collection.hh
@@ -189,6 +189,8 @@ namespace paludis
virtual Iterator find(const T_ & v) const = 0;
+ virtual int count(const T_ & v) const = 0;
+
///\}
///\name Adding, removing and modifying items
@@ -307,6 +309,11 @@ namespace paludis
*/
virtual bool erase(const K_ & k) = 0;
+ /**
+ * Erase an item, return whether we succeeded.
+ */
+ virtual bool erase(const Iterator & i) = 0;
+
///\}
///\name Queries
diff --git a/paludis/util/collection_concrete.hh b/paludis/util/collection_concrete.hh
index a19b226..4124cbe 100644
--- a/paludis/util/collection_concrete.hh
+++ b/paludis/util/collection_concrete.hh
@@ -166,6 +166,11 @@ namespace paludis
return Iterator(_items.find(v));
}
+ virtual int count(const T_ & v) const
+ {
+ return _items.count(v);
+ }
+
virtual bool insert(const T_ & v)
{
return _items.insert(v).second;
@@ -259,6 +264,12 @@ namespace paludis
return 0 != _items.erase(k);
}
+ virtual bool erase(const Iterator & i)
+ {
+ _items.erase(i->first);
+ return true;
+ }
+
virtual bool empty() const
{
return _items.empty();
diff --git a/src/paludis/use.cc b/src/paludis/use.cc
index 144b35c..3e41179 100644
--- a/src/paludis/use.cc
+++ b/src/paludis/use.cc
@@ -25,6 +25,18 @@
using namespace paludis;
+namespace
+{
+ std::string::size_type
+ use_expand_delim_pos(const UseFlagName & u, const UseFlagNameCollection::ConstPointer c)
+ {
+ for (UseFlagNameCollection::Iterator i(c->begin()), i_end(c->end()) ; i != i_end ; ++i)
+ if (0 == u.data().compare(0, i->data().length(), i->data(), 0, i->data().length()))
+ return i->data().length();
+ return std::string::npos;
+ }
+}
+
std::string
make_pretty_use_flags_string(const Environment * const env, const PackageDatabaseEntry & p,
VersionMetadata::ConstPointer metadata)
@@ -45,7 +57,7 @@ make_pretty_use_flags_string(const Environment * const env, const PackageDatabas
for (std::set<UseFlagName>::const_iterator i(iuse.begin()), i_end(iuse.end()) ;
i != i_end ; ++i)
{
- if (use_interface->is_expand_flag(*i))
+ if (std::string::npos != use_expand_delim_pos(*i, use_interface->use_expand_prefixes()))
continue;
if (env->query_use(*i, &p))
@@ -69,12 +81,13 @@ make_pretty_use_flags_string(const Environment * const env, const PackageDatabas
for (std::set<UseFlagName>::const_iterator i(iuse.begin()), i_end(iuse.end()) ;
i != i_end ; ++i)
{
- if ((! use_interface->is_expand_flag(*i)) ||
- (use_interface->is_expand_hidden_flag(*i)))
+ std::string::size_type delim_pos;
+ if (std::string::npos == ((delim_pos = use_expand_delim_pos(*i, use_interface->use_expand_prefixes()))))
+ continue;
+ if (use_interface->use_expand_hidden_prefixes()->count(UseFlagName(i->data().substr(0, delim_pos))))
continue;
- UseFlagName expand_name(use_interface->expand_flag_name(*i)),
- expand_value(use_interface->expand_flag_value(*i));
+ UseFlagName expand_name(i->data().substr(0, delim_pos)), expand_value(i->data().substr(delim_pos + 1));
if (expand_name != old_expand_name)
{