X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/3196dae8e92407b3aa8e12779a8ed7db998ebdc4..2906182db398419a9c59a928b7ae73cf7c7aa307:/test/integration/test-kernel-helper-autoremove diff --git a/test/integration/test-kernel-helper-autoremove b/test/integration/test-kernel-helper-autoremove index a110d5d52..a70841d9d 100755 --- a/test/integration/test-kernel-helper-autoremove +++ b/test/integration/test-kernel-helper-autoremove @@ -1,12 +1,12 @@ #!/bin/sh set -e -TESTDIR=$(readlink -f $(dirname $0)) -. $TESTDIR/framework +TESTDIR="$(readlink -f "$(dirname "$0")")" +. "$TESTDIR/framework" setupenvironment configarchitecture 'amd64' -CURRENTKERNEL="linux-image-$(uname -r)" +CURRENTKERNEL="linux-image-$(uname -r | tr '[A-Z]' '[a-z]')" insertinstalledpackage "$CURRENTKERNEL" 'amd64' '5-1' # debug packages do not need our protection insertinstalledpackage "${CURRENTKERNEL}-dbg" 'amd64' '5-1' @@ -21,15 +21,17 @@ insertinstalledpackage 'linux-image-amd64' 'amd64' '200-1' insertinstalledpackage 'linux-image-686-pae' 'i386' '300-1' # ensure that the '.' is really a dot and not a wildcard insertinstalledpackage 'linux-headers-1000000-1-generic' 'amd64' '100.0.0-1' +# ensure that the '+' is really a plus and not a regexp quantifier +insertinstalledpackage "${CURRENTKERNEL}+variant" 'amd64' '5-1' testsuccess aptmark auto "$CURRENTKERNEL" "${CURRENTKERNEL}-dbg" "${CURRENTKERNEL}-686-pae:i386" "${CURRENTKERNEL}-rt" \ - 'linux-image-1.0.0-2-generic' 'linux-image-100.0.0-1-generic' 'linux-headers-1000000-1-generic' + 'linux-image-1.0.0-2-generic' 'linux-image-100.0.0-1-generic' 'linux-headers-1000000-1-generic' "${CURRENTKERNEL}+variant" testsuccess aptmark hold "${CURRENTKERNEL}-rt" testprotected() { rm -f rootdir/etc/apt/apt.conf.d/01autoremove-kernels protected.list - testsuccess runapt sh ${TESTDIR}/../../debian/apt.auto-removal.sh "$@" + testsuccess runapt sh "${TESTDIR}/../../debian/apt.auto-removal.sh" "$@" testfailure test -s rootdir/tmp/testsuccess.output msgtest 'Check kernel autoremoval protection list' 'is created' @@ -47,12 +49,16 @@ testprotected() { testsuccess --nomsg grep '^\^linux-image-100\\\.0\\\.0-1-generic\$$' protected.list msgtest 'Check kernel autoremoval protection list includes' 'running kernel' - testsuccess --nomsg grep "^\\^linux-image-$(uname -r | sed -e 's#\.#\\\\.#g')\\\$\$" protected.list + testsuccess --nomsg grep "^\\^linux-image-$(uname -r | tr '[A-Z]' '[a-z]' | sed -e 's#\.#\\\\.#g')\\\$\$" protected.list msgtest 'Check kernel autoremoval protection list does not include' 'metapackages' testfailure --nomsg grep -e '^\^linux-image-amd64\$$' -e '^\^linux-image-686-pae\$$' -e ':i386' protected.list } +AUTOREMOVE='apt autoremove' +if [ -n "$SUDO_USER" ]; then + AUTOREMOVE="sudo $AUTOREMOVE" +fi testsuccessequal "Reading package lists... Building dependency tree... Reading state information... @@ -61,9 +67,10 @@ The following packages were automatically installed and are no longer required: linux-image-1.0.0-2-generic (1.0.0-2) linux-image-100.0.0-1-generic (100.0.0-1) $CURRENTKERNEL (5-1) + ${CURRENTKERNEL}+variant (5-1) ${CURRENTKERNEL}-686-pae:i386 (5-1) ${CURRENTKERNEL}-dbg (5-1) -Use 'apt-get autoremove' to remove them. +Use '$AUTOREMOVE' to remove them. 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded." aptget install -sV testsuccessequal "Reading package lists... Building dependency tree... @@ -73,16 +80,17 @@ The following packages were automatically installed and are no longer required: linux-image-1.0.0-2-generic (1.0.0-2) linux-image-100.0.0-1-generic (100.0.0-1) $CURRENTKERNEL (5-1) + ${CURRENTKERNEL}+variant (5-1) ${CURRENTKERNEL}-686-pae:i386 (5-1) ${CURRENTKERNEL}-dbg (5-1) ${CURRENTKERNEL}-rt (5-1) -Use 'apt-get autoremove' to remove them. +Use '$AUTOREMOVE' to remove them. 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded." aptget install -sV --ignore-hold testequal "Reading package lists... Building dependency tree... Reading state information... -6 packages were automatically installed and are no longer required. -Use 'apt-get autoremove' to remove them. +7 packages were automatically installed and are no longer required. +Use '$AUTOREMOVE' to remove them. 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded." aptget install -s -o APT::Get::HideAutoRemove=small testequal "Reading package lists... Building dependency tree... @@ -92,13 +100,15 @@ The following packages will be REMOVED: linux-image-1.0.0-2-generic (1.0.0-2) linux-image-100.0.0-1-generic (100.0.0-1) $CURRENTKERNEL (5-1) + ${CURRENTKERNEL}+variant (5-1) ${CURRENTKERNEL}-686-pae:i386 (5-1) ${CURRENTKERNEL}-dbg (5-1) -0 upgraded, 0 newly installed, 6 to remove and 0 not upgraded. +0 upgraded, 0 newly installed, 7 to remove and 0 not upgraded. Remv linux-headers-1000000-1-generic [100.0.0-1] Remv linux-image-1.0.0-2-generic [1.0.0-2] Remv linux-image-100.0.0-1-generic [100.0.0-1] Remv $CURRENTKERNEL [5-1] +Remv ${CURRENTKERNEL}+variant [5-1] Remv ${CURRENTKERNEL}-686-pae:i386 [5-1] Remv ${CURRENTKERNEL}-dbg [5-1]" aptget autoremove -sV