aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar David Leverton <levertond@googlemail.com> 2009-02-22 17:58:51 +0000
committerAvatar David Leverton <levertond@googlemail.com> 2009-02-22 21:20:29 +0000
commitc2c85dbb5cdc66a7503f58d2545c457968a0c10e (patch)
tree51d5f0923dd692855eb8735cf9ca9e4b81bf38bc
parentdff81f47d93e2611267a60d177fbcbca9dc33092 (diff)
downloadpaludis-c2c85dbb5cdc66a7503f58d2545c457968a0c10e.tar.gz
paludis-c2c85dbb5cdc66a7503f58d2545c457968a0c10e.tar.xz
Probably break everything
-rw-r--r--paludis/repositories/e/e_installed_repository.cc2
-rw-r--r--paludis/repositories/e/eapis/0.conf16
-rw-r--r--paludis/repositories/e/eapis/2.conf18
-rw-r--r--paludis/repositories/e/eapis/exheres-0.conf20
-rw-r--r--paludis/repositories/e/eapis/kdebuild-1.conf14
-rw-r--r--paludis/repositories/e/eapis/paludis-1.conf16
-rw-r--r--paludis/repositories/e/eapis/pbin-1+0.conf8
-rw-r--r--paludis/repositories/e/eapis/pbin-1+1.conf8
-rw-r--r--paludis/repositories/e/eapis/pbin-1+exheres-0.conf8
-rw-r--r--paludis/repositories/e/eapis/pbin-1+paludis-1.conf8
-rw-r--r--paludis/repositories/e/ebuild.cc3
-rw-r--r--paludis/repositories/e/ebuild.hh2
-rw-r--r--paludis/repositories/e/ebuild/0/builtin_init.bash15
-rw-r--r--paludis/repositories/e/ebuild/0/builtin_initmisc.bash17
-rw-r--r--paludis/repositories/e/ebuild/0/builtin_metadata.bash2
-rwxr-xr-xpaludis/repositories/e/ebuild/ebuild.bash269
-rw-r--r--paludis/repositories/e/ebuild/exheres-0/builtin_init.bash15
-rw-r--r--paludis/repositories/e/ebuild/exheres-0/builtin_initmisc.bash17
-rw-r--r--paludis/repositories/e/ebuild/exheres-0/builtin_metadata.bash2
-rw-r--r--paludis/repositories/e/ebuild_entries.cc6
-rw-r--r--paludis/repositories/e/ebuild_id.cc1
-rw-r--r--paludis/repositories/e/exndbam_repository.cc1
-rw-r--r--paludis/repositories/e/vdb_repository.cc1
-rw-r--r--paludis/util/system.cc36
-rw-r--r--paludis/util/system.hh15
25 files changed, 306 insertions, 214 deletions
diff --git a/paludis/repositories/e/e_installed_repository.cc b/paludis/repositories/e/e_installed_repository.cc
index 4c022d1..2a3328e 100644
--- a/paludis/repositories/e/e_installed_repository.cc
+++ b/paludis/repositories/e/e_installed_repository.cc
@@ -271,6 +271,7 @@ EInstalledRepository::perform_config(
{
EbuildConfigCommand config_cmd(make_named_values<EbuildCommandParams>(
value_for<n::builddir>(_imp->params.builddir()),
+ value_for<n::clearenv>(phase->option("clearenv")),
value_for<n::commands>(join(phase->begin_commands(), phase->end_commands(), " ")),
value_for<n::distdir>(ver_dir),
value_for<n::ebuild_dir>(ver_dir),
@@ -376,6 +377,7 @@ EInstalledRepository::perform_info(
EbuildInfoCommand info_cmd(make_named_values<EbuildCommandParams>(
value_for<n::builddir>(_imp->params.builddir()),
+ value_for<n::clearenv>(phase->option("clearenv")),
value_for<n::commands>(join(phase->begin_commands(), phase->end_commands(), " ")),
value_for<n::distdir>(ver_dir),
value_for<n::ebuild_dir>(ver_dir),
diff --git a/paludis/repositories/e/eapis/0.conf b/paludis/repositories/e/eapis/0.conf
index b25d65e..6407393 100644
--- a/paludis/repositories/e/eapis/0.conf
+++ b/paludis/repositories/e/eapis/0.conf
@@ -102,22 +102,22 @@ ebuild_functions = \
ebuild_install = \
skipname=killold : killold ; \
skipname=init userpriv sandbox : init saveenv ; \
- skipname=setup skipifno=setup : loadenv setup saveenv ; \
- skipname=unpack skipifno=*sources,unpack sandbox userpriv : loadenv unpack saveenv ; \
- skipname=compile skipifno=*sources,unpack,compile sandbox userpriv : loadenv compile saveenv ; \
- skipname=test skipifno=*sources,unpack,compile,test sandbox userpriv optional_tests : loadenv test saveenv ; \
- skipname=install skipifno=install sandbox : loadenv install saveenv ; \
+ skipname=setup skipifno=setup clearenv : loadenv setup saveenv ; \
+ skipname=unpack skipifno=*sources,unpack sandbox userpriv clearenv : loadenv unpack saveenv ; \
+ skipname=compile skipifno=*sources,unpack,compile sandbox userpriv clearenv : loadenv compile saveenv ; \
+ skipname=test skipifno=*sources,unpack,compile,test sandbox userpriv clearenv optional_tests : loadenv test saveenv ; \
+ skipname=install skipifno=install sandbox clearenv : loadenv install saveenv ; \
skipname=strip strip : ; \
- skipname=preinst skipifno=preinst prepost : loadenv preinst saveenv ; \
+ skipname=preinst skipifno=preinst clearenv prepost : loadenv preinst saveenv ; \
skipname=merge merge : ; \
- skipname=postinst skipifno=postinst prepost : loadenv postinst saveenv ; \
+ skipname=postinst skipifno=postinst clearenv prepost : loadenv postinst saveenv ; \
skipname=tidyup : tidyup
ebuild_uninstall = \
skipname=killold skipifno=prerm,postrm : killold ; \
skipname=prerm skipifno=prerm,postrm : initmisc prerm saveenv ; \
unmerge : ; \
- skipname=postrm skipifno=prerm,postrm : loadenv postrm tidyup ;
+ skipname=postrm skipifno=prerm,postrm clearenv : loadenv postrm tidyup ;
ebuild_pretend =
diff --git a/paludis/repositories/e/eapis/2.conf b/paludis/repositories/e/eapis/2.conf
index 6abd0f4..30a157c 100644
--- a/paludis/repositories/e/eapis/2.conf
+++ b/paludis/repositories/e/eapis/2.conf
@@ -14,17 +14,17 @@ ebuild_functions = ${ebuild_functions} src_prepare src_configure
ebuild_install = \
skipname=killold : killold ; \
skipname=init userpriv sandbox : init saveenv ; \
- skipname=setup skipifno=setup : loadenv setup saveenv ; \
- skipname=unpack skipifno=*sources,unpack sandbox userpriv : loadenv unpack saveenv ; \
- skipname=prepare skipifno=*sources,unpack,prepare sandbox userpriv : loadenv prepare saveenv ; \
- skipname=configure skipifno=*sources,unpack,prepare,configure sandbox userpriv : loadenv configure saveenv ; \
- skipname=compile skipifno=*sources,unpack,prepare,configure,compile sandbox userpriv : loadenv compile saveenv ; \
- skipname=test skipifno=*sources,unpack,prepare,configure,compile,test sandbox userpriv optional_tests : loadenv test saveenv ; \
- skipname=install skipifno=install sandbox : loadenv install saveenv ; \
+ skipname=setup skipifno=setup clearenv : loadenv setup saveenv ; \
+ skipname=unpack skipifno=*sources,unpack sandbox userpriv clearenv : loadenv unpack saveenv ; \
+ skipname=prepare skipifno=*sources,unpack,prepare sandbox userpriv clearenv : loadenv prepare saveenv ; \
+ skipname=configure skipifno=*sources,unpack,prepare,configure sandbox userpriv clearenv : loadenv configure saveenv ; \
+ skipname=compile skipifno=*sources,unpack,prepare,configure,compile sandbox userpriv clearenv : loadenv compile saveenv ; \
+ skipname=test skipifno=*sources,unpack,prepare,configure,compile,test sandbox userpriv clearenv optional_tests : loadenv test saveenv ; \
+ skipname=install skipifno=install sandbox clearenv : loadenv install saveenv ; \
skipname=strip strip : ; \
- skipname=preinst skipifno=preinst prepost : loadenv preinst saveenv ; \
+ skipname=preinst skipifno=preinst clearenv prepost : loadenv preinst saveenv ; \
skipname=merge merge : ; \
- skipname=postinst skipifno=postinst prepost : loadenv postinst saveenv ; \
+ skipname=postinst skipifno=postinst clearenv prepost : loadenv postinst saveenv ; \
skipname=tidyup : tidyup
ebuild_new_upgrade_phase_order = true
diff --git a/paludis/repositories/e/eapis/exheres-0.conf b/paludis/repositories/e/eapis/exheres-0.conf
index d89c87e..cb986ad 100644
--- a/paludis/repositories/e/eapis/exheres-0.conf
+++ b/paludis/repositories/e/eapis/exheres-0.conf
@@ -106,24 +106,24 @@ ebuild_functions = \
ebuild_install = \
skipname=killold : killold ; \
skipname=init userpriv sandbox : init saveenv ; \
- skipname=setup skipifno=setup sandbox : loadenv setup saveenv ; \
- skipname=unpack skipifno=*sources,unpack sandbox userpriv : loadenv unpack saveenv ; \
- skipname=prepare skipifno=*sources,unpack,prepare sandbox userpriv : loadenv prepare saveenv ; \
- skipname=configure skipifno=*sources,unpack,prepare,configure sandbox userpriv : loadenv configure saveenv ; \
- skipname=compile skipifno=*sources,unpack,prepare,configure,compile sandbox userpriv : loadenv compile saveenv ; \
- skipname=test skipifno=*sources,unpack,prepare,configure,compile,test sandbox userpriv recommended_tests : loadenv test saveenv ; \
- skipname=install skipifno=*sources,unpack,prepare,configure,compile,test,install sandbox : loadenv install saveenv ; \
+ skipname=setup skipifno=setup sandbox clearenv : loadenv setup saveenv ; \
+ skipname=unpack skipifno=*sources,unpack sandbox userpriv clearenv : loadenv unpack saveenv ; \
+ skipname=prepare skipifno=*sources,unpack,prepare sandbox userpriv clearenv : loadenv prepare saveenv ; \
+ skipname=configure skipifno=*sources,unpack,prepare,configure sandbox userpriv clearenv : loadenv configure saveenv ; \
+ skipname=compile skipifno=*sources,unpack,prepare,configure,compile sandbox userpriv clearenv : loadenv compile saveenv ; \
+ skipname=test skipifno=*sources,unpack,prepare,configure,compile,test sandbox userpriv clearenv recommended_tests : loadenv test saveenv ; \
+ skipname=install skipifno=*sources,unpack,prepare,configure,compile,test,install sandbox clearenv : loadenv install saveenv ; \
skipname=strip strip : ; \
- skipname=preinst skipifno=preinst sandbox : loadenv preinst saveenv ; \
+ skipname=preinst skipifno=preinst sandbox clearenv prepost : loadenv preinst saveenv ; \
skipname=merge merge : ; \
- skipname=postinst skipifno=postinst sandbox : loadenv postinst saveenv ; \
+ skipname=postinst skipifno=postinst sandbox clearenv prepost : loadenv postinst saveenv ; \
skipname=tidyup : tidyup
ebuild_uninstall = \
skipname=killold skipifno=prerm,postrm : killold ; \
skipname=prerm skipifno=prerm,postrm sandbox : initmisc prerm saveenv ; \
unmerge : ; \
- skipname=postrm skipifno=prerm,postrm sandbox : loadenv postrm ; \
+ skipname=postrm skipifno=prerm,postrm sandbox clearenv : loadenv postrm ; \
skipname=tidyup skipifno=prerm,postrm : tidyup
ebuild_pretend = \
diff --git a/paludis/repositories/e/eapis/kdebuild-1.conf b/paludis/repositories/e/eapis/kdebuild-1.conf
index 03fafaf..82bb762 100644
--- a/paludis/repositories/e/eapis/kdebuild-1.conf
+++ b/paludis/repositories/e/eapis/kdebuild-1.conf
@@ -28,15 +28,15 @@ flat_list_minimum_size = -1
ebuild_install = \
skipname=killold : killold ; \
skipname=init userpriv sandbox : init saveenv ; \
- skipname=setup skipifno=setup : loadenv setup saveenv ; \
- skipname=unpack skipifno=*sources,unpack sandbox userpriv : loadenv unpack saveenv ; \
- skipname=compile skipifno=*sources,unpack,compile sandbox userpriv : loadenv compile saveenv ; \
- skipname=test skipifno=*sources,unpack,compile,test sandbox userpriv recommended_tests : loadenv test saveenv ; \
- skipname=install skipifno=install sandbox : loadenv install saveenv ; \
+ skipname=setup skipifno=setup clearenv : loadenv setup saveenv ; \
+ skipname=unpack skipifno=*sources,unpack sandbox userpriv clearenv : loadenv unpack saveenv ; \
+ skipname=compile skipifno=*sources,unpack,compile sandbox userpriv clearenv : loadenv compile saveenv ; \
+ skipname=test skipifno=*sources,unpack,compile,test sandbox userpriv clearenv recommended_tests : loadenv test saveenv ; \
+ skipname=install skipifno=install sandbox clearenv : loadenv install saveenv ; \
skipname=strip strip : ; \
- skipname=preinst skipifno=preinst prepost : loadenv preinst saveenv ; \
+ skipname=preinst skipifno=preinst clearenv prepost : loadenv preinst saveenv ; \
skipname=merge merge : ; \
- skipname=postinst skipifno=postinst prepost : loadenv postinst saveenv ; \
+ skipname=postinst skipifno=postinst clearenv prepost : loadenv postinst saveenv ; \
skipname=tidyup : tidyup
ebuild_info = \
diff --git a/paludis/repositories/e/eapis/paludis-1.conf b/paludis/repositories/e/eapis/paludis-1.conf
index 6dbba95..e679851 100644
--- a/paludis/repositories/e/eapis/paludis-1.conf
+++ b/paludis/repositories/e/eapis/paludis-1.conf
@@ -104,22 +104,22 @@ ebuild_functions = \
ebuild_install = \
skipname=killold : killold ; \
skipname=init userpriv sandbox : init saveenv ; \
- skipname=setup skipifno=setup sandbox : loadenv setup saveenv ; \
- skipname=unpack skipifno=*sources,unpack sandbox userpriv : loadenv unpack saveenv ; \
- skipname=compile skipifno=*sources,unpack,compile sandbox userpriv : loadenv compile saveenv ; \
- skipname=test skipifno=*sources,unpack,compile,test sandbox userpriv recommended_tests : loadenv test saveenv ; \
- skipname=install skipifno=install sandbox : loadenv install saveenv ; \
+ skipname=setup skipifno=setup sandbox clearenv : loadenv setup saveenv ; \
+ skipname=unpack skipifno=*sources,unpack sandbox userpriv clearenv : loadenv unpack saveenv ; \
+ skipname=compile skipifno=*sources,unpack,compile sandbox userpriv clearenv : loadenv compile saveenv ; \
+ skipname=test skipifno=*sources,unpack,compile,test sandbox userpriv clearenv recommended_tests : loadenv test saveenv ; \
+ skipname=install skipifno=install sandbox clearenv : loadenv install saveenv ; \
skipname=strip strip : ; \
- skipname=preinst skipifno=preinst sandbox : loadenv preinst saveenv ; \
+ skipname=preinst skipifno=preinst sandbox clearenv prepost : loadenv preinst saveenv ; \
skipname=merge merge : ; \
- skipname=postinst skipifno=postinst sandbox : loadenv postinst saveenv ; \
+ skipname=postinst skipifno=postinst sandbox clearenv prepost : loadenv postinst saveenv ; \
skipname=tidyup : tidyup
ebuild_uninstall = \
skipname=killold skipifno=prerm,postrm : killold ; \
skipname=prerm skipifno=prerm,postrm sandbox : initmisc prerm saveenv ; \
unmerge : ; \
- skipname=postrm skipifno=prerm,postrm sandbox : loadenv postrm ; \
+ skipname=postrm skipifno=prerm,postrm sandbox clearenv : loadenv postrm ; \
skipname=tidyup skipifno=prerm,postrm : tidyup
ebuild_pretend = \
diff --git a/paludis/repositories/e/eapis/pbin-1+0.conf b/paludis/repositories/e/eapis/pbin-1+0.conf
index 6ff3de7..810a24e 100644
--- a/paludis/repositories/e/eapis/pbin-1+0.conf
+++ b/paludis/repositories/e/eapis/pbin-1+0.conf
@@ -25,12 +25,12 @@ ebuild_functions = ${ebuild_functions} builtin_pivotbin builtin_installbin
ebuild_install = \
skipname=killold : killold ; \
skipname=init userpriv sandbox : init saveenv ; \
- skipname=pivotbin : loadenv pivotbin setup saveenv ; \
- skipname=installbin sandbox : loadenv installbin saveenv ; \
+ skipname=pivotbin clearenv : loadenv pivotbin setup saveenv ; \
+ skipname=installbin sandbox clearenv : loadenv installbin saveenv ; \
skipname=strip strip : ; \
- skipname=preinst prepost : loadenv preinst saveenv ; \
+ skipname=preinst clearenv prepost : loadenv preinst saveenv ; \
skipname=merge merge : ; \
- skipname=postinst prepost : loadenv postinst saveenv ; \
+ skipname=postinst clearenv prepost : loadenv postinst saveenv ; \
skipname=tidyup : tidyup
description_generated_using = Generated using
diff --git a/paludis/repositories/e/eapis/pbin-1+1.conf b/paludis/repositories/e/eapis/pbin-1+1.conf
index d417ed9..74d7705 100644
--- a/paludis/repositories/e/eapis/pbin-1+1.conf
+++ b/paludis/repositories/e/eapis/pbin-1+1.conf
@@ -25,12 +25,12 @@ ebuild_functions = ${ebuild_functions} builtin_pivotbin builtin_installbin
ebuild_install = \
skipname=killold : killold ; \
skipname=init userpriv sandbox : init saveenv ; \
- skipname=setup : loadenv pivotbin setup saveenv ; \
- skipname=installbin sandbox : loadenv installbin saveenv ; \
+ skipname=setup clearenv : loadenv pivotbin setup saveenv ; \
+ skipname=installbin sandbox clearenv : loadenv installbin saveenv ; \
skipname=strip strip : ; \
- skipname=preinst prepost : loadenv preinst saveenv ; \
+ skipname=preinst clearenv prepost : loadenv preinst saveenv ; \
skipname=merge merge : ; \
- skipname=postinst prepost : loadenv postinst saveenv ; \
+ skipname=postinst clearenv prepost : loadenv postinst saveenv ; \
skipname=tidyup : tidyup
description_generated_using = Generated using
diff --git a/paludis/repositories/e/eapis/pbin-1+exheres-0.conf b/paludis/repositories/e/eapis/pbin-1+exheres-0.conf
index ad3e024..180aeb4 100644
--- a/paludis/repositories/e/eapis/pbin-1+exheres-0.conf
+++ b/paludis/repositories/e/eapis/pbin-1+exheres-0.conf
@@ -26,12 +26,12 @@ ebuild_functions = ${ebuild_functions} builtin_pivotbin builtin_installbin
ebuild_install = \
skipname=killold : killold ; \
skipname=init userpriv sandbox : init saveenv ; \
- skipname=setup : loadenv pivotbin setup saveenv ; \
- skipname=installbin sandbox : loadenv installbin saveenv ; \
+ skipname=setup clearenv : loadenv pivotbin setup saveenv ; \
+ skipname=installbin sandbox clearenv : loadenv installbin saveenv ; \
skipname=strip strip : ; \
- skipname=preinst prepost : loadenv preinst saveenv ; \
+ skipname=preinst clearenv prepost : loadenv preinst saveenv ; \
skipname=merge merge : ; \
- skipname=postinst prepost : loadenv postinst saveenv ; \
+ skipname=postinst clearenv prepost : loadenv postinst saveenv ; \
skipname=tidyup : tidyup
description_generated_using = Generated using
diff --git a/paludis/repositories/e/eapis/pbin-1+paludis-1.conf b/paludis/repositories/e/eapis/pbin-1+paludis-1.conf
index 72923ec..5bf6708 100644
--- a/paludis/repositories/e/eapis/pbin-1+paludis-1.conf
+++ b/paludis/repositories/e/eapis/pbin-1+paludis-1.conf
@@ -26,12 +26,12 @@ ebuild_functions = ${ebuild_functions} builtin_pivotbin builtin_installbin
ebuild_install = \
skipname=killold : killold ; \
skipname=init userpriv sandbox : init saveenv ; \
- skipname=setup : loadenv pivotbin setup saveenv ; \
- skipname=installbin sandbox : loadenv installbin saveenv ; \
+ skipname=setup clearenv : loadenv pivotbin setup saveenv ; \
+ skipname=installbin sandbox clearenv : loadenv installbin saveenv ; \
skipname=strip strip : ; \
- skipname=preinst prepost : loadenv preinst saveenv ; \
+ skipname=preinst clearenv prepost : loadenv preinst saveenv ; \
skipname=merge merge : ; \
- skipname=postinst prepost : loadenv postinst saveenv ; \
+ skipname=postinst clearenv prepost : loadenv postinst saveenv ; \
skipname=tidyup : tidyup
description_generated_using = Generated using
diff --git a/paludis/repositories/e/ebuild.cc b/paludis/repositories/e/ebuild.cc
index 28ae2a9..b43b37c 100644
--- a/paludis/repositories/e/ebuild.cc
+++ b/paludis/repositories/e/ebuild.cc
@@ -100,6 +100,9 @@ EbuildCommand::operator() ()
if (! params.package_id()->eapi()->supported())
throw InternalError(PALUDIS_HERE, "Tried to run EbuildCommand on an unsupported EAPI");
+ if (params.clearenv())
+ cmd.with_clearenv();
+
if (params.sandbox())
cmd.with_sandbox();
diff --git a/paludis/repositories/e/ebuild.hh b/paludis/repositories/e/ebuild.hh
index fa92abf..a00963b 100644
--- a/paludis/repositories/e/ebuild.hh
+++ b/paludis/repositories/e/ebuild.hh
@@ -48,6 +48,7 @@ namespace paludis
struct binary_distdir;
struct binary_ebuild_location;
struct builddir;
+ struct clearenv;
struct commands;
struct config_protect;
struct config_protect_mask;
@@ -99,6 +100,7 @@ namespace paludis
struct EbuildCommandParams
{
NamedValue<n::builddir, FSEntry> builddir;
+ NamedValue<n::clearenv, bool> clearenv;
NamedValue<n::commands, std::string> commands;
NamedValue<n::distdir, FSEntry> distdir;
NamedValue<n::ebuild_dir, FSEntry> ebuild_dir;
diff --git a/paludis/repositories/e/ebuild/0/builtin_init.bash b/paludis/repositories/e/ebuild/0/builtin_init.bash
index 3f62989..89ee889 100644
--- a/paludis/repositories/e/ebuild/0/builtin_init.bash
+++ b/paludis/repositories/e/ebuild/0/builtin_init.bash
@@ -19,11 +19,6 @@
builtin_init()
{
local a
- for a in PALUDIS_NON_EMPTY_VARIABLES ${PALUDIS_NON_EMPTY_VARIABLES} ; do
- a=${a#build:}
- [[ -z "${!a}" ]] && die "\$${a} unset or empty"
- declare -r ${a}="${!a}"
- done
for a in ${PALUDIS_DIRECTORY_VARIABLES} ; do
a=${a#build:}
@@ -79,9 +74,13 @@ builtin_init()
export S="${WORKDIR}/${P}"
- if [[ "${EBUILD}" != "-" ]] ; then
- ebuild_load_ebuild "${EBUILD}"
- fi
+ ebuild_load_em_up_dan
+
+ for a in PALUDIS_NON_EMPTY_VARIABLES ${PALUDIS_NON_EMPTY_VARIABLES} ; do
+ a=${a#build:}
+ [[ -z "${!a}" ]] && die "\$${a} unset or empty"
+ declare -r ${a}="${!a}"
+ done
}
ebuild_f_init()
diff --git a/paludis/repositories/e/ebuild/0/builtin_initmisc.bash b/paludis/repositories/e/ebuild/0/builtin_initmisc.bash
index 720816a..db9b42f 100644
--- a/paludis/repositories/e/ebuild/0/builtin_initmisc.bash
+++ b/paludis/repositories/e/ebuild/0/builtin_initmisc.bash
@@ -19,11 +19,6 @@
builtin_initmisc()
{
local a
- for a in PALUDIS_NON_EMPTY_VARIABLES ${PALUDIS_NON_EMPTY_VARIABLES} ; do
- [[ "${a#build:}" != "${a}" ]] && continue
- [[ -z "${!a}" ]] && die "\$${a} unset or empty"
- declare -r ${a}="${!a}"
- done
for a in ${PALUDIS_DIRECTORY_VARIABLES} ; do
[[ "${a#build:}" != "${a}" ]] && continue
@@ -61,13 +56,17 @@ builtin_initmisc()
export T="${PALUDIS_PACKAGE_BUILDDIR}"
mkdir -p "${T}" || die "Couldn't create \$T (\"${T}\")"
- declare -r T="${T}"
export HOME="${T}"
export TMPDIR="${T}"
- if [[ "${EBUILD}" != "-" ]] ; then
- ebuild_load_ebuild "${EBUILD}"
- fi
+ ebuild_load_em_up_dan
+ declare -r T="${T}"
+
+ for a in PALUDIS_NON_EMPTY_VARIABLES ${PALUDIS_NON_EMPTY_VARIABLES} ; do
+ [[ "${a#build:}" != "${a}" ]] && continue
+ [[ -z "${!a}" ]] && die "\$${a} unset or empty"
+ declare -r ${a}="${!a}"
+ done
}
ebuild_f_initmisc()
diff --git a/paludis/repositories/e/ebuild/0/builtin_metadata.bash b/paludis/repositories/e/ebuild/0/builtin_metadata.bash
index 849648d..c2cb71e 100644
--- a/paludis/repositories/e/ebuild/0/builtin_metadata.bash
+++ b/paludis/repositories/e/ebuild/0/builtin_metadata.bash
@@ -25,7 +25,7 @@ ebuild_f_metadata()
local key
for a in ${PALUDIS_EBUILD_MUST_NOT_SET_VARIABLES} ; do
- [[ "${!a-unset}" == "unset" ]] || die "\$${a} must not be set"
+ [[ ${!a+set} != set ]] || die "\$${a} must not be set"
done
for key in ${EBUILD_METADATA_VARIABLES} ; do
diff --git a/paludis/repositories/e/ebuild/ebuild.bash b/paludis/repositories/e/ebuild/ebuild.bash
index 0e1cb52..f6a193a 100755
--- a/paludis/repositories/e/ebuild/ebuild.bash
+++ b/paludis/repositories/e/ebuild/ebuild.bash
@@ -20,20 +20,29 @@
# this program; if not, write to the Free Software Foundation, Inc., 59 Temple
# Place, Suite 330, Boston, MA 02111-1307 USA
-if [[ -e ${ROOT}/etc/profile.env ]] && ! source "${ROOT}"/etc/profile.env; then
- echo "error sourcing ${ROOT}/etc/profile.env" >&2
- exit 123
-fi
-
-# Force a few more things into PATH, since some users have crazy setups.
-# See ticket:374.
-export PATH="/bin:/sbin:/usr/bin:/usr/sbin:${PATH}"
-
unalias -a
set +C
-unset GZIP BZIP BZIP2 CDPATH GREP_OPTIONS GREP_COLOR GLOBIGNORE
-eval unset LANG ${!LC_*}
-export LC_ALL=C
+
+ebuild_sanitise_envvars()
+{
+ # Force a few more things into PATH, since some users have crazy setups.
+ # See ticket:374.
+ export PATH="/bin:/sbin:/usr/bin:/usr/sbin${PATH:+:${PATH}}"
+
+ if [[ -n "${PALUDIS_EBUILD_DIR_FALLBACK}" ]] ; then
+ export PATH="${PALUDIS_EBUILD_DIR_FALLBACK}/utils:${PATH}"
+ fi
+ export PATH="${PALUDIS_EBUILD_DIR}/utils:${PATH}"
+ local p
+ for p in ${PALUDIS_UTILITY_PATH_SUFFIXES} ; do
+ export PATH="${PALUDIS_EBUILD_DIR}/utils/${p}:${PATH}"
+ done
+
+ unset GZIP BZIP BZIP2 CDPATH GREP_OPTIONS GREP_COLOR GLOBIGNORE
+ unset LANG ${!LC_*}
+ export LC_ALL=C
+}
+ebuild_sanitise_envvars
# The list below should include all variables from all EAPIs, along with any
# fancy fake variables
@@ -43,10 +52,8 @@ EBUILD_METADATA_VARIABLES="DEPEND RDEPEND PDEPEND IUSE SRC_URI DOWNLOADS RESTRIC
MYOPTIONS E_MYOPTIONS E_DEPENDENCIES BINARY_KEYWORDS BINARY_URI \
GENERATED_USING GENERATED_TIME BINARY_PLATFORMS REMOTE_IDS \
SUMMARY BUGS_TO UPSTREAM_DOCUMENTATION UPSTREAM_CHANGELOG \
- UPSTREAM_RELEASE_NOTES PROPERTIES PALUDIS_DECLARED_FUNCTIONS"
-unset -v ${EBUILD_METADATA_VARIABLES} ${PALUDIS_EBUILD_MUST_NOT_SET_VARIABLES}
-# These can be set by C++
-EBUILD_METADATA_VARIABLES="${EBUILD_METADATA_VARIABLES} SLOT EAPI OPTIONS USE"
+ UPSTREAM_RELEASE_NOTES PROPERTIES PALUDIS_DECLARED_FUNCTIONS SLOT EAPI OPTIONS USE"
+EBUILD_METADATA_VARIABLES_FROM_CPLUSPLUS="SLOT EAPI OPTIONS USE"
if [[ -z "${PALUDIS_DO_NOTHING_SANDBOXY}" ]] ; then
export SANDBOX_PREDICT="${SANDBOX_PREDICT+${SANDBOX_PREDICT}:}"
@@ -67,14 +74,6 @@ export ROOT="${ROOT%+(/)}/"
export EBUILD_PROGRAM_NAME="$0"
-if [[ -n "${PALUDIS_EBUILD_DIR_FALLBACK}" ]] ; then
- export PATH="${PALUDIS_EBUILD_DIR_FALLBACK}/utils:${PATH}"
-fi
-export PATH="${PALUDIS_EBUILD_DIR}/utils:${PATH}"
-for p in ${PALUDIS_UTILITY_PATH_SUFFIXES} ; do
- export PATH="${PALUDIS_EBUILD_DIR}/utils/${p}:${PATH}"
-done
-
EBUILD_MODULES_DIR=$(canonicalise $(dirname $0 ) )
if ! [[ -d ${EBUILD_MODULES_DIR} ]] ; then
echo "${EBUILD_MODULES_DIR} is not a directory" 1>&2
@@ -172,7 +171,7 @@ ebuild_source_profile()
done <${1}/parent
fi
- local old_set=$-
+ local paludis_old_set=$-
set -a
if [[ -f ${1}/make.defaults ]] ; then
@@ -183,78 +182,14 @@ ebuild_source_profile()
source ${1}/bashrc || die "Couldn't source ${1}/bashrc"
fi
- [[ "${old_set}" == *a* ]] || set +a
+ [[ ${paludis_old_set} == *a* ]] || set +a
}
-export CONFIG_PROTECT="${PALUDIS_CONFIG_PROTECT}"
-export CONFIG_PROTECT_MASK="${PALUDIS_CONFIG_PROTECT_MASK}"
-save_vars="$(eval echo ${PALUDIS_SAVE_VARIABLES} )"
-save_base_vars="$(eval echo ${PALUDIS_SAVE_BASE_VARIABLES} )"
-save_unmodifiable_vars="$(eval echo ${PALUDIS_SAVE_UNMODIFIABLE_VARIABLES} )"
-check_save_vars="${save_vars}"
-check_base_vars="${save_base_vars}"
-check_unmodifiable_vars="${save_unmodifiable_vars}"
-
-for var in ${save_vars} ${default_save_vars} ${save_base_vars} ${save_unmodifiable_vars} ; do
- eval "export save_var_${var}='${!var}'"
-done
-
-if [[ -n "${PALUDIS_PROFILE_DIRS}" ]] ; then
- for var in ${PALUDIS_PROFILE_DIRS} ; do
- ebuild_source_profile $(canonicalise "${var}")
- done
-elif [[ -n "${PALUDIS_PROFILE_DIR}" ]] ; then
- ebuild_source_profile $(canonicalise "${PALUDIS_PROFILE_DIR}")
-fi
-
-unset ${save_vars} ${save_base_vars}
-
-for f in ${PALUDIS_BASHRC_FILES} ; do
- if [[ -f ${f} ]] ; then
- ebuild_notice "debug" "Loading bashrc file ${f}"
- old_set=$-
- set -a
- source ${f}
- [[ "${old_set}" == *a* ]] || set +a
- else
- ebuild_notice "debug" "Skipping bashrc file ${f}"
- fi
-
- for var in ${check_save_vars} ; do
- if [[ -n ${!var} ]] ; then
- die "${f} attempted to set \$${var}, which must not be set in bashrc."
- fi
- done
-
- for var in ${check_save_unmodifiable_vars} ; do
- s_var=save_var_${var}
- if [[ "${!s_var}" != "${!var}" ]] ; then
- die "${f} attempted to modify \$${var}, which must not be modified in bashrc."
- fi
- done
-done
-
-for var in ${save_vars} ; do
- eval "export ${var}=\${save_var_${var}}"
-done
-
-for var in ${save_base_vars} ; do
- eval "export ${var}=\"\${save_var_${var}} \$$(echo ${var})\""
-done
-
-if [[ -z "${PALUDIS_DO_NOTHING_SANDBOXY}" ]] ; then
- [[ -n "${CCACHE_DIR}" ]] && export SANDBOX_WRITE="${SANDBOX_WRITE}:${CCACHE_DIR}"
-fi
-
-[[ -z "${CBUILD}" ]] && export CBUILD="${CHOST}"
-export REAL_CHOST="${CHOST}"
-
ebuild_scrub_environment()
{
- local save_LD_LIBRARY_PATH="${LD_LIBRARY_PATH}"
(
ebuild_safe_source "${1}" PATH PALUDIS_SOURCE_MERGED_VARIABLES \
- PALUDIS_BRACKET_MERGED_VARIABLES || exit 1
+ PALUDIS_BRACKET_MERGED_VARIABLES LD_LIBRARY_PATH || exit 1
unset -f diefunc perform_hook inherit builtin_loadenv builtin_saveenv
unset -f ebuild_safe_source portageq best_version has_version paludis_pipe_command
@@ -276,8 +211,11 @@ ebuild_scrub_environment()
PALUDIS_CLIENT_UPPER=$(echo ${PALUDIS_CLIENT} | tr a-z A-Z)
echo "\${!${PALUDIS_CLIENT_UPPER}_CMDLINE_*} ${PALUDIS_CLIENT_UPPER}_OPTIONS" )
- unset -v CATEGORY PN PV P PNV PVR PF PNVR ${!LD_*}
-
+ unset -v CATEGORY PN PV P PNV PVR PF PNVR
+ unset -v $(
+ for v in ${!LD_*}; do
+ [[ ${v} != LD_LIBRARY_PATH ]] && echo ${v}
+ done )
unset -v ebuild EBUILD
unset -v $(
for v in ${PALUDIS_SOURCE_MERGED_VARIABLES} ${PALUDIS_BRACKET_MERGED_VARIABLES} ; do
@@ -298,7 +236,7 @@ ebuild_scrub_environment()
done )
set >"${1}"
- LD_LIBRARY_PATH="${save_LD_LIBRARY_PATH}" print_exports >>"${1}"
+ print_exports >>"${1}"
)
}
@@ -345,47 +283,137 @@ ebuild_load_environment()
fi
}
-ebuild_load_ebuild()
+ebuild_unset_all_except()
{
- unset ${SOURCE_MERGED_VARIABLES} ${BRACKET_MERGED_VARIABLES}
+ local ${2}
+ unset -v ${1}
+}
- local v e_v
- for v in ${PALUDIS_MUST_NOT_CHANGE_VARIABLES} ; do
- e_v=saved_${v}
- local ${e_v}="${!v}"
+ebuild_load_ebuild()
+{
+ local paludis_v paludis_e_v
+ ebuild_unset_all_except "${EBUILD_METADATA_VARIABLES}" "${EBUILD_METADATA_VARIABLES_FROM_CPLUSPLUS}"
+ unset -v ${PALUDIS_EBUILD_MUST_NOT_SET_VARIABLES}
+ unset -v ${PALUDIS_SOURCE_MERGED_VARIABLES} ${PALUDIS_BRACKET_MERGED_VARIABLES}
+
+ for paludis_v in ${PALUDIS_MUST_NOT_CHANGE_VARIABLES} ; do
+ local paludis_saved_${paludis_v}
+ eval paludis_saved_${paludis_v}='${!paludis_v}'
done
- [[ -f "${1}" ]] || die "Ebuild '${1}' is not a file"
+ [[ -f ${1} ]] || die "Ebuild '${1}' is not a file"
source ${1} || die "Error sourcing ebuild '${1}'"
- if [[ -n "${PALUDIS_RDEPEND_DEFAULTS_TO_DEPEND}" ]] ; then
- [[ ${RDEPEND-unset} == "unset" ]] && RDEPEND="${DEPEND}"
+ if [[ -n ${PALUDIS_RDEPEND_DEFAULTS_TO_DEPEND} ]] ; then
+ [[ ${RDEPEND+set} != set ]] && RDEPEND=${DEPEND}
fi
- for v in ${PALUDIS_SOURCE_MERGED_VARIABLES} ; do
- e_v=E_${v}
- export -n ${v}="${!v} ${!e_v}"
+ for paludis_v in ${PALUDIS_SOURCE_MERGED_VARIABLES} ; do
+ paludis_e_v=E_${paludis_v}
+ eval ${paludis_v}='"${!paludis_v} ${!paludis_e_v}"'
done
- for v in ${PALUDIS_BRACKET_MERGED_VARIABLES} ; do
- e_v=E_${v}
- export -n ${v}="( ${!v} ) ${!e_v}"
+ for paludis_v in ${PALUDIS_BRACKET_MERGED_VARIABLES} ; do
+ paludis_e_v=E_${paludis_v}
+ eval ${paludis_v}='"( ${!paludis_v} ) ${!paludis_e_v}"'
done
- for v in ${PALUDIS_MUST_NOT_CHANGE_VARIABLES} ; do
- s_v="saved_${v}"
- if [[ -n "${!s_v}" ]] && [[ "${!v}" != "${!s_v}" ]] ; then
+ for paludis_v in ${PALUDIS_MUST_NOT_CHANGE_VARIABLES} ; do
+ local paludis_s_v=paludis_saved_${paludis_v}
+ if [[ -n ${!paludis_s_v} ]] && [[ ${!paludis_v} != ${!paludis_s_v} ]] ; then
ebuild_notice "qa" \
- "Ebuild ${1} illegally tried to change ${v} from '${!s_v}' to '${!v}'"
- export ${v}="${!s_v}"
+ "Ebuild ${1} illegally tried to change ${paludis_v} from '${!paludis_s_v}' to '${!paludis_v}'"
+ eval ${paludis_v}='${!paludis_s_v}'
fi
done
- export PALUDIS_DECLARED_FUNCTIONS=$(declare -F | while read v ; do
- echo -n ${v/declare -f } " "
+ PALUDIS_DECLARED_FUNCTIONS=$(declare -F | while read paludis_v ; do
+ echo -n ${paludis_v#declare -f } " "
done )
}
+ebuild_load_em_up_dan()
+{
+ export CONFIG_PROTECT=${PALUDIS_CONFIG_PROTECT}
+ export CONFIG_PROTECT_MASK=${PALUDIS_CONFIG_PROTECT_MASK}
+ local paludis_save_vars=$(eval echo ${PALUDIS_SAVE_VARIABLES} )
+ local paludis_save_base_vars=$(eval echo ${PALUDIS_SAVE_BASE_VARIABLES} )
+ local paludis_save_unmodifiable_vars=$(eval echo ${PALUDIS_SAVE_UNMODIFIABLE_VARIABLES} )
+ local paludis_check_save_vars=${paludis_save_vars}
+ local paludis_check_base_vars=${paludis_save_base_vars}
+ local paludis_check_unmodifiable_vars=${paludis_save_unmodifiable_vars}
+
+ local paludis_var
+ for paludis_var in ${paludis_save_vars} ${paludis_save_base_vars} ${paludis_save_unmodifiable_vars} ; do
+ local paludis_save_var_${paludis_var}
+ eval paludis_save_var_${paludis_var}='${!paludis_var}'
+ done
+
+ if [[ -e ${ROOT}/etc/profile.env ]] && ! source "${ROOT}"/etc/profile.env; then
+ echo "error sourcing ${ROOT}/etc/profile.env" >&2
+ exit 123
+ fi
+ ebuild_sanitise_envvars
+
+ if [[ -n ${PALUDIS_PROFILE_DIRS} ]] ; then
+ for paludis_var in ${PALUDIS_PROFILE_DIRS} ; do
+ ebuild_source_profile "$(canonicalise "${paludis_var}")"
+ done
+ elif [[ -n ${PALUDIS_PROFILE_DIR} ]] ; then
+ ebuild_source_profile "$(canonicalise "${PALUDIS_PROFILE_DIR}")"
+ fi
+
+ unset ${paludis_save_vars} ${paludis_save_base_vars}
+
+ local paludis_f
+ for paludis_f in ${PALUDIS_BASHRC_FILES} ; do
+ if [[ -f ${paludis_f} ]] ; then
+ ebuild_notice "debug" "Loading bashrc file ${paludis_f}"
+ local paludis_old_set=${-}
+ set -a
+ source ${paludis_f}
+ [[ ${paludis_old_set} == *a* ]] || set +a
+ else
+ ebuild_notice "debug" "Skipping bashrc file ${paludis_f}"
+ fi
+
+ for paludis_var in ${paludis_check_save_vars} ; do
+ if [[ -n ${!paludis_var} ]] ; then
+ die "${paludis_f} attempted to set \$${paludis_var}, which must not be set in bashrc"
+ fi
+ done
+
+ for paludis_var in ${paludis_check_save_unmodifiable_vars} ; do
+ local paludis_s_var=paludis_save_var_${paludis_var}
+ if [[ "${!paludis_s_var}" != "${!paludis_var}" ]] ; then
+ die "${paludis_f} attempted to modify \$${var}, which must not be modified in bashrc"
+ fi
+ done
+ done
+
+ for paludis_var in ${paludis_save_vars} ; do
+ local paludis_s_var=paludis_save_var_${paludis_var}
+ eval ${paludis_var}='${!paludis_s_var}'
+ done
+
+ for paludis_var in ${paludis_save_base_vars} ; do
+ local paludis_s_var=paludis_save_var_${paludis_var}
+ eval ${paludis_var}='"${!paludis_s_var} $(echo ${!paludis_var})"'
+ done
+
+ if [[ -z ${PALUDIS_DO_NOTHING_SANDBOXY} ]] ; then
+ [[ -n ${CCACHE_DIR} ]] && export SANDBOX_WRITE=${SANDBOX_WRITE}:${CCACHE_DIR}
+ fi
+
+ [[ -z ${CBUILD} ]] && export CBUILD=${CHOST}
+ export REAL_CHOST=${CHOST}
+
+ ebuild_load_environment
+ if [[ ${EBUILD} != - ]] ; then
+ ebuild_load_ebuild "${EBUILD}"
+ fi
+}
+
perform_hook()
{
export HOOK=${1}
@@ -459,15 +487,16 @@ ebuild_main()
[[ $1 == bad_options ]] ; then
export EBUILD_PHASE="${1}"
perform_hook ebuild_${action}_pre
- if [[ $1 != variable ]] || [[ -n "${EBUILD}" ]] ; then
+ if [[ $1 == metadata ]]; then
for f in cut tr date ; do
- eval "export ebuild_real_${f}=\"$(which $f )\""
- eval "${f}() { ebuild_notice qa 'global scope ${f}' ; $(which $f ) \"\$@\" ; }"
+ eval "${f}() { ebuild_notice qa 'global scope ${f}' ; $(type -P ${f} ) \"\$@\" ; }"
done
for f in locked_pipe_command ; do
- eval "${f}() { $(which $f ) \"\$@\" ; }"
+ eval "${f}() { $(type -P ${f} ) \"\$@\" ; }"
done
PATH="" ebuild_load_ebuild "${EBUILD}"
+ else
+ ebuild_load_em_up_dan
fi
if ! ${PALUDIS_F_FUNCTION_PREFIX:-ebuild_f}_${1} ; then
perform_hook ebuild_${action}_fail
diff --git a/paludis/repositories/e/ebuild/exheres-0/builtin_init.bash b/paludis/repositories/e/ebuild/exheres-0/builtin_init.bash
index 45126e7..92cf00a 100644
--- a/paludis/repositories/e/ebuild/exheres-0/builtin_init.bash
+++ b/paludis/repositories/e/ebuild/exheres-0/builtin_init.bash
@@ -19,11 +19,6 @@
builtin_init()
{
local a
- for a in PALUDIS_NON_EMPTY_VARIABLES ${PALUDIS_NON_EMPTY_VARIABLES} ; do
- a=${a#build:}
- [[ -z "${!a}" ]] && die "\$${a} unset or empty"
- declare -r ${a}="${!a}"
- done
for a in ${PALUDIS_DIRECTORY_VARIABLES} ; do
a=${a#build:}
@@ -76,9 +71,13 @@ builtin_init()
export WORK="${WORKBASE}/${PNV}"
- if [[ "${EBUILD}" != "-" ]] ; then
- ebuild_load_ebuild "${EBUILD}"
- fi
+ ebuild_load_em_up_dan
+
+ for a in PALUDIS_NON_EMPTY_VARIABLES ${PALUDIS_NON_EMPTY_VARIABLES} ; do
+ a=${a#build:}
+ [[ -z "${!a}" ]] && die "\$${a} unset or empty"
+ declare -r ${a}="${!a}"
+ done
}
exheres_internal_init()
diff --git a/paludis/repositories/e/ebuild/exheres-0/builtin_initmisc.bash b/paludis/repositories/e/ebuild/exheres-0/builtin_initmisc.bash
index 17ba0e1..23d1dbc 100644
--- a/paludis/repositories/e/ebuild/exheres-0/builtin_initmisc.bash
+++ b/paludis/repositories/e/ebuild/exheres-0/builtin_initmisc.bash
@@ -19,11 +19,6 @@
builtin_initmisc()
{
local a
- for a in PALUDIS_NON_EMPTY_VARIABLES ${PALUDIS_NON_EMPTY_VARIABLES} ; do
- [[ "${a#build:}" != "${a}" ]] && continue
- [[ -z "${!a}" ]] && die "\$${a} unset or empty"
- declare -r ${a}="${!a}"
- done
for a in ${PALUDIS_DIRECTORY_VARIABLES} ; do
[[ "${a#build:}" != "${a}" ]] && continue
@@ -61,13 +56,17 @@ builtin_initmisc()
export TEMP="${PALUDIS_PACKAGE_BUILDDIR}/temp/"
mkdir -p "${TEMP}" || die "Couldn't create \$TEMP (\"${TEMP}\")"
- declare -r TEMP="${TEMP}"
export HOME="${TEMP}"
export TMPDIR="${TEMP}"
- if [[ "${EBUILD}" != "-" ]] ; then
- ebuild_load_ebuild "${EBUILD}"
- fi
+ ebuild_load_em_up_dan
+ declare -r TEMP="${TEMP}"
+
+ for a in PALUDIS_NON_EMPTY_VARIABLES ${PALUDIS_NON_EMPTY_VARIABLES} ; do
+ [[ "${a#build:}" != "${a}" ]] && continue
+ [[ -z "${!a}" ]] && die "\$${a} unset or empty"
+ declare -r ${a}="${!a}"
+ done
}
exheres_internal_initmisc()
diff --git a/paludis/repositories/e/ebuild/exheres-0/builtin_metadata.bash b/paludis/repositories/e/ebuild/exheres-0/builtin_metadata.bash
index 819b3fb..25d8008 100644
--- a/paludis/repositories/e/ebuild/exheres-0/builtin_metadata.bash
+++ b/paludis/repositories/e/ebuild/exheres-0/builtin_metadata.bash
@@ -25,7 +25,7 @@ exheres_internal_metadata()
local key
for a in ${PALUDIS_EBUILD_MUST_NOT_SET_VARIABLES} ; do
- [[ "${!a-unset}" == "unset" ]] || die "\$${a} must not be set"
+ [[ ${!a+set} != set ]] || die "\$${a} must not be set"
done
for key in ${EBUILD_METADATA_VARIABLES} ; do
diff --git a/paludis/repositories/e/ebuild_entries.cc b/paludis/repositories/e/ebuild_entries.cc
index c8a0e23..bcca3ff 100644
--- a/paludis/repositories/e/ebuild_entries.cc
+++ b/paludis/repositories/e/ebuild_entries.cc
@@ -465,6 +465,7 @@ EbuildEntries::fetch(const std::tr1::shared_ptr<const ERepositoryID> & id,
{
EbuildCommandParams command_params(make_named_values<EbuildCommandParams>(
value_for<n::builddir>(_imp->params.builddir()),
+ value_for<n::clearenv>(phase->option("clearenv")),
value_for<n::commands>(join(phase->begin_commands(), phase->end_commands(), " ")),
value_for<n::distdir>(_imp->params.distdir()),
value_for<n::ebuild_dir>(_imp->e_repository->layout()->package_directory(id->name())),
@@ -764,6 +765,7 @@ EbuildEntries::install(const std::tr1::shared_ptr<const ERepositoryID> & id,
EbuildCommandParams command_params(make_named_values<EbuildCommandParams>(
value_for<n::builddir>(_imp->params.builddir()),
+ value_for<n::clearenv>(phase->option("clearenv")),
value_for<n::commands>(join(phase->begin_commands(), phase->end_commands(), " ")),
value_for<n::distdir>(_imp->params.distdir()),
value_for<n::ebuild_dir>(_imp->e_repository->layout()->package_directory(id->name())),
@@ -872,6 +874,7 @@ EbuildEntries::info(const std::tr1::shared_ptr<const ERepositoryID> & id,
EbuildCommandParams command_params(make_named_values<EbuildCommandParams>(
value_for<n::builddir>(_imp->params.builddir()),
+ value_for<n::clearenv>(phase->option("clearenv")),
value_for<n::commands>(join(phase->begin_commands(), phase->end_commands(), " ")),
value_for<n::distdir>(_imp->params.distdir()),
value_for<n::ebuild_dir>(_imp->e_repository->layout()->package_directory(id->name())),
@@ -942,6 +945,7 @@ EbuildEntries::get_environment_variable(
EbuildVariableCommand cmd(make_named_values<EbuildCommandParams>(
value_for<n::builddir>(_imp->params.builddir()),
+ value_for<n::clearenv>(phases.begin_phases()->option("clearenv")),
value_for<n::commands>(join(phases.begin_phases()->begin_commands(), phases.begin_phases()->end_commands(), " ")),
value_for<n::distdir>(_imp->params.distdir()),
value_for<n::ebuild_dir>(_imp->e_repository->layout()->package_directory(id->name())),
@@ -1095,6 +1099,7 @@ EbuildEntries::pretend(
EbuildCommandParams command_params(make_named_values<EbuildCommandParams>(
value_for<n::builddir>(_imp->params.builddir()),
+ value_for<n::clearenv>(phase->option("clearenv")),
value_for<n::commands>(join(phase->begin_commands(), phase->end_commands(), " ")),
value_for<n::distdir>(_imp->params.distdir()),
value_for<n::ebuild_dir>(_imp->e_repository->layout()->package_directory(id->name())),
@@ -1147,6 +1152,7 @@ EbuildEntries::pretend(
EbuildCommandParams command_params(make_named_values<EbuildCommandParams>(
value_for<n::builddir>(_imp->params.builddir()),
+ value_for<n::clearenv>(phase->option("clearenv")),
value_for<n::commands>(join(phase->begin_commands(), phase->end_commands(), " ")),
value_for<n::distdir>(_imp->params.distdir()),
value_for<n::ebuild_dir>(_imp->e_repository->layout()->package_directory(id->name())),
diff --git a/paludis/repositories/e/ebuild_id.cc b/paludis/repositories/e/ebuild_id.cc
index 2fda637..a53a056 100644
--- a/paludis/repositories/e/ebuild_id.cc
+++ b/paludis/repositories/e/ebuild_id.cc
@@ -235,6 +235,7 @@ EbuildID::need_keys_added() const
EbuildMetadataCommand cmd(make_named_values<EbuildCommandParams>(
value_for<n::builddir>(_imp->repository->params().builddir()),
+ value_for<n::clearenv>(phases.begin_phases()->option("clearenv")),
value_for<n::commands>(join(phases.begin_phases()->begin_commands(), phases.begin_phases()->end_commands(), " ")),
value_for<n::distdir>(_imp->repository->params().distdir()),
value_for<n::ebuild_dir>(_imp->repository->layout()->package_directory(name())),
diff --git a/paludis/repositories/e/exndbam_repository.cc b/paludis/repositories/e/exndbam_repository.cc
index f50db36..4d642ae 100644
--- a/paludis/repositories/e/exndbam_repository.cc
+++ b/paludis/repositories/e/exndbam_repository.cc
@@ -523,6 +523,7 @@ ExndbamRepository::perform_uninstall(
EbuildCommandParams params(
make_named_values<EbuildCommandParams>(
value_for<n::builddir>(_imp->params.builddir()),
+ value_for<n::clearenv>(phase->option("clearenv")),
value_for<n::commands>(join(phase->begin_commands(), phase->end_commands(), " ")),
value_for<n::distdir>(ver_dir),
value_for<n::ebuild_dir>(ver_dir),
diff --git a/paludis/repositories/e/vdb_repository.cc b/paludis/repositories/e/vdb_repository.cc
index c0007b2..c7de342 100644
--- a/paludis/repositories/e/vdb_repository.cc
+++ b/paludis/repositories/e/vdb_repository.cc
@@ -450,6 +450,7 @@ VDBRepository::perform_uninstall(
{
EbuildCommandParams params(make_named_values<EbuildCommandParams>(
value_for<n::builddir>(_imp->params.builddir()),
+ value_for<n::clearenv>(phase->option("clearenv")),
value_for<n::commands>(join(phase->begin_commands(), phase->end_commands(), " ")),
value_for<n::distdir>(pkg_dir),
value_for<n::ebuild_dir>(pkg_dir),
diff --git a/paludis/util/system.cc b/paludis/util/system.cc
index bbd14cb..88d187e 100644
--- a/paludis/util/system.cc
+++ b/paludis/util/system.cc
@@ -150,6 +150,7 @@ namespace paludis
struct Implementation<Command>
{
std::string command;
+ bool clearenv;
std::map<std::string, std::string> setenv_values;
std::string chdir;
bool echo_to_stderr;
@@ -174,6 +175,7 @@ namespace paludis
std::ostream * cs = 0,
std::ostream * ds = 0) :
command(c),
+ clearenv(false),
setenv_values(s),
chdir(d),
echo_to_stderr(e),
@@ -252,6 +254,13 @@ Command::with_setenv(const std::string & k, const std::string & v)
}
Command &
+Command::with_clearenv()
+{
+ _imp->clearenv = true;
+ return *this;
+}
+
+Command &
Command::with_uid_gid(const uid_t u, const gid_t g)
{
_imp->uid.reset(new uid_t(u));
@@ -324,6 +333,9 @@ paludis::run_command(const Command & cmd)
if (! cmd.chdir().empty())
extras.append(" [chdir " + cmd.chdir() + "]");
+ if (cmd.clearenv())
+ extras.append(" [clearenv]");
+
for (Command::ConstIterator s(cmd.begin_setenvs()), s_end(cmd.end_setenvs()) ; s != s_end ; ++s)
extras.append(" [setenv " + s->first + "=" + s->second + "]");
@@ -419,6 +431,24 @@ paludis::run_command(const Command & cmd)
if (-1 == chdir(stringify(cmd.chdir()).c_str()))
throw RunCommandError("chdir failed: " + stringify(strerror(errno)));
+ if (cmd.clearenv())
+ {
+ std::map<std::string, std::string> setenvs;
+ for (const char * const * it(environ); 0 != it; ++it)
+ {
+ std::string var(*it);
+ if (std::string::npos != var.find('=') &&
+ ("PALUDIS_" == var.substr(0, 8) ||
+ "PATH=" == var.substr(0, 5) ||
+ "LD_LIBRARY_PATH=" == var.substr(0, 16)))
+ setenvs.insert(std::make_pair(var.substr(0, var.find('=')), var.substr(var.find('=') + 1)));
+ }
+ clearenv();
+ for (std::map<std::string, std::string>::const_iterator it(setenvs.begin()),
+ it_end(setenvs.end()); it_end != it; ++it)
+ setenv(it->first.c_str(), it->second.c_str(), 1);
+ }
+
for (Command::ConstIterator s(cmd.begin_setenvs()), s_end(cmd.end_setenvs()) ; s != s_end ; ++s)
setenv(s->first.c_str(), s->second.c_str(), 1);
@@ -779,6 +809,12 @@ Command::chdir() const
return _imp->chdir;
}
+bool
+Command::clearenv() const
+{
+ return _imp->clearenv;
+}
+
Command::ConstIterator
Command::begin_setenvs() const
{
diff --git a/paludis/util/system.hh b/paludis/util/system.hh
index 184ba48..6e2ccef 100644
--- a/paludis/util/system.hh
+++ b/paludis/util/system.hh
@@ -136,6 +136,14 @@ namespace paludis
Command & with_setenv(const std::string &, const std::string &);
/**
+ * Remove (most) existing environment variables before
+ * setting those added with with_setenv.
+ *
+ * \since 0.36
+ */
+ Command & with_clearenv();
+
+ /**
* Run our command sandboxed.
*/
Command & with_sandbox();
@@ -256,6 +264,13 @@ namespace paludis
*/
std::ostream * captured_stderr_stream() const;
+ /**
+ * Should we clear existing environment variables?
+ *
+ * \since 0.36
+ */
+ bool clearenv() const;
+
///\}
///\name Iterate over our setenvs.