aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Bo ├śrsted Andresen <bo.andresen@zlin.dk> 2009-10-05 02:19:07 +0000
committerAvatar Bo ├śrsted Andresen <bo.andresen@zlin.dk> 2009-10-05 18:54:09 +0000
commitcbfa5a1f18259de94ca6a44b25caa58e8679fc21 (patch)
tree1445db5681da57356670847058c7115538acad75
parent684622341c337dcd2ae3516471866016546379ff (diff)
downloadpaludis-cbfa5a1f18259de94ca6a44b25caa58e8679fc21.tar.gz
paludis-cbfa5a1f18259de94ca6a44b25caa58e8679fc21.tar.xz
Enforce cross-phase function call ban #755.
-rw-r--r--paludis/repositories/e/e_repository_TEST_exlibs.cc3
-rwxr-xr-xpaludis/repositories/e/e_repository_TEST_exlibs_setup.sh40
-rw-r--r--paludis/repositories/e/ebuild/exheres-0/builtin_init.bash6
-rw-r--r--paludis/repositories/e/ebuild/exheres-0/exlib_functions.bash7
-rw-r--r--paludis/repositories/e/ebuild/exheres-0/pkg_bad_options.bash1
-rw-r--r--paludis/repositories/e/ebuild/exheres-0/pkg_config.bash1
-rw-r--r--paludis/repositories/e/ebuild/exheres-0/pkg_info.bash1
-rw-r--r--paludis/repositories/e/ebuild/exheres-0/pkg_nofetch.bash1
-rw-r--r--paludis/repositories/e/ebuild/exheres-0/pkg_postinst.bash1
-rw-r--r--paludis/repositories/e/ebuild/exheres-0/pkg_postrm.bash1
-rw-r--r--paludis/repositories/e/ebuild/exheres-0/pkg_preinst.bash1
-rw-r--r--paludis/repositories/e/ebuild/exheres-0/pkg_prerm.bash1
-rw-r--r--paludis/repositories/e/ebuild/exheres-0/pkg_pretend.bash1
-rw-r--r--paludis/repositories/e/ebuild/exheres-0/pkg_setup.bash1
-rw-r--r--paludis/repositories/e/ebuild/exheres-0/src_compile.bash1
-rw-r--r--paludis/repositories/e/ebuild/exheres-0/src_configure.bash1
-rw-r--r--paludis/repositories/e/ebuild/exheres-0/src_fetch_extra.bash1
-rw-r--r--paludis/repositories/e/ebuild/exheres-0/src_install.bash1
-rw-r--r--paludis/repositories/e/ebuild/exheres-0/src_prepare.bash1
-rw-r--r--paludis/repositories/e/ebuild/exheres-0/src_test.bash1
-rw-r--r--paludis/repositories/e/ebuild/exheres-0/src_test_expensive.bash1
-rw-r--r--paludis/repositories/e/ebuild/exheres-0/src_unpack.bash1
22 files changed, 74 insertions, 0 deletions
diff --git a/paludis/repositories/e/e_repository_TEST_exlibs.cc b/paludis/repositories/e/e_repository_TEST_exlibs.cc
index 485f2c9..8f4a1ee 100644
--- a/paludis/repositories/e/e_repository_TEST_exlibs.cc
+++ b/paludis/repositories/e/e_repository_TEST_exlibs.cc
@@ -195,6 +195,9 @@ namespace test_cases
ExlibsTest test_array_required("array-required", throws_UnsupportedActionError);
ExlibsTest test_illegal_in_global_scope("illegal-in-global-scope", throws_UnsupportedActionError);
ExlibsTest test_illegal_in_global_scope_in_func("illegal-in-global-scope-in-func", success);
+ ExlibsTest test_called_cross_phase("called-cross-phase", throws_InstallActionError);
+ ExlibsTest test_called_cross_phase_default("called-cross-phase-default", throws_InstallActionError);
+ ExlibsTest test_called_cross_phase_user_overridden("called-cross-phase-user-overridden", throws_InstallActionError);
ExlibsTest test_boolean("boolean", success);
ExlibsTest test_boolean_badvalue("boolean-badvalue", throws_UnsupportedActionError);
ExlibsTest test_boolean_blankvalue("boolean-blankvalue", throws_UnsupportedActionError);
diff --git a/paludis/repositories/e/e_repository_TEST_exlibs_setup.sh b/paludis/repositories/e/e_repository_TEST_exlibs_setup.sh
index ecbcd99..a4d236b 100755
--- a/paludis/repositories/e/e_repository_TEST_exlibs_setup.sh
+++ b/paludis/repositories/e/e_repository_TEST_exlibs_setup.sh
@@ -536,6 +536,46 @@ pkg_setup() {
f
}
END
+mkdir -p "packages/cat/called-cross-phase"
+cat <<'END' > packages/cat/called-cross-phase/called-cross-phase-1.ebuild || exit 1
+DESCRIPTION="The Long Description"
+SUMMARY="The Short Description"
+HOMEPAGE="http://example.com/"
+SLOT="0"
+LICENCES="GPL-2"
+
+src_unpack() {
+ pkg_setup
+}
+END
+mkdir -p "packages/cat/called-cross-phase-default"
+cat <<'END' > packages/cat/called-cross-phase-default/called-cross-phase-default-1.ebuild || exit 1
+DESCRIPTION="The Long Description"
+SUMMARY="The Short Description"
+HOMEPAGE="http://example.com/"
+SLOT="0"
+LICENCES="GPL-2"
+
+src_unpack() {
+ default_pkg_setup
+}
+END
+mkdir -p "packages/cat/called-cross-phase-user-overridden"
+cat <<'END' > packages/cat/called-cross-phase-user-overridden/called-cross-phase-user-overridden-1.ebuild || exit 1
+DESCRIPTION="The Long Description"
+SUMMARY="The Short Description"
+HOMEPAGE="http://example.com/"
+SLOT="0"
+LICENCES="GPL-2"
+
+pkg_setup() {
+ :
+}
+
+src_unpack() {
+ pkg_setup
+}
+END
cd ..
cd ..
diff --git a/paludis/repositories/e/ebuild/exheres-0/builtin_init.bash b/paludis/repositories/e/ebuild/exheres-0/builtin_init.bash
index 92cf00a..daab9be 100644
--- a/paludis/repositories/e/ebuild/exheres-0/builtin_init.bash
+++ b/paludis/repositories/e/ebuild/exheres-0/builtin_init.bash
@@ -73,6 +73,12 @@ builtin_init()
ebuild_load_em_up_dan
+ for a in ${PALUDIS_EBUILD_FUNCTIONS}; do
+ [[ $(type -t ${a}) == function ]] || continue
+ a="$(declare -f ${a})"
+ eval "${a/{/{ verify_not_called_cross_phase}"
+ done
+
for a in PALUDIS_NON_EMPTY_VARIABLES ${PALUDIS_NON_EMPTY_VARIABLES} ; do
a=${a#build:}
[[ -z "${!a}" ]] && die "\$${a} unset or empty"
diff --git a/paludis/repositories/e/ebuild/exheres-0/exlib_functions.bash b/paludis/repositories/e/ebuild/exheres-0/exlib_functions.bash
index a5727e9..5db1546 100644
--- a/paludis/repositories/e/ebuild/exheres-0/exlib_functions.bash
+++ b/paludis/repositories/e/ebuild/exheres-0/exlib_functions.bash
@@ -271,3 +271,10 @@ illegal_in_global_scope()
&& die "Exheres bug: ${FUNCNAME[1]} must not be called in global scope"
}
+verify_not_called_cross_phase() {
+ if [[ ${1:-${FUNCNAME[1]}} != $(paludis_phase_to_function_name "${!PALUDIS_EBUILD_PHASE_VAR}") ]] ; then
+ local correct_phase=${1:-${FUNCNAME[1]}#src_}; correct_phase=${correct_phase#pkg_}; correct_phase=${correct_phase#builtin_}
+ die "Exheres bug: ${FUNCNAME[1]} must only be called in the ${corect_phase} phase, was called in ${!PALUDIS_EBUILD_PHASE_VAR}"
+ fi
+}
+
diff --git a/paludis/repositories/e/ebuild/exheres-0/pkg_bad_options.bash b/paludis/repositories/e/ebuild/exheres-0/pkg_bad_options.bash
index 328b838..585c1ab 100644
--- a/paludis/repositories/e/ebuild/exheres-0/pkg_bad_options.bash
+++ b/paludis/repositories/e/ebuild/exheres-0/pkg_bad_options.bash
@@ -18,6 +18,7 @@
default_pkg_bad_options()
{
+ verify_not_called_cross_phase ${FUNCNAME[0]#default_}
eerror "The following option requirements are unmet for ${CATEGORY}/${PNVR}:"
local f
echo "${EX_UNMET_REQUIREMENTS}" | while IFS=$'\n' read f ; do
diff --git a/paludis/repositories/e/ebuild/exheres-0/pkg_config.bash b/paludis/repositories/e/ebuild/exheres-0/pkg_config.bash
index 6c57351..36d4df1 100644
--- a/paludis/repositories/e/ebuild/exheres-0/pkg_config.bash
+++ b/paludis/repositories/e/ebuild/exheres-0/pkg_config.bash
@@ -22,6 +22,7 @@
default_pkg_config()
{
+ verify_not_called_cross_phase ${FUNCNAME[0]#default_}
eerror "No configuration function is defined"
}
diff --git a/paludis/repositories/e/ebuild/exheres-0/pkg_info.bash b/paludis/repositories/e/ebuild/exheres-0/pkg_info.bash
index 5ff06be..241d659 100644
--- a/paludis/repositories/e/ebuild/exheres-0/pkg_info.bash
+++ b/paludis/repositories/e/ebuild/exheres-0/pkg_info.bash
@@ -18,6 +18,7 @@
default_pkg_info()
{
+ verify_not_called_cross_phase ${FUNCNAME[0]#default_}
:
}
diff --git a/paludis/repositories/e/ebuild/exheres-0/pkg_nofetch.bash b/paludis/repositories/e/ebuild/exheres-0/pkg_nofetch.bash
index 4e27f7a..3ec2bb9 100644
--- a/paludis/repositories/e/ebuild/exheres-0/pkg_nofetch.bash
+++ b/paludis/repositories/e/ebuild/exheres-0/pkg_nofetch.bash
@@ -22,6 +22,7 @@
default_pkg_nofetch()
{
+ verify_not_called_cross_phase ${FUNCNAME[0]#default_}
[[ -z "${ARCHIVES}" ]] && return
local f g=
diff --git a/paludis/repositories/e/ebuild/exheres-0/pkg_postinst.bash b/paludis/repositories/e/ebuild/exheres-0/pkg_postinst.bash
index ea5d457..dd8ddbb 100644
--- a/paludis/repositories/e/ebuild/exheres-0/pkg_postinst.bash
+++ b/paludis/repositories/e/ebuild/exheres-0/pkg_postinst.bash
@@ -22,6 +22,7 @@
default_pkg_postinst()
{
+ verify_not_called_cross_phase ${FUNCNAME[0]#default_}
:
}
diff --git a/paludis/repositories/e/ebuild/exheres-0/pkg_postrm.bash b/paludis/repositories/e/ebuild/exheres-0/pkg_postrm.bash
index c0777d3..50c6145 100644
--- a/paludis/repositories/e/ebuild/exheres-0/pkg_postrm.bash
+++ b/paludis/repositories/e/ebuild/exheres-0/pkg_postrm.bash
@@ -22,6 +22,7 @@
default_pkg_postrm()
{
+ verify_not_called_cross_phase ${FUNCNAME[0]#default_}
:
}
diff --git a/paludis/repositories/e/ebuild/exheres-0/pkg_preinst.bash b/paludis/repositories/e/ebuild/exheres-0/pkg_preinst.bash
index ee70aab..1f37459 100644
--- a/paludis/repositories/e/ebuild/exheres-0/pkg_preinst.bash
+++ b/paludis/repositories/e/ebuild/exheres-0/pkg_preinst.bash
@@ -22,6 +22,7 @@
default_pkg_preinst()
{
+ verify_not_called_cross_phase ${FUNCNAME[0]#default_}
:
}
diff --git a/paludis/repositories/e/ebuild/exheres-0/pkg_prerm.bash b/paludis/repositories/e/ebuild/exheres-0/pkg_prerm.bash
index 65ef54b..9f1e646 100644
--- a/paludis/repositories/e/ebuild/exheres-0/pkg_prerm.bash
+++ b/paludis/repositories/e/ebuild/exheres-0/pkg_prerm.bash
@@ -22,6 +22,7 @@
default_pkg_prerm()
{
+ verify_not_called_cross_phase ${FUNCNAME[0]#default_}
:
}
diff --git a/paludis/repositories/e/ebuild/exheres-0/pkg_pretend.bash b/paludis/repositories/e/ebuild/exheres-0/pkg_pretend.bash
index 0fc76a2..fababda 100644
--- a/paludis/repositories/e/ebuild/exheres-0/pkg_pretend.bash
+++ b/paludis/repositories/e/ebuild/exheres-0/pkg_pretend.bash
@@ -18,6 +18,7 @@
default_pkg_pretend()
{
+ verify_not_called_cross_phase ${FUNCNAME[0]#default_}
:
}
diff --git a/paludis/repositories/e/ebuild/exheres-0/pkg_setup.bash b/paludis/repositories/e/ebuild/exheres-0/pkg_setup.bash
index 82bd300..cc91fe9 100644
--- a/paludis/repositories/e/ebuild/exheres-0/pkg_setup.bash
+++ b/paludis/repositories/e/ebuild/exheres-0/pkg_setup.bash
@@ -22,6 +22,7 @@
default_pkg_setup()
{
+ verify_not_called_cross_phase ${FUNCNAME[0]#default_}
:
}
diff --git a/paludis/repositories/e/ebuild/exheres-0/src_compile.bash b/paludis/repositories/e/ebuild/exheres-0/src_compile.bash
index 7a1a83b..aa5238d 100644
--- a/paludis/repositories/e/ebuild/exheres-0/src_compile.bash
+++ b/paludis/repositories/e/ebuild/exheres-0/src_compile.bash
@@ -22,6 +22,7 @@
default_src_compile()
{
+ verify_not_called_cross_phase ${FUNCNAME[0]#default_}
ebuild_verify_not_changed_from_global_scope DEFAULT_SRC_COMPILE_PARAMS
if [[ -f Makefile ]] || [[ -f makefile ]] || [[ -f GNUmakefile ]] ; then
diff --git a/paludis/repositories/e/ebuild/exheres-0/src_configure.bash b/paludis/repositories/e/ebuild/exheres-0/src_configure.bash
index acc62d3..1de12a7 100644
--- a/paludis/repositories/e/ebuild/exheres-0/src_configure.bash
+++ b/paludis/repositories/e/ebuild/exheres-0/src_configure.bash
@@ -22,6 +22,7 @@
default_src_configure()
{
+ verify_not_called_cross_phase ${FUNCNAME[0]#default_}
ebuild_verify_not_changed_from_global_scope \
DEFAULT_SRC_CONFIGURE_PARAMS \
DEFAULT_SRC_CONFIGURE_OPTION_ENABLES \
diff --git a/paludis/repositories/e/ebuild/exheres-0/src_fetch_extra.bash b/paludis/repositories/e/ebuild/exheres-0/src_fetch_extra.bash
index 1e9d50c..b255f86 100644
--- a/paludis/repositories/e/ebuild/exheres-0/src_fetch_extra.bash
+++ b/paludis/repositories/e/ebuild/exheres-0/src_fetch_extra.bash
@@ -18,6 +18,7 @@
default_src_fetch_extra()
{
+ verify_not_called_cross_phase ${FUNCNAME[0]#default_}
:
}
diff --git a/paludis/repositories/e/ebuild/exheres-0/src_install.bash b/paludis/repositories/e/ebuild/exheres-0/src_install.bash
index 439a124..477b50a 100644
--- a/paludis/repositories/e/ebuild/exheres-0/src_install.bash
+++ b/paludis/repositories/e/ebuild/exheres-0/src_install.bash
@@ -22,6 +22,7 @@
default_src_install()
{
+ verify_not_called_cross_phase ${FUNCNAME[0]#default_}
ebuild_verify_not_changed_from_global_scope DEFAULT_SRC_INSTALL_PARAMS
local done_docs old_set f d p doc e
diff --git a/paludis/repositories/e/ebuild/exheres-0/src_prepare.bash b/paludis/repositories/e/ebuild/exheres-0/src_prepare.bash
index 04d3a9b..254ffd2 100644
--- a/paludis/repositories/e/ebuild/exheres-0/src_prepare.bash
+++ b/paludis/repositories/e/ebuild/exheres-0/src_prepare.bash
@@ -22,6 +22,7 @@
default_src_prepare()
{
+ verify_not_called_cross_phase ${FUNCNAME[0]#default_}
ebuild_verify_not_changed_from_global_scope DEFAULT_SRC_PREPARE_PATCHES
if [[ -n "${DEFAULT_SRC_PREPARE_PATCHES[@]}" ]]; then
diff --git a/paludis/repositories/e/ebuild/exheres-0/src_test.bash b/paludis/repositories/e/ebuild/exheres-0/src_test.bash
index 28e9f59..ea6a0a1 100644
--- a/paludis/repositories/e/ebuild/exheres-0/src_test.bash
+++ b/paludis/repositories/e/ebuild/exheres-0/src_test.bash
@@ -22,6 +22,7 @@
default_src_test()
{
+ verify_not_called_cross_phase ${FUNCNAME[0]#default_}
ebuild_verify_not_changed_from_global_scope DEFAULT_SRC_TEST_PARAMS
if [[ -f Makefile ]] || [[ -f GNUmakefile ]] || [[ -f makefile ]] ; then
diff --git a/paludis/repositories/e/ebuild/exheres-0/src_test_expensive.bash b/paludis/repositories/e/ebuild/exheres-0/src_test_expensive.bash
index f6136dd..c2064b9 100644
--- a/paludis/repositories/e/ebuild/exheres-0/src_test_expensive.bash
+++ b/paludis/repositories/e/ebuild/exheres-0/src_test_expensive.bash
@@ -22,6 +22,7 @@
default_src_test_expensive()
{
+ verify_not_called_cross_phase ${FUNCNAME[0]#default_}
:
}
diff --git a/paludis/repositories/e/ebuild/exheres-0/src_unpack.bash b/paludis/repositories/e/ebuild/exheres-0/src_unpack.bash
index 67fd083..fe6543b 100644
--- a/paludis/repositories/e/ebuild/exheres-0/src_unpack.bash
+++ b/paludis/repositories/e/ebuild/exheres-0/src_unpack.bash
@@ -22,6 +22,7 @@
default_src_unpack()
{
+ verify_not_called_cross_phase ${FUNCNAME[0]#default_}
[[ -n "${ARCHIVES}" ]] && unpack --if-compressed ${ARCHIVES}
}