mirror of
https://github.com/kata-containers/kata-containers.git
synced 2026-07-01 22:50:54 +00:00
kata-deploy: packaging: fix buggy return statements in cache check
The `install_cached_tarball_component` function in the binaries packaging script contained syntax errors where it attempted to capture the empty stdout of the `cleanup_and_fail` function inside a return statement (e.g., `return "$(cleanup_and_fail ...)"`). Since `cleanup_and_fail` only returns an exit status and produces no stdout, this evaluated to `return ""`, which is invalid in bash and causes the script to crash with `numeric argument required` instead of returning the failure status. Fix this by replacing the buggy inline returns with proper `if` blocks that call `cleanup_and_fail` and explicitly return `1`. Signed-off-by: Huy Pham <huypham@google.com>
This commit is contained in:
@@ -188,7 +188,7 @@ cleanup_and_fail_shim_v2_rust_specifics() {
|
||||
[[ -f "${root_hash_file}" ]] && rm -f "${root_hash_file}"
|
||||
done
|
||||
|
||||
return "$(cleanup_and_fail "${1:-}" "${2:-}")"
|
||||
cleanup_and_fail "${1:-}" "${2:-}"
|
||||
}
|
||||
|
||||
cleanup_and_fail() {
|
||||
@@ -272,12 +272,18 @@ install_cached_tarball_component() {
|
||||
rm -f "${component}"-version
|
||||
rm -f "${component}"-builder-image-version
|
||||
|
||||
[[ "${cached_image_version}" != "${current_image_version}" ]] && return "$(cleanup_and_fail "${component_tarball_path}" "${extra_tarballs}")"
|
||||
[[ "${cached_version}" != "${current_version}" ]] && return "$(cleanup_and_fail "${component_tarball_path}" "${extra_tarballs}")"
|
||||
sha256sum -c "${component}-sha256sum" || return "$(cleanup_and_fail "${component_tarball_path}" "${extra_tarballs}")"
|
||||
if [[ "${cached_image_version}" != "${current_image_version}" ]]; then
|
||||
cleanup_and_fail "${component_tarball_path}" "${extra_tarballs}"
|
||||
return 1
|
||||
fi
|
||||
if [[ "${cached_version}" != "${current_version}" ]]; then
|
||||
cleanup_and_fail "${component_tarball_path}" "${extra_tarballs}"
|
||||
return 1
|
||||
fi
|
||||
sha256sum -c "${component}-sha256sum" || { cleanup_and_fail "${component_tarball_path}" "${extra_tarballs}"; return 1; }
|
||||
|
||||
if [[ "${component}" = "shim-v2-rust" ]]; then
|
||||
install_cached_shim_v2_rust_tarball_compare_root_hashes || return "$(cleanup_and_fail_shim_v2_rust_specifics "${component_tarball_path}" "${extra_tarballs}")"
|
||||
install_cached_shim_v2_rust_tarball_compare_root_hashes || { cleanup_and_fail_shim_v2_rust_specifics "${component_tarball_path}" "${extra_tarballs}"; return 1; }
|
||||
fi
|
||||
|
||||
info "Using cached tarball of ${component}"
|
||||
|
||||
Reference in New Issue
Block a user