mirror of
https://github.com/awalsh128/cache-apt-pkgs-action.git
synced 2025-09-20 01:57:16 +00:00
chore: descriptive variable names and use log_err
Added the review feedback, updating variable names to be more descriptive and using log_err where appropriate.
This commit is contained in:
parent
58b7390736
commit
52d1d96a40
34
lib.sh
34
lib.sh
|
@ -82,7 +82,7 @@ function get_package_name_ver {
|
||||||
# If version not found in the fully qualified package value.
|
# If version not found in the fully qualified package value.
|
||||||
if test -z "${ver}"; then
|
if test -z "${ver}"; then
|
||||||
# This is a fallback and should not be used any more as its slow.
|
# This is a fallback and should not be used any more as its slow.
|
||||||
log_err "Unexpected version resolution for package '${name}'..."
|
log_err "Unexpected version resolution for package '${name}'"
|
||||||
ver="$(apt-cache show ${name} | grep '^Version:' | awk '{print $2}')"
|
ver="$(apt-cache show ${name} | grep '^Version:' | awk '{print $2}')"
|
||||||
fi
|
fi
|
||||||
echo "${name}" "${ver}"
|
echo "${name}" "${ver}"
|
||||||
|
@ -99,9 +99,9 @@ function get_normalized_package_list {
|
||||||
# Remove commas, and block scalar folded backslashes,
|
# Remove commas, and block scalar folded backslashes,
|
||||||
# extraneous spaces at the middle, beginning and end
|
# extraneous spaces at the middle, beginning and end
|
||||||
# then sort.
|
# then sort.
|
||||||
packages=$(echo "${1}" | \
|
packages=$(echo "${1}" \
|
||||||
sed 's/[,\]/ /g; s/\s\+/ /g; s/^\s\+//g; s/\s\+$//g' | \
|
| sed 's/[,\]/ /g; s/\s\+/ /g; s/^\s\+//g; s/\s\+$//g' \
|
||||||
sort -t' ')
|
| sort -t' ')
|
||||||
|
|
||||||
# Validate package names and get versions.
|
# Validate package names and get versions.
|
||||||
log_err "resolving package versions..."
|
log_err "resolving package versions..."
|
||||||
|
@ -113,29 +113,29 @@ function get_normalized_package_list {
|
||||||
IFS=$'\n'
|
IFS=$'\n'
|
||||||
declare -A missing
|
declare -A missing
|
||||||
local package_versions=''
|
local package_versions=''
|
||||||
local pkg='' sep=''
|
local package='' separator=''
|
||||||
for v in ${data}; do
|
for key_value in ${data}; do
|
||||||
local key="${v%%: *}"
|
local key="${key_value%%: *}"
|
||||||
local val="${v##*: }"
|
local value="${key_value##*: }"
|
||||||
|
|
||||||
case $key in
|
case $key in
|
||||||
Package)
|
Package)
|
||||||
pkg=$val
|
package=$value
|
||||||
;;
|
;;
|
||||||
Version)
|
Version)
|
||||||
package_versions="${package_versions}${sep}"${pkg}=${val}""
|
package_versions="${package_versions}${separator}"${package}=${value}""
|
||||||
sep=' '
|
separator=' '
|
||||||
;;
|
;;
|
||||||
N)
|
N)
|
||||||
# Warning messages.
|
# Warning messages.
|
||||||
case $val in
|
case $value in
|
||||||
'Unable to locate package '*)
|
'Unable to locate package '*)
|
||||||
pkg="${val#'Unable to locate package '}"
|
package="${value#'Unable to locate package '}"
|
||||||
# Avoid duplicate messages.
|
# Avoid duplicate messages.
|
||||||
if [ -z "${missing[$pkg]}" ]; then
|
if [ -z "${missing[$package]}" ]; then
|
||||||
pkg="${val#'Unable to locate package '}"
|
package="${value#'Unable to locate package '}"
|
||||||
log "Package '${pkg}' not found." >&2
|
log_err "Package '${package}' not found."
|
||||||
missing[$pkg]=1
|
missing[$package]=1
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
Loading…
Reference in a new issue