From f3c663103a4661f189ab9b4b147411d625e9418a Mon Sep 17 00:00:00 2001 From: Michele Locati Date: Mon, 23 Dec 2019 12:40:28 +0100 Subject: [PATCH] Improve package install errors handling --- install-php-extensions | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/install-php-extensions b/install-php-extensions index 76fa701..63134d8 100755 --- a/install-php-extensions +++ b/install-php-extensions @@ -564,15 +564,13 @@ buildRequiredPackageLists() { esac if test -n "$buildRequiredPackageLists_persistent"; then PACKAGES_PERSISTENT="$(expandPackagesToBeInstalled $buildRequiredPackageLists_persistent)" - if test -s "$IPE_ERRFILE"; then - cat "$IPE_ERRFILE" >&2 + if test -s "$IPE_ERRFLAG_FILE"; then exit 1 fi fi if test -n "$buildRequiredPackageLists_volatile"; then buildRequiredPackageLists_packages="$(expandPackagesToBeInstalled $buildRequiredPackageLists_volatile)" - if test -s "$IPE_ERRFILE"; then - cat "$IPE_ERRFILE" >&2 + if test -s "$IPE_ERRFLAG_FILE"; then exit 1 fi resetIFS @@ -598,9 +596,10 @@ expandPackagesToBeInstalled() { alpine) expandPackagesToBeInstalled_log="$(apk add --simulate $@ 2>&1 || printf '\nERROR: apk failed\n')" if test -n "$(printf '%s' "$expandPackagesToBeInstalled_log" | grep -E '^ERROR:')"; then - printf 'FAILED TO LIST THE WHOLE PACKAGE LIST FOR\n' >"$IPE_ERRFILE" - printf '%s ' "$@" >>"$IPE_ERRFILE" - printf '\n\nCOMMAND OUTPUT:\n%s\n' "$expandPackagesToBeInstalled_log" >>"$IPE_ERRFILE" + printf 'FAILED TO LIST THE WHOLE PACKAGE LIST FOR\n' >&2 + printf '%s ' "$@" >&2 + printf '\n\nCOMMAND OUTPUT:\n%s\n' "$expandPackagesToBeInstalled_log" >&2 + echo 'y' >"$IPE_ERRFLAG_FILE" exit 1 fi IFS=' @@ -615,9 +614,10 @@ expandPackagesToBeInstalled() { debian) expandPackagesToBeInstalled_log="$(DEBIAN_FRONTEND=noninteractive apt-get install -sy $@ 2>&1 || printf '\nE: apt-get failed\n')" if test -n "$(printf '%s' "$expandPackagesToBeInstalled_log" | grep -E '^E:')"; then - printf 'FAILED TO LIST THE WHOLE PACKAGE LIST FOR\n' >"$IPE_ERRFILE" - printf '%s ' "$@" >"$IPE_ERRFILE" - printf '\n\nCOMMAND OUTPUT:\n%s\n' "$expandPackagesToBeInstalled_log" >"$IPE_ERRFILE" + printf 'FAILED TO LIST THE WHOLE PACKAGE LIST FOR\n' >&2 + printf '%s ' "$@" >&2 + printf '\n\nCOMMAND OUTPUT:\n%s\n' "$expandPackagesToBeInstalled_log" >&2 + echo 'y' >"$IPE_ERRFLAG_FILE" exit 1 fi expandPackagesToBeInstalled_inNewPackages=0 @@ -1138,7 +1138,7 @@ cleanup() { resetIFS mkdir -p /tmp/src -IPE_ERRFILE="$(mktemp -p /tmp/src)" +IPE_ERRFLAG_FILE="$(mktemp -p /tmp/src)" PHP_MAJMIN_VERSION=$(getPHPMajorMinor) case "$PHP_MAJMIN_VERSION" in 506 | 700 | 701 | 702 | 703 | 704) ;;