Improve apt/apk error logging

pull/68/head
Michele Locati 2019-12-19 15:59:08 +01:00
parent 441cd6760b
commit 40482177ab
No known key found for this signature in database
GPG Key ID: 98B7CE2E7234E28B
1 changed files with 8 additions and 4 deletions

View File

@ -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