aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-04-27 19:30:26 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-04-27 19:30:26 +0100
commit18cca3a49d42c95a1887ed89e3d9133902afacf3 (patch)
treecd88dedfee3e3f7549de56e0d09d1f3e44f37974
parent23138200aca0fa30d285c7b5cf84db69498c1238 (diff)
downloadpaludis-18cca3a49d42c95a1887ed89e3d9133902afacf3.tar.gz
paludis-18cca3a49d42c95a1887ed89e3d9133902afacf3.tar.xz
Don't let people change DEFAULT_ things except in global scope
-rw-r--r--paludis/repositories/e/e_repository_TEST.cc9
-rwxr-xr-xpaludis/repositories/e/e_repository_TEST_setup.sh17
-rw-r--r--paludis/repositories/e/eapi.cc1
-rw-r--r--paludis/repositories/e/eapi.hh2
-rw-r--r--paludis/repositories/e/eapis/exheres-0.conf9
-rw-r--r--paludis/repositories/e/ebuild.cc2
-rwxr-xr-xpaludis/repositories/e/ebuild/ebuild.bash5
-rw-r--r--paludis/repositories/e/ebuild/exheres-0/src_compile.bash2
-rw-r--r--paludis/repositories/e/ebuild/exheres-0/src_configure.bash7
-rw-r--r--paludis/repositories/e/ebuild/exheres-0/src_install.bash2
-rw-r--r--paludis/repositories/e/ebuild/exheres-0/src_prepare.bash2
-rw-r--r--paludis/repositories/e/ebuild/exheres-0/src_test.bash4
-rwxr-xr-xpaludis/repositories/e/ebuild/source_functions.bash10
13 files changed, 70 insertions, 2 deletions
diff --git a/paludis/repositories/e/e_repository_TEST.cc b/paludis/repositories/e/e_repository_TEST.cc
index 1bb5724..d6506d8 100644
--- a/paludis/repositories/e/e_repository_TEST.cc
+++ b/paludis/repositories/e/e_repository_TEST.cc
@@ -2322,6 +2322,15 @@ namespace test_cases
TEST_CHECK(id);
TEST_CHECK_THROWS(id->perform_action(action), InstallActionError);
}
+
+ {
+ TestMessageSuffix suffix("change globals", true);
+ const std::tr1::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/change-globals-0",
+ &env, UserPackageDepSpecOptions())), MatchPackageOptions()))]->last());
+ TEST_CHECK(id);
+ TEST_CHECK_THROWS(id->perform_action(action), InstallActionError);
+ }
}
} test_e_repository_install_exheres_0;
diff --git a/paludis/repositories/e/e_repository_TEST_setup.sh b/paludis/repositories/e/e_repository_TEST_setup.sh
index 0c4bef4..9d58ae0 100755
--- a/paludis/repositories/e/e_repository_TEST_setup.sh
+++ b/paludis/repositories/e/e_repository_TEST_setup.sh
@@ -2288,6 +2288,23 @@ src_install() {
doman bar.m
}
END
+mkdir -p "packages/cat/change-globals"
+cat <<'END' > packages/cat/change-globals/change-globals-0.ebuild || exit 1
+DESCRIPTION="The Long Description"
+SUMMARY="The Short Description"
+HOMEPAGE="http://example.com/"
+DOWNLOADS=""
+SLOT="0"
+MYOPTIONS="spork"
+LICENCES="GPL-2"
+PLATFORMS="test"
+WORK="${WORKBASE}"
+
+src_compile() {
+ DEFAULT_SRC_COMPILE_PARAMS="foo"
+ default
+}
+END
mkdir -p "packages/cat/doman-nonfatal"
cat <<'END' > packages/cat/doman-nonfatal/doman-nonfatal-0.ebuild || exit 1
DESCRIPTION="The Long Description"
diff --git a/paludis/repositories/e/eapi.cc b/paludis/repositories/e/eapi.cc
index 2ee23c8..d14a7e8 100644
--- a/paludis/repositories/e/eapi.cc
+++ b/paludis/repositories/e/eapi.cc
@@ -159,6 +159,7 @@ namespace
value_for<n::ignore_pivot_env_functions>(check_get(k, "ignore_pivot_env_functions")),
value_for<n::ignore_pivot_env_variables>(check_get(k, "ignore_pivot_env_variables")),
value_for<n::load_modules>(check_get(k, "load_modules")),
+ value_for<n::must_not_change_after_source_variables>(check_get(k, "must_not_change_after_source_variables")),
value_for<n::must_not_change_variables>(check_get(k, "must_not_change_variables")),
value_for<n::non_empty_variables>(check_get(k, "non_empty_variables")),
value_for<n::rdepend_defaults_to_depend>(destringify_key<bool>(k, "rdepend_defaults_to_depend")),
diff --git a/paludis/repositories/e/eapi.hh b/paludis/repositories/e/eapi.hh
index 30372e3..4a77e49 100644
--- a/paludis/repositories/e/eapi.hh
+++ b/paludis/repositories/e/eapi.hh
@@ -121,6 +121,7 @@ namespace paludis
struct myoptions_number_selected_at_most_one;
struct myoptions_number_selected_exactly_one;
struct myoptions_requires;
+ struct must_not_change_after_source_variables;
struct must_not_change_variables;
struct name;
struct no_slot_or_repo;
@@ -341,6 +342,7 @@ namespace paludis
NamedValue<n::ignore_pivot_env_functions, std::string> ignore_pivot_env_functions;
NamedValue<n::ignore_pivot_env_variables, std::string> ignore_pivot_env_variables;
NamedValue<n::load_modules, std::string> load_modules;
+ NamedValue<n::must_not_change_after_source_variables, std::string> must_not_change_after_source_variables;
NamedValue<n::must_not_change_variables, std::string> must_not_change_variables;
NamedValue<n::non_empty_variables, std::string> non_empty_variables;
NamedValue<n::rdepend_defaults_to_depend, bool> rdepend_defaults_to_depend;
diff --git a/paludis/repositories/e/eapis/exheres-0.conf b/paludis/repositories/e/eapis/exheres-0.conf
index 30836e1..582a79e 100644
--- a/paludis/repositories/e/eapis/exheres-0.conf
+++ b/paludis/repositories/e/eapis/exheres-0.conf
@@ -66,6 +66,15 @@ directory_if_exists_variables = \
ebuild_must_not_set_variables = \
DEPEND RDEPEND PDEPEND PROVIDE USE IUSE KEYWORDS LICENSE LICENSES LICENCE SRC_URI
+must_not_change_after_source_variables = \
+ DEFAULT_SRC_COMPILE_PARAMS \
+ DEFAULT_SRC_CONFIGURE_PARAMS \
+ DEFAULT_SRC_CONFIGURE_OPTION_ENABLES \
+ DEFAULT_SRC_CONFIGURE_OPTION_WITHS \
+ DEFAULT_SRC_INSTALL_PARAMS \
+ DEFAULT_SRC_PREPARE_PATCHES \
+ DEFAULT_SRC_TEST_PARAMS
+
eclass_must_not_set_variables = PLATFORMS
must_not_change_variables =
diff --git a/paludis/repositories/e/ebuild.cc b/paludis/repositories/e/ebuild.cc
index 84c20a2..64463c4 100644
--- a/paludis/repositories/e/ebuild.cc
+++ b/paludis/repositories/e/ebuild.cc
@@ -179,6 +179,8 @@ EbuildCommand::operator() ()
params.package_id()->eapi()->supported()->ebuild_options()->bracket_merged_variables())
.with_setenv("PALUDIS_MUST_NOT_CHANGE_VARIABLES",
params.package_id()->eapi()->supported()->ebuild_options()->must_not_change_variables())
+ .with_setenv("PALUDIS_MUST_NOT_CHANGE_AFTER_SOURCE_VARIABLES",
+ params.package_id()->eapi()->supported()->ebuild_options()->must_not_change_after_source_variables())
.with_setenv("PALUDIS_RDEPEND_DEFAULTS_TO_DEPEND",
params.package_id()->eapi()->supported()->ebuild_options()->rdepend_defaults_to_depend() ? "yes" : "")
.with_setenv("PALUDIS_F_FUNCTION_PREFIX",
diff --git a/paludis/repositories/e/ebuild/ebuild.bash b/paludis/repositories/e/ebuild/ebuild.bash
index 1953c64..c83b11b 100755
--- a/paludis/repositories/e/ebuild/ebuild.bash
+++ b/paludis/repositories/e/ebuild/ebuild.bash
@@ -326,6 +326,11 @@ ebuild_load_ebuild()
fi
done
+ for paludis_v in ${PALUDIS_MUST_NOT_CHANGE_AFTER_SOURCE_VARIABLES} ; do
+ local paludis_s_v=PALUDIS_SAVE_GLOBAL_SCOPE_${paludis_v}
+ export ${paludis_s_v}="$(declare -p ${paludis_v} 2>/dev/null)"
+ done
+
PALUDIS_DECLARED_FUNCTIONS=$(declare -F | while read paludis_v ; do
echo -n ${paludis_v#declare -f } " "
done )
diff --git a/paludis/repositories/e/ebuild/exheres-0/src_compile.bash b/paludis/repositories/e/ebuild/exheres-0/src_compile.bash
index a691970..7a1a83b 100644
--- a/paludis/repositories/e/ebuild/exheres-0/src_compile.bash
+++ b/paludis/repositories/e/ebuild/exheres-0/src_compile.bash
@@ -22,6 +22,8 @@
default_src_compile()
{
+ ebuild_verify_not_changed_from_global_scope DEFAULT_SRC_COMPILE_PARAMS
+
if [[ -f Makefile ]] || [[ -f makefile ]] || [[ -f GNUmakefile ]] ; then
emake "${DEFAULT_SRC_COMPILE_PARAMS[@]}"
fi
diff --git a/paludis/repositories/e/ebuild/exheres-0/src_configure.bash b/paludis/repositories/e/ebuild/exheres-0/src_configure.bash
index a595f10..acc62d3 100644
--- a/paludis/repositories/e/ebuild/exheres-0/src_configure.bash
+++ b/paludis/repositories/e/ebuild/exheres-0/src_configure.bash
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
# vim: set sw=4 sts=4 et :
-# Copyright (c) 2006, 2007, 2008 Ciaran McCreesh
+# Copyright (c) 2006, 2007, 2008, 2009 Ciaran McCreesh
#
# Based in part upon ebuild.sh from Portage, which is Copyright 1995-2005
# Gentoo Foundation and distributed under the terms of the GNU General
@@ -22,6 +22,11 @@
default_src_configure()
{
+ ebuild_verify_not_changed_from_global_scope \
+ DEFAULT_SRC_CONFIGURE_PARAMS \
+ DEFAULT_SRC_CONFIGURE_OPTION_ENABLES \
+ DEFAULT_SRC_CONFIGURE_OPTION_WITHS
+
if [[ -x ${ECONF_SOURCE:-.}/configure ]] ; then
econf \
"${DEFAULT_SRC_CONFIGURE_PARAMS[@]}" \
diff --git a/paludis/repositories/e/ebuild/exheres-0/src_install.bash b/paludis/repositories/e/ebuild/exheres-0/src_install.bash
index 97516b2..dd26803 100644
--- a/paludis/repositories/e/ebuild/exheres-0/src_install.bash
+++ b/paludis/repositories/e/ebuild/exheres-0/src_install.bash
@@ -22,6 +22,8 @@
default_src_install()
{
+ ebuild_verify_not_changed_from_global_scope DEFAULT_SRC_INSTALL_PARAMS
+
local done_docs old_set f d p doc e
if [[ -f Makefile ]] || [[ -f makefile ]] || [[ -f GNUmakefile ]] ; then
if make -j1 -n "${DEFAULT_SRC_INSTALL_PARAMS[@]}" install ; then
diff --git a/paludis/repositories/e/ebuild/exheres-0/src_prepare.bash b/paludis/repositories/e/ebuild/exheres-0/src_prepare.bash
index 7864dbc..04d3a9b 100644
--- a/paludis/repositories/e/ebuild/exheres-0/src_prepare.bash
+++ b/paludis/repositories/e/ebuild/exheres-0/src_prepare.bash
@@ -22,6 +22,8 @@
default_src_prepare()
{
+ ebuild_verify_not_changed_from_global_scope DEFAULT_SRC_PREPARE_PATCHES
+
if [[ -n "${DEFAULT_SRC_PREPARE_PATCHES[@]}" ]]; then
expatch "${DEFAULT_SRC_PREPARE_PATCHES[@]}"
fi
diff --git a/paludis/repositories/e/ebuild/exheres-0/src_test.bash b/paludis/repositories/e/ebuild/exheres-0/src_test.bash
index 8b26f31..e4d6e82 100644
--- a/paludis/repositories/e/ebuild/exheres-0/src_test.bash
+++ b/paludis/repositories/e/ebuild/exheres-0/src_test.bash
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
# vim: set sw=4 sts=4 et :
-# Copyright (c) 2006, 2007, 2008 Ciaran McCreesh
+# Copyright (c) 2006, 2007, 2008, 2009 Ciaran McCreesh
#
# Based in part upon ebuild.sh from Portage, which is Copyright 1995-2005
# Gentoo Foundation and distributed under the terms of the GNU General
@@ -22,6 +22,8 @@
default_src_test()
{
+ ebuild_verify_not_changed_from_global_scope DEFAULT_SRC_TEST_PARAMS
+
if [[ -f Makefile ]] || [[ -f GNUmakefile ]] || [[ -f makefile ]] ; then
echo "Makefile found, looking for potential test targets"
if make -j1 -n "${DEFAULT_SRC_TEST_PARAMS[@]}" check ; then
diff --git a/paludis/repositories/e/ebuild/source_functions.bash b/paludis/repositories/e/ebuild/source_functions.bash
index 82c03a7..f335560 100755
--- a/paludis/repositories/e/ebuild/source_functions.bash
+++ b/paludis/repositories/e/ebuild/source_functions.bash
@@ -39,3 +39,13 @@ ebuild_safe_source()
eval "trap DEBUG; shopt -u extdebug; set +T; return ${?}"
}
+ebuild_verify_not_changed_from_global_scope()
+{
+ local v vv_orig
+ for v in "$@" ; do
+ vv_orig=PALUDIS_SAVE_GLOBAL_SCOPE_$v
+ vv_orig=${!vv_orig}
+ [[ "${vv_orig}" == "$(declare -p "${v}" 2>/dev/null)" ]] || die "Variable $v must be set to an invariant value in global scope"
+ done
+}
+