From e6baec0bc6c0871eaee63b59fa4e0b64bf575c6b Mon Sep 17 00:00:00 2001 From: awalsh128 Date: Thu, 30 Jun 2022 01:17:13 -0700 Subject: [PATCH] Fix cache version ref and ver function output. --- lib.sh | 2 +- pre_cache_action.sh | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib.sh b/lib.sh index 975fc3f..0c9ddd1 100755 --- a/lib.sh +++ b/lib.sh @@ -15,5 +15,5 @@ function get_package_name_ver { if test -z "${ver}"; then ver="$(grep "Version:" <<< "$(apt show ${name})" | awk '{print $2}')" fi - echo ""${name}"="${ver}"" + echo "${name}" "${ver}" } diff --git a/pre_cache_action.sh b/pre_cache_action.sh index 84d9868..2f26954 100755 --- a/pre_cache_action.sh +++ b/pre_cache_action.sh @@ -20,7 +20,7 @@ packages="$(normalize_package_list "${input_packages}")" mkdir -p ${cache_dir} echo -n "Validating action arguments (version='${version}', packages='${packages}')..."; -if grep -q " " <<< "${cache_version}"; then +if grep -q " " <<< "${version}"; then echo "aborted." echo "Version value '${version}' cannot contain spaces." >&2 exit 1 @@ -41,8 +41,9 @@ for package in ${packages}; do echo "aborted." echo "Package '${package}' not found." >&2 exit 3 - fi - versioned_packages=""${versioned_packages}" "$(get_package_name_ver "${package}")"" + fi + read package_name package_ver < <(get_package_name_ver "${package}") # -> package_name, package_ver + versioned_packages=""${versioned_packages}" "${package_name}"="${package_ver}"" done echo "done." @@ -55,7 +56,7 @@ echo "Creating cache key..." normalized_versioned_packages="$(normalize_package_list "${versioned_packages}")" echo "- Normalized package list is '${normalized_versioned_packages}'." -value="$(echo "${normalized_versioned_packages} @ ${cache_version}")" +value="$(echo "${normalized_versioned_packages} @ ${version}")" echo "- Value to hash is '${value}'." key="$(echo "${value}" | md5sum | /bin/cut -f1 -d' ')"