|
|
|
@ -21,7 +21,6 @@ function debian_update_repo { |
|
|
|
function debian_add { |
|
|
|
debian_update_repo |
|
|
|
declare -a wanted=("$@") |
|
|
|
declare -a unrecognized=() |
|
|
|
declare -a missing=() |
|
|
|
mapfile -t queries < <(dpkg-query -W -f='${Package}: ${Status}\n' "${wanted[@]}" 2>&1 || true) |
|
|
|
|
|
|
|
@ -29,15 +28,13 @@ function debian_add { |
|
|
|
local missing_regex='(.*): .* not-installed$' |
|
|
|
for query in "${queries[@]}"; do |
|
|
|
if [[ "$query" =~ $unrecognized_regex ]]; then |
|
|
|
unrecognized+=("${BASH_REMATCH[1]}") |
|
|
|
missing+=("${BASH_REMATCH[1]}") |
|
|
|
elif [[ "$query" =~ $missing_regex ]]; then |
|
|
|
missing+=("${BASH_REMATCH[1]}") |
|
|
|
fi |
|
|
|
done |
|
|
|
|
|
|
|
if [[ ${#unrecognized[@]} -gt 0 ]]; then |
|
|
|
>&2 echo "$(basename "$0") error: unrecognized packages: ${unrecognized[*]}" && return 2 |
|
|
|
elif [[ "${#missing[@]}" -gt 0 ]]; then |
|
|
|
if [[ "${#missing[@]}" -gt 0 ]]; then |
|
|
|
echo installing packages: "${missing[@]}" |
|
|
|
apt-get install -y "${missing[@]}" |
|
|
|
fi |
|
|
|
|