diff options
author | Shih-Yuan Lee (FourDollars) <sylee@canonical.com> | 2022-01-04 20:31:06 +0800 |
---|---|---|
committer | Shih-Yuan Lee (FourDollars) <sylee@canonical.com> | 2022-01-05 16:17:50 +0800 |
commit | cf1df249bfcec3ffaa6b616c125e5ec04b7d52c8 (patch) | |
tree | 3155aa622fd644d6e6af084dee5a725b20036f65 /bin | |
parent | c44c4af4e3213cbe70a169d480ae7a0fd833cb24 (diff) |
Add: check if all recommended packages of ubuntu-desktop are installed.
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/check-ubuntu-desktop-recommends.sh | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/bin/check-ubuntu-desktop-recommends.sh b/bin/check-ubuntu-desktop-recommends.sh new file mode 100755 index 0000000..edda52e --- /dev/null +++ b/bin/check-ubuntu-desktop-recommends.sh @@ -0,0 +1,21 @@ +#!/bin/bash +set -euo pipefail +IFS=$'\n\t' + +noninstalled=() +while read -r pkg; do + # libreoffice-impress provides libreoffice-ogltrans, and libreoffice-ogltrans becomes a transitional package on Ubuntu 20.04. + # shellcheck disable=SC2016 + if ! dpkg-query -W -f='${Status}\n' "$pkg" 2>&1 | grep "install ok installed" >/dev/null 2>&1 && [ "$pkg" != "libreoffice-ogltrans" ]; then + noninstalled+=("$pkg") + fi +done < <(apt-cache show ubuntu-desktop | grep ^Recommends | head -n 1 | cut -d : -f 2- | xargs | sed 's/ //g' | tr , $'\n') + +if [ -n "${noninstalled[*]}" ]; then + IFS=' ' + echo "${noninstalled[*]} are not installed." + exit 1 +fi + +echo "All packages in Recommends of ubuntu-desktop are installed." +exit 0 |