2022-03-26 19:42:40 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Sort these packages by name and split on commas.
|
|
|
|
function normalize_package_list {
|
2022-06-30 07:51:24 +00:00
|
|
|
stripped=$(echo "${1}" | sed 's/,//g')
|
2022-03-26 19:42:40 +00:00
|
|
|
# Remove extraneous spaces at the middle, beginning, and end.
|
2022-06-30 07:51:24 +00:00
|
|
|
trimmed="$(echo "${stripped}" | sed 's/\s\+/ /g; s/^\s\+//g; s/\s\+$//g')"
|
|
|
|
echo "$(echo "${trimmed}" | sort)"
|
2022-03-26 19:42:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# Split fully qualified package into name and version
|
|
|
|
function get_package_name_ver {
|
2022-06-30 07:51:24 +00:00
|
|
|
IFS=\= read name ver <<< "${1}"
|
2022-03-26 19:42:40 +00:00
|
|
|
# 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
|
2022-06-30 08:17:13 +00:00
|
|
|
echo "${name}" "${ver}"
|
2022-03-26 19:42:40 +00:00
|
|
|
}
|
2022-06-30 14:13:58 +00:00
|
|
|
|
|
|
|
function log {
|
|
|
|
timestamp="$(echo -n "$(date +%H:%M:%S)")"
|
|
|
|
line=""${timestamp}" "$(echo ${@})""
|
|
|
|
if [[ "${1}" == "-n" ]]; then
|
|
|
|
echo -n "${line}"
|
|
|
|
else
|
|
|
|
echo "${line}"
|
|
|
|
fi
|
|
|
|
}
|