From 2d675acd6bbd16cac8f8d08ade777177dad0416b Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 10 Apr 2022 17:47:54 +0200 Subject: [PATCH] Fix handling apt install errors in install script Logging the error code reset it (as echo executed successfully), so save it first. Also check for the failure of the second attempt to run apt too. --- build/tools/before_install.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/build/tools/before_install.sh b/build/tools/before_install.sh index 6cddd918eb..a10fa314d6 100755 --- a/build/tools/before_install.sh +++ b/build/tools/before_install.sh @@ -22,9 +22,10 @@ case $(uname -s) in # Disable some (but not all) output. $SUDO apt-get -q -o=Dpkg::Use-Pty=0 "$@" - echo "-> Done with $?" + rc=$? + echo "-> Done with $rc" - return $? + return $rc } if [ "$wxUSE_ASAN" = 1 ]; then @@ -81,13 +82,15 @@ case $(uname -s) in if ! run_apt install -y $pkg_install $dbgsym_pkgs; then if [ -z "$dbgsym_pkgs" ]; then - exit $? + exit 1 fi # Retry without dbgsym packages that currently fail to install # under Ubuntu Focal (20.04). echo 'Installing with dbgsym packages failed, retrying without...' - run_apt install -y $pkg_install + if ! run_apt install -y $pkg_install; then + exit 1 + fi else touch wx_dbgsym_available fi