From cf1df249bfcec3ffaa6b616c125e5ec04b7d52c8 Mon Sep 17 00:00:00 2001 From: "Shih-Yuan Lee (FourDollars)" Date: Tue, 4 Jan 2022 20:31:06 +0800 Subject: Add: check if all recommended packages of ubuntu-desktop are installed. --- bin/check-ubuntu-desktop-recommends.sh | 21 +++++++++++++++++++++ units/miscellanea/jobs.pxu | 9 +++++++++ units/miscellanea/test-plan.pxu | 1 + 3 files changed, 31 insertions(+) create mode 100755 bin/check-ubuntu-desktop-recommends.sh 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 diff --git a/units/miscellanea/jobs.pxu b/units/miscellanea/jobs.pxu index ac0c9ae..785eebe 100644 --- a/units/miscellanea/jobs.pxu +++ b/units/miscellanea/jobs.pxu @@ -474,6 +474,15 @@ command: debsums -c _summary: Check the MD5 sums of installed Debian packages _description: Verify installed Debian package files against MD5 checksum lists from /var/lib/dpkg/info/*.md5sums. +plugin: shell +category_id: com.canonical.plainbox::miscellanea +estimated_duration: 60 +id: miscellanea/ubuntu-desktop-recommends +requires: package.name == 'ubuntu-desktop' +command: check-ubuntu-desktop-recommends.sh +_summary: Check if Debian packages in Recommends of ubuntu-desktop are installed +_description: Check if Debian packages in Recommends of ubuntu-desktop are installed + plugin: shell category_id: com.canonical.plainbox::miscellanea id: miscellanea/maas_user_check diff --git a/units/miscellanea/test-plan.pxu b/units/miscellanea/test-plan.pxu index a48e80f..b6e4de7 100644 --- a/units/miscellanea/test-plan.pxu +++ b/units/miscellanea/test-plan.pxu @@ -34,6 +34,7 @@ include: miscellanea/fan_stress_reaction miscellanea/debsums certification-status=blocker miscellanea/check_prerelease certification-status=blocker + miscellanea/ubuntu-desktop-recommends certification-status=blocker bootstrap_include: fwts -- cgit v1.2.3