commit:     66e4193a006529a15ecb13658eac02e218bad7e0
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Wed Jun  1 08:02:28 2022 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Tue Jun  7 06:53:51 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=66e4193a

python-utils-r1.eclass: Add explicit checks for incorrect phase

Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 eclass/python-utils-r1.eclass | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
index fd04cf374ce4..b9cf9c03caeb 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -696,6 +696,9 @@ python_scriptinto() {
 python_doexe() {
        debug-print-function ${FUNCNAME} "${@}"
 
+       [[ ${EBUILD_PHASE} != install ]] &&
+               die "${FUNCNAME} can only be used in src_install"
+
        local f
        for f; do
                python_newexe "${f}" "${f##*/}"
@@ -714,6 +717,8 @@ python_doexe() {
 python_newexe() {
        debug-print-function ${FUNCNAME} "${@}"
 
+       [[ ${EBUILD_PHASE} != install ]] &&
+               die "${FUNCNAME} can only be used in src_install"
        [[ ${EPYTHON} ]] || die 'No Python implementation set (EPYTHON is 
null).'
        [[ ${#} -eq 2 ]] || die "Usage: ${FUNCNAME} <path> <new-name>"
 
@@ -762,6 +767,9 @@ python_newexe() {
 python_doscript() {
        debug-print-function ${FUNCNAME} "${@}"
 
+       [[ ${EBUILD_PHASE} != install ]] &&
+               die "${FUNCNAME} can only be used in src_install"
+
        local _PYTHON_REWRITE_SHEBANG=1
        python_doexe "${@}"
 }
@@ -786,6 +794,9 @@ python_doscript() {
 python_newscript() {
        debug-print-function ${FUNCNAME} "${@}"
 
+       [[ ${EBUILD_PHASE} != install ]] &&
+               die "${FUNCNAME} can only be used in src_install"
+
        local _PYTHON_REWRITE_SHEBANG=1
        python_newexe "${@}"
 }
@@ -894,6 +905,8 @@ python_domodule() {
 python_doheader() {
        debug-print-function ${FUNCNAME} "${@}"
 
+       [[ ${EBUILD_PHASE} != install ]] &&
+               die "${FUNCNAME} can only be used in src_install"
        [[ ${EPYTHON} ]] || die 'No Python implementation set (EPYTHON is 
null).'
 
        local includedir=$(python_get_includedir)

Reply via email to