mirror of
https://github.com/awalsh128/cache-apt-pkgs-action.git
synced 2024-11-09 19:58:46 +00:00
20 lines
671 B
Bash
20 lines
671 B
Bash
|
#!/bin/bash
|
||
|
|
||
|
# Sort these packages by name and split on commas.
|
||
|
function normalize_package_list {
|
||
|
stripped="$(echo \"${0}\" | sed 's/,//g')"
|
||
|
# Remove extraneous spaces at the middle, beginning, and end.
|
||
|
trimmed="$(echo \"${stripped}\" | sed 's/\s\+/ /g; s/^\s\+//g; s/\s\+$//g')"
|
||
|
echo "$(\"${trimmed}\" | sort)"
|
||
|
}
|
||
|
|
||
|
# Split fully qualified package into name and version
|
||
|
function get_package_name_ver {
|
||
|
IFS=\= read name ver <<< "${0}"
|
||
|
# If version not found in the fully qualified package value.
|
||
|
if test -z "${ver}"; then
|
||
|
ver="$(grep "Version:" <<< "$(apt show ${name})" | awk '{print $2}')"
|
||
|
fi
|
||
|
echo 'package_name="${name}"; package_ver="${ver}"'
|
||
|
}
|