github.com/canonical/ubuntu-image@v0.0.0-20240430122802-2202fe98b290/tests/lib/external/snapd-testing-tools/tools/tests.pkgs.apt.sh (about) 1 #!/bin/bash 2 3 remap_one() { 4 case "$1" in 5 man) 6 if os.query is-debian; then 7 echo "man-db" 8 else 9 echo "$1" 10 fi 11 ;; 12 printer-driver-cups-pdf) 13 if os.query is-debian || os.query is-trusty; then 14 echo "cups-pdf" 15 else 16 echo "$1" 17 fi 18 ;; 19 test-snapd-pkg-1) 20 echo "curseofwar" 21 ;; 22 test-snapd-pkg-2) 23 echo "robotfindskitten" 24 ;; 25 *) 26 echo "$1" 27 ;; 28 esac 29 } 30 31 cmd_install() { 32 apt-get update 33 34 local APT_FLAGS="--yes" 35 while [ -n "$1" ]; do 36 case "$1" in 37 --no-install-recommends) 38 APT_FLAGS="$APT_FLAGS --no-install-recommends" 39 shift 40 ;; 41 *) 42 break 43 ;; 44 esac 45 done 46 # shellcheck disable=SC2068,SC2086 47 apt-get install $APT_FLAGS $@ 48 } 49 50 cmd_is_installed() { 51 dpkg -S "$1" >/dev/null 2>&1 52 } 53 54 cmd_query() { 55 apt-cache policy "$1" 56 } 57 58 cmd_list_installed() { 59 apt list --installed | cut -d/ -f1 | sort 60 } 61 62 cmd_remove() { 63 # shellcheck disable=SC2068 64 apt-get remove --yes $@ 65 }