]> git.saurik.com Git - apt.git/blame_incremental - test/integration/test-apt-get-clean
eipp: add Allow-Temporary-Remove-of-Essentials
[apt.git] / test / integration / test-apt-get-clean
... / ...
CommitLineData
1#!/bin/sh
2set -e
3
4TESTDIR="$(readlink -f "$(dirname "$0")")"
5. "$TESTDIR/framework"
6
7setupenvironment
8configarchitecture 'amd64'
9
10insertpackage 'testing' 'foo' 'all' '1'
11insertpackage 'unstable' 'foo' 'all' '2'
12insertpackage 'experimental' 'foo' 'all' '1:1'
13insertinstalledpackage 'foo' 'all' '3'
14
15setupaptarchive --no-update
16
17mkdir -p rootdir/var/lib/apt/lists/lost+found
18testsuccess apt update
19
20# nothing to do always works
21testsuccess aptget clean
22testsuccess aptget clean -s
23
24# generate some dirt and clean it up
25generatedirt() {
26 touch rootdir/var/lib/apt/lists/partial/http.debian.net_debian_dists_sid_main_i18n_Translation-en
27 mkdir -p rootdir/var/cache/apt/archives/lost+found
28 touch rootdir/var/cache/apt/archives/foo_1_all.deb
29 touch rootdir/var/cache/apt/archives/foo_1%3a1_all.deb
30 touch rootdir/var/cache/apt/archives/foo_2%3a1_all.deb
31 touch rootdir/var/cache/apt/archives/foo_2_all.deb
32 touch rootdir/var/cache/apt/archives/foo_3_all.deb
33 touch rootdir/var/cache/apt/archives/foo_4_all.deb
34}
35
36generatedirt
37testsuccess aptget autoclean
38testsuccess test -e rootdir/var/lib/apt/lists/partial/http.debian.net_debian_dists_sid_main_i18n_Translation-en
39testsuccess test -e rootdir/var/cache/apt/archives/foo_1_all.deb
40testsuccess test -e rootdir/var/cache/apt/archives/foo_1%3a1_all.deb
41testfailure test -e rootdir/var/cache/apt/archives/foo_2%3a1_all.deb
42testsuccess test -e rootdir/var/cache/apt/archives/foo_2_all.deb
43testfailure test -e rootdir/var/cache/apt/archives/foo_3_all.deb
44testfailure test -e rootdir/var/cache/apt/archives/foo_4_all.deb
45
46generatedirt
47testsuccess aptget clean
48testfailure test -e rootdir/var/lib/apt/lists/partial/http.debian.net_debian_dists_sid_main_i18n_Translation-en
49testfailure test -e rootdir/var/cache/apt/archives/foo_1_all.deb
50testfailure test -e rootdir/var/cache/apt/archives/foo_1%3a1_all.deb
51testfailure test -e rootdir/var/cache/apt/archives/foo_2%3a1_all.deb
52testfailure test -e rootdir/var/cache/apt/archives/foo_2_all.deb
53testfailure test -e rootdir/var/cache/apt/archives/foo_3_all.deb
54testfailure test -e rootdir/var/cache/apt/archives/foo_4_all.deb
55
56if [ "$(id -u)" != '0' ]; then
57 msgmsg 'No clean if lock can not be acquired'
58 touch rootdir/var/cache/apt/archives/foo_4_all.deb
59 touch rootdir/var/cache/apt/archives/lock
60 chmod 444 rootdir/var/cache/apt/archives/lock
61 testfailure apt clean
62 testsuccess test -e rootdir/var/cache/apt/archives/foo_4_all.deb
63 chmod 644 rootdir/var/cache/apt/archives/lock
64fi
65
66directorygone() {
67 rm -rf "$1"
68 testsuccess apt autoclean
69 testfailure test -d "$1"
70 testsuccess apt clean
71 # clean creates an empty partial directory via GetLock
72 if [ "$(basename "$1")" = 'partial' ]; then
73 testsuccess test -d "$1"
74 else
75 testfailure test -d "$1"
76 fi
77}
78msgmsg 'Partial directory missing'
79directorygone 'rootdir/var/cache/apt/archives/partial'
80directorygone 'rootdir/var/lib/apt/lists/partial'
81
82msgmsg 'Archives directory missing'
83directorygone 'rootdir/var/cache/apt/archives'
84directorygone 'rootdir/var/lib/apt/lists'
85
86msgmsg 'apt directory missing'
87directorygone 'rootdir/var/cache/apt'
88directorygone 'rootdir/var/lib/apt'