mirror of
https://github.com/awalsh128/cache-apt-pkgs-action.git
synced 2026-11-13 21:36:56 +00:00
lib.sh disables errexit, so failures from package resolution, apt-fast install, and repository setup were ignored and an incomplete install could be cached. Check each of these explicitly and abort with a distinct exit code, and verify every requested package is installed before caching. - Report virtual packages with no providers (e.g. python on 22.04) with a clear error instead of a mangled "Reverse=Provides:" package (#166). - Stop reporting each apt_query error twice. - Guard logging.Debug against an uninitialized logger. - Add an abort helper to lib.sh and use it for all abort sites. - Add distribute.sh build-committed-binaries / check-committed-binaries and apt_query.srchash so PR CI fails when the committed binaries are stale (#166, #218). Release and committed builds share build_apt_query. - Rebuild the committed apt_query binaries. - Make the expected-failure tests actually fail when the action succeeds, and add regression tests for #166 and #221. Fixes #166 Fixes #221 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
42 lines
1.1 KiB
Bash
Executable file
42 lines
1.1 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
# Fail on any error.
|
|
set -e
|
|
|
|
# Include library.
|
|
script_dir="$(dirname -- "$(realpath -- "${0}")")"
|
|
source "${script_dir}/lib.sh"
|
|
|
|
# Directory that holds the cached packages.
|
|
cache_dir="${1}"
|
|
|
|
# Root directory to untar the cached packages to.
|
|
# Typically filesystem root '/' but can be changed for testing.
|
|
# WARNING: If non-root, this can cause errors during install script execution.
|
|
cache_restore_root="${2}"
|
|
|
|
# Indicates that the cache was found.
|
|
cache_hit="${3}"
|
|
|
|
# Cache and execute post install scripts on restore.
|
|
execute_install_scripts="${4}"
|
|
|
|
# Debug mode for diagnosing issues.
|
|
debug="${5}"
|
|
test "${debug}" = "true" && set -x
|
|
|
|
# Repositories to add before installing packages.
|
|
add_repository="${6}"
|
|
|
|
# List of the packages to use.
|
|
packages="${@:7}"
|
|
|
|
# Explicitly propagate failures since lib.sh disables errexit.
|
|
if test "${cache_hit}" = "true"; then
|
|
${script_dir}/restore_pkgs.sh "${cache_dir}" "${cache_restore_root}" "${execute_install_scripts}" "${debug}" || exit $?
|
|
else
|
|
${script_dir}/install_and_cache_pkgs.sh "${cache_dir}" "${debug}" "${add_repository}" ${packages} || exit $?
|
|
fi
|
|
|
|
log_empty_line
|