From e40d1ce99ba7af086eb202319f71602d09374fdb Mon Sep 17 00:00:00 2001 From: Torsten Marco Knodt <191793499+torsknod2@users.noreply.github.com> Date: Sun, 12 Jan 2025 14:42:37 +0000 Subject: [PATCH 1/2] Fall back to install_and_cache_pkg.sh if restore_pkg.sh fails --- post_cache_action.sh | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/post_cache_action.sh b/post_cache_action.sh index f71c336..9a9b35f 100755 --- a/post_cache_action.sh +++ b/post_cache_action.sh @@ -28,10 +28,6 @@ test "${debug}" = "true" && set -x # List of the packages to use. packages="${@:6}" -if test "${cache_hit}" = "true"; then - ${script_dir}/restore_pkgs.sh "${cache_dir}" "${cache_restore_root}" "${execute_install_scripts}" "${debug}" -else - ${script_dir}/install_and_cache_pkgs.sh "${cache_dir}" "${debug}" ${packages} -fi +([ "${cache_hit}" = "true" ] && ${script_dir}/restore_pkgs.sh "${cache_dir}" "${cache_restore_root}" "${execute_install_scripts}" "${debug}") || ${script_dir}/install_and_cache_pkgs.sh "${cache_dir}" "${debug}" ${packages} log_empty_line From 17ab10b5acb112df5c8f8fe83a91a4d5019eb41d Mon Sep 17 00:00:00 2001 From: Torsten Marco Knodt <191793499+torsknod2@users.noreply.github.com> Date: Sun, 12 Jan 2025 16:07:40 +0000 Subject: [PATCH 2/2] Hopefully fail not restore_pkgs.sh with exit code on errors to install_and_cache_pkgs.sh is really run on error. --- restore_pkgs.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/restore_pkgs.sh b/restore_pkgs.sh index 418f9f0..0732249 100755 --- a/restore_pkgs.sh +++ b/restore_pkgs.sh @@ -1,7 +1,9 @@ #!/bin/bash # Fail on any error. -set -e +set -eET -o pipefail + +trap 'exit -1' ERR # Debug mode for diagnosing issues. # Setup first before other operations. @@ -50,7 +52,7 @@ for cached_filepath in ${cached_filepaths}; do sudo tar -xf "${cached_filepath}" -C "${cache_restore_root}" > /dev/null log " done" - # Execute install scripts if available. + # Execute install scripts if available. if test ${execute_install_scripts} == "true"; then # May have to add more handling for extracting pre-install script before extracting all files. # Keeping it simple for now.