From ee4f756b75c42431debff9e4b85ac6ae9d5365fc Mon Sep 17 00:00:00 2001 From: Huy Pham Date: Wed, 20 May 2026 10:27:51 -0700 Subject: [PATCH] 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 --- .../local-build/kata-deploy-binaries.sh | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/tools/packaging/kata-deploy/local-build/kata-deploy-binaries.sh b/tools/packaging/kata-deploy/local-build/kata-deploy-binaries.sh index 824ba3e717..0e491eea8d 100755 --- a/tools/packaging/kata-deploy/local-build/kata-deploy-binaries.sh +++ b/tools/packaging/kata-deploy/local-build/kata-deploy-binaries.sh @@ -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}"