aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-04-14 15:08:25 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-04-14 15:08:25 +0000
commite5bed44d14211b3bacdd50aeddff7c9dc8c25bc6 (patch)
treedf6b44d84466259e25a6af10b7b5de49f85e6173
parente3f0cb7da5a2e6313a523a47d2d0956df0fe0e48 (diff)
downloadpaludis-e5bed44d14211b3bacdd50aeddff7c9dc8c25bc6.tar.gz
paludis-e5bed44d14211b3bacdd50aeddff7c9dc8c25bc6.tar.xz
Create USE_EXPAND variable values and pass them to ebuild. Currently this relies upon USERLAND etc being overridden in ebuild.bash's ebuild_source_profile, so we can't do expand var checking with save_vars
-rw-r--r--paludis/default_environment.cc68
-rw-r--r--paludis/default_environment.hh3
-rw-r--r--paludis/environment.hh7
-rw-r--r--paludis/name.hh2
-rw-r--r--paludis/portage_repository.cc18
-rw-r--r--paludis/qa/environment.hh6
-rw-r--r--paludis/test_environment.hh6
7 files changed, 102 insertions, 8 deletions
diff --git a/paludis/default_environment.cc b/paludis/default_environment.cc
index c80f1af..02dc885 100644
--- a/paludis/default_environment.cc
+++ b/paludis/default_environment.cc
@@ -48,13 +48,6 @@ DefaultEnvironment::~DefaultEnvironment()
bool
DefaultEnvironment::query_use(const UseFlagName & f, const PackageDatabaseEntry * e) const
{
- std::string env_use = " " + getenv_with_default("USE", "") + " ";
-
- if (env_use.find(" " + f.data() + " ") != std::string::npos)
- return true;
- else if (env_use.find(" -" + f.data() + " ") != std::string::npos)
- return false;
-
if (e)
{
UseFlagState s(use_unspecified);
@@ -258,3 +251,64 @@ 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);
+
+ 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->get<pde_name>())),
+ u_end(DefaultConfig::get_instance()->end_use_config(e->get<pde_name>())) ;
+ u != u_end ; ++u)
+ {
+ if (0 != u->get<uce_flag_name>().data().compare(0, prefix.length(), prefix))
+ continue;
+
+ if (! match_package(package_database(), *u->get<uce_dep_atom>(), *e))
+ continue;
+
+ switch (u->get<uce_flag_state>())
+ {
+ case use_enabled:
+ result->insert(u->get<uce_flag_name>());
+ break;
+
+ case use_disabled:
+ result->erase(u->get<uce_flag_name>());
+ break;
+
+ case use_unspecified:
+ break;
+ }
+ }
+ }
+
+ return result;
+}
+
diff --git a/paludis/default_environment.hh b/paludis/default_environment.hh
index f9e1343..b4a7ecc 100644
--- a/paludis/default_environment.hh
+++ b/paludis/default_environment.hh
@@ -62,6 +62,9 @@ namespace paludis
virtual std::string bashrc_files() const;
virtual std::string paludis_command() const;
+
+ virtual UseFlagNameCollection::Pointer query_enabled_use_matching(
+ const std::string & prefix, const PackageDatabaseEntry *) const;
};
}
#endif
diff --git a/paludis/environment.hh b/paludis/environment.hh
index c16c84d..6f2502b 100644
--- a/paludis/environment.hh
+++ b/paludis/environment.hh
@@ -65,6 +65,13 @@ namespace paludis
virtual bool query_use(const UseFlagName &, const PackageDatabaseEntry *) const = 0;
/**
+ * Fetch a list of enabled USE flags that start with a given prefix,
+ * for USE_EXPAND.
+ */
+ virtual UseFlagNameCollection::Pointer query_enabled_use_matching(
+ const std::string & prefix, const PackageDatabaseEntry *) const = 0;
+
+ /**
* Is the specified KEYWORD accepted?
*/
virtual bool accept_keyword(const KeywordName &, const PackageDatabaseEntry * const) const = 0;
diff --git a/paludis/name.hh b/paludis/name.hh
index b6c7238..370b63d 100644
--- a/paludis/name.hh
+++ b/paludis/name.hh
@@ -264,6 +264,8 @@ namespace paludis
*/
typedef Validated<std::string, UseFlagNameValidator> UseFlagName;
+ typedef SortedCollection<UseFlagName> UseFlagNameCollection;
+
/**
* A SlotNameError is thrown if an invalid value is assigned to
* a SlotName.
diff --git a/paludis/portage_repository.cc b/paludis/portage_repository.cc
index cef2917..9056a33 100644
--- a/paludis/portage_repository.cc
+++ b/paludis/portage_repository.cc
@@ -1214,7 +1214,7 @@ PortageRepository::do_install(const QualifiedPackageName & q, const VersionSpec
}
}
- std::string cmd(make_env_command(
+ MakeEnvCommand cmd(make_env_command(
getenv_with_default("PALUDIS_EBUILD_DIR", LIBEXECDIR "/paludis") +
"/ebuild.bash '" +
stringify(_imp->location) + "/" +
@@ -1248,6 +1248,22 @@ PortageRepository::do_install(const QualifiedPackageName & q, const VersionSpec
("PALUDIS_EBUILD_LOG_LEVEL", Log::get_instance()->log_level_string())
("PALUDIS_EBUILD_DIR", getenv_with_default("PALUDIS_EBUILD_DIR", LIBEXECDIR "/paludis")));
+ for (UseFlagSet::const_iterator u(_imp->expand_list.begin()),
+ u_end(_imp->expand_list.end()) ; 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->env->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) + " ");
+ cmd = cmd(stringify(*u), value);
+ }
+
if (0 != run_command(cmd))
throw PackageInstallActionError("Can't install '" + stringify(q) + "-"
+ stringify(v) + "'");
diff --git a/paludis/qa/environment.hh b/paludis/qa/environment.hh
index 28e7ac1..77b29c7 100644
--- a/paludis/qa/environment.hh
+++ b/paludis/qa/environment.hh
@@ -67,6 +67,12 @@ namespace paludis
{
throw InternalError(PALUDIS_HERE, "Cannot use paludis_command in a QA environment");
}
+
+ virtual UseFlagNameCollection::Pointer query_enabled_use_matching(
+ const std::string &, const PackageDatabaseEntry *) const
+ {
+ return UseFlagNameCollection::Pointer(new UseFlagNameCollection);
+ }
};
}
}
diff --git a/paludis/test_environment.hh b/paludis/test_environment.hh
index 50007d0..9de4ae1 100644
--- a/paludis/test_environment.hh
+++ b/paludis/test_environment.hh
@@ -57,6 +57,12 @@ namespace paludis
{
return "false";
}
+
+ virtual UseFlagNameCollection::Pointer query_enabled_use_matching(
+ const std::string &, const PackageDatabaseEntry *) const
+ {
+ return UseFlagNameCollection::Pointer(new UseFlagNameCollection);
+ }
};
}