From 40482177abba90191efddc6466af68846a4c87c1 Mon Sep 17 00:00:00 2001 From: Michele Locati Date: Thu, 19 Dec 2019 15:59:08 +0100 Subject: [PATCH] Improve apt/apk error logging --- install-php-extensions | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/install-php-extensions b/install-php-extensions index ed82ab4..215383c 100755 --- a/install-php-extensions +++ b/install-php-extensions @@ -565,9 +565,11 @@ expandPackagesToBeInstalled () { expandPackagesToBeInstalled_result='' case "$(getDistro)" in alpine) - expandPackagesToBeInstalled_log="$(apk add --simulate $@ 2>&1)" + 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 %s\n\n%s\n' "$@" "$expandPackagesToBeInstalled_log" >&2 + printf 'FAILED TO LIST THE WHOLE PACKAGE LIST FOR\n' >&2 + printf '%s ' "$@" >&2 + printf '\n\nCOMMAND OUTPUT:\n%s\n' "$expandPackagesToBeInstalled_log" >&2 exit 1 fi IFS=' @@ -580,9 +582,11 @@ expandPackagesToBeInstalled () { resetIFS ;; debian) - expandPackagesToBeInstalled_log="$(DEBIAN_FRONTEND=noninteractive apt-get install -sy $@ 2>&1)" + 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 %s\n\n%s\n' "$@" "$expandPackagesToBeInstalled_log" >&2 + printf 'FAILED TO LIST THE WHOLE PACKAGE LIST FOR\n' >&2 + printf '%s ' "$@" >&2 + printf '\n\nCOMMAND OUTPUT:\n%s\n' "$expandPackagesToBeInstalled_log" >&2 exit 1 fi expandPackagesToBeInstalled_inNewPackages=0