2022-07-19 20:42:48 -07:00
|
|
|
#!/bin/bash
|
2022-03-26 12:42:40 -07:00
|
|
|
|
|
|
|
# Sort these packages by name and split on commas.
|
|
|
|
function normalize_package_list {
|
2022-07-19 20:42:48 -07:00
|
|
|
local stripped=$(echo "${1}" | sed 's/,//g')
|
2022-03-26 12:42:40 -07:00
|
|
|
# Remove extraneous spaces at the middle, beginning, and end.
|
2022-07-19 20:42:48 -07:00
|
|
|
local trimmed="$(echo "${stripped}" | sed 's/\s\+/ /g; s/^\s\+//g; s/\s\+$//g')"
|
|
|
|
local sorted="$(echo ${trimmed} | tr ' ' '\n' | sort | tr '\n' ' ')"
|
|
|
|
echo "${sorted}"
|
|
|
|
}
|
|
|
|
|
|
|
|
# Gets a package list of dependencies as common delimited pairs
|
|
|
|
# <name>:<version>,<name:version>...
|
|
|
|
function get_dep_packages {
|
|
|
|
echo $(apt-get install --dry-run --yes "${1}" | \
|
|
|
|
grep "^Inst" | sort | awk '{print $2 $3}' | \
|
|
|
|
tr '(' ':' | grep -v "${1}:")
|
2022-03-26 12:42:40 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
# Split fully qualified package into name and version
|
|
|
|
function get_package_name_ver {
|
2022-07-19 20:42:48 -07:00
|
|
|
IFS=\: read name ver <<< "${1}"
|
2022-03-26 12:42:40 -07: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-07-19 20:42:48 -07:00
|
|
|
echo "${name}" "${ver}"
|
2022-03-26 12:42:40 -07:00
|
|
|
}
|
2022-07-19 20:42:48 -07:00
|
|
|
|
|
|
|
function log { echo "$(date +%H:%M:%S)" "${@}"; }
|
|
|
|
|
2022-07-15 15:38:51 -07:00
|
|
|
function write_manifest {
|
|
|
|
echo "manifest list ${1}"
|
2022-07-19 20:42:48 -07:00
|
|
|
log "Writing ${1} packages manifest to ${3}..."
|
|
|
|
# 0:-1 to remove trailing comma, delimit by newline and sort
|
|
|
|
echo "${2:0:-1}" | tr ',' '\n' | sort > ${3}
|
|
|
|
log "done."
|
|
|
|
}
|