]> git.saurik.com Git - apt.git/blobdiff - test/integration/test-apt-get-clean
eipp: add Allow-Temporary-Remove-of-Essentials
[apt.git] / test / integration / test-apt-get-clean
index 78cb95d746d48e362dc9654a43b5c4e8069faffa..d050732186b16ad4860c029c3dd76b409e1b9d44 100755 (executable)
@@ -1,14 +1,15 @@
 #!/bin/sh
 set -e
 
-TESTDIR=$(readlink -f $(dirname $0))
-. $TESTDIR/framework
+TESTDIR="$(readlink -f "$(dirname "$0")")"
+. "$TESTDIR/framework"
 
 setupenvironment
 configarchitecture 'amd64'
 
 insertpackage 'testing' 'foo' 'all' '1'
 insertpackage 'unstable' 'foo' 'all' '2'
+insertpackage 'experimental' 'foo' 'all' '1:1'
 insertinstalledpackage 'foo' 'all' '3'
 
 setupaptarchive --no-update
@@ -21,21 +22,47 @@ testsuccess aptget clean
 testsuccess aptget clean -s
 
 # generate some dirt and clean it up
-touch rootdir/var/lib/apt/lists/partial/http.debian.net_debian_dists_sid_main_i18n_Translation-en
-mkdir -p rootdir/var/cache/apt/archives/lost+found
-touch rootdir/var/cache/apt/archives/foo_1_all.deb
-touch rootdir/var/cache/apt/archives/foo_2_all.deb
-touch rootdir/var/cache/apt/archives/foo_3_all.deb
-touch rootdir/var/cache/apt/archives/foo_4_all.deb
+generatedirt() {
+       touch rootdir/var/lib/apt/lists/partial/http.debian.net_debian_dists_sid_main_i18n_Translation-en
+       mkdir -p rootdir/var/cache/apt/archives/lost+found
+       touch rootdir/var/cache/apt/archives/foo_1_all.deb
+       touch rootdir/var/cache/apt/archives/foo_1%3a1_all.deb
+       touch rootdir/var/cache/apt/archives/foo_2%3a1_all.deb
+       touch rootdir/var/cache/apt/archives/foo_2_all.deb
+       touch rootdir/var/cache/apt/archives/foo_3_all.deb
+       touch rootdir/var/cache/apt/archives/foo_4_all.deb
+}
 
-testsuccess aptget clean
+generatedirt
+testsuccess aptget autoclean
+testsuccess test -e rootdir/var/lib/apt/lists/partial/http.debian.net_debian_dists_sid_main_i18n_Translation-en
+testsuccess test -e rootdir/var/cache/apt/archives/foo_1_all.deb
+testsuccess test -e rootdir/var/cache/apt/archives/foo_1%3a1_all.deb
+testfailure test -e rootdir/var/cache/apt/archives/foo_2%3a1_all.deb
+testsuccess test -e rootdir/var/cache/apt/archives/foo_2_all.deb
+testfailure test -e rootdir/var/cache/apt/archives/foo_3_all.deb
+testfailure test -e rootdir/var/cache/apt/archives/foo_4_all.deb
 
+generatedirt
+testsuccess aptget clean
 testfailure test -e rootdir/var/lib/apt/lists/partial/http.debian.net_debian_dists_sid_main_i18n_Translation-en
 testfailure test -e rootdir/var/cache/apt/archives/foo_1_all.deb
+testfailure test -e rootdir/var/cache/apt/archives/foo_1%3a1_all.deb
+testfailure test -e rootdir/var/cache/apt/archives/foo_2%3a1_all.deb
 testfailure test -e rootdir/var/cache/apt/archives/foo_2_all.deb
 testfailure test -e rootdir/var/cache/apt/archives/foo_3_all.deb
 testfailure test -e rootdir/var/cache/apt/archives/foo_4_all.deb
 
+if [ "$(id -u)" != '0' ]; then
+       msgmsg 'No clean if lock can not be acquired'
+       touch rootdir/var/cache/apt/archives/foo_4_all.deb
+       touch rootdir/var/cache/apt/archives/lock
+       chmod 444 rootdir/var/cache/apt/archives/lock
+       testfailure apt clean
+       testsuccess test -e rootdir/var/cache/apt/archives/foo_4_all.deb
+       chmod 644 rootdir/var/cache/apt/archives/lock
+fi
+
 directorygone() {
        rm -rf "$1"
        testsuccess apt autoclean