diff options
author | Mike Gilbert <floppym@gentoo.org> | 2022-07-11 15:48:48 -0400 |
---|---|---|
committer | Sam James <sam@gentoo.org> | 2022-07-12 00:01:04 +0100 |
commit | 50ac4e2e3401be2410a01f7d5d7923672b57798f (patch) | |
tree | 079f9ca965c15c424b849c8a9183496104c70f39 | |
parent | news: fix isRelevant check (diff) | |
download | portage-50ac4e2e3401be2410a01f7d5d7923672b57798f.tar.gz portage-50ac4e2e3401be2410a01f7d5d7923672b57798f.tar.bz2 portage-50ac4e2e3401be2410a01f7d5d7923672b57798f.zip |
Allow nested ebegin calls using a count variable
At the start of each phase, the count is set to 0.
The count is incremented each time ebegin is called.
If the count is equal to 0 when eend is called, a warning is output.
Otherwise, the count is decremented by 1.
At the end of each phase, if the count is greater than 0, a warning is
output.
Signed-off-by: Mike Gilbert <floppym@gentoo.org>
Closes: https://github.com/gentoo/portage/pull/854
Signed-off-by: Sam James <sam@gentoo.org>
-rw-r--r-- | bin/isolated-functions.sh | 12 | ||||
-rw-r--r-- | bin/phase-functions.sh | 8 |
2 files changed, 8 insertions, 12 deletions
diff --git a/bin/isolated-functions.sh b/bin/isolated-functions.sh index dea0d7f49..55c38fbb0 100644 --- a/bin/isolated-functions.sh +++ b/bin/isolated-functions.sh @@ -339,10 +339,7 @@ ebegin() { [[ ${RC_ENDCOL} == "yes" ]] && echo >&2 LAST_E_LEN=$(( 3 + ${#RC_INDENTATION} + ${#msg} )) LAST_E_CMD="ebegin" - if [[ -v EBEGIN_EEND ]] ; then - eqawarn "QA Notice: ebegin called, but missing call to eend (phase: ${EBUILD_PHASE})" - fi - EBEGIN_EEND=1 + let ++__EBEGIN_EEND_COUNT return 0 } @@ -371,10 +368,9 @@ __eend() { eend() { [[ -n $1 ]] || eqawarn "QA Notice: eend called without first argument" - if [[ -v EBEGIN_EEND ]] ; then - unset EBEGIN_EEND - else - eqawarn "QA Notice: eend called without preceding ebegin (phase: ${EBUILD_PHASE})" + if (( --__EBEGIN_EEND_COUNT < 0 )); then + __EBEGIN_EEND_COUNT=0 + eqawarn "QA Notice: eend called without preceding ebegin in ${FUNCNAME[1]}" fi local retval=${1:-0} shift diff --git a/bin/phase-functions.sh b/bin/phase-functions.sh index 25e25cc1e..84a5c1ec3 100644 --- a/bin/phase-functions.sh +++ b/bin/phase-functions.sh @@ -207,7 +207,11 @@ __preprocess_ebuild_env() { } __ebuild_phase() { + local __EBEGIN_EEND_COUNT=0 declare -F "$1" >/dev/null && __qa_call $1 + if (( __EBEGIN_EEND_COUNT > 0 )); then + eqawarn "QA Notice: ebegin called without eend in $1" + fi } __ebuild_phase_with_hooks() { @@ -1088,10 +1092,6 @@ __ebuild_main() { ;; esac - if [[ -v EBEGIN_EEND ]] ; then - eqawarn "QA Notice: ebegin called, but missing call to eend (phase: ${1})" - fi - # Save the env only for relevant phases. if ! has "${1}" clean help info nofetch ; then umask 002 |