]>
Commit | Line | Data |
---|---|---|
1 | #!/bin/sh | |
2 | set -e | |
3 | ||
4 | TESTDIR="$(readlink -f "$(dirname "$0")")" | |
5 | . "$TESTDIR/framework" | |
6 | ||
7 | setupenvironment | |
8 | configarchitecture 'amd64' | |
9 | ||
10 | insertpackage 'testing' 'foo' 'all' '1' | |
11 | insertpackage 'unstable' 'foo' 'all' '2' | |
12 | insertpackage 'experimental' 'foo' 'all' '1:1' | |
13 | insertinstalledpackage 'foo' 'all' '3' | |
14 | ||
15 | setupaptarchive --no-update | |
16 | ||
17 | mkdir -p rootdir/var/lib/apt/lists/lost+found | |
18 | testsuccess apt update | |
19 | ||
20 | # nothing to do always works | |
21 | testsuccess aptget clean | |
22 | testsuccess aptget clean -s | |
23 | ||
24 | # generate some dirt and clean it up | |
25 | generatedirt() { | |
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 | ||
36 | generatedirt | |
37 | testsuccess aptget autoclean | |
38 | testsuccess test -e rootdir/var/lib/apt/lists/partial/http.debian.net_debian_dists_sid_main_i18n_Translation-en | |
39 | testsuccess test -e rootdir/var/cache/apt/archives/foo_1_all.deb | |
40 | testsuccess test -e rootdir/var/cache/apt/archives/foo_1%3a1_all.deb | |
41 | testfailure test -e rootdir/var/cache/apt/archives/foo_2%3a1_all.deb | |
42 | testsuccess test -e rootdir/var/cache/apt/archives/foo_2_all.deb | |
43 | testfailure test -e rootdir/var/cache/apt/archives/foo_3_all.deb | |
44 | testfailure test -e rootdir/var/cache/apt/archives/foo_4_all.deb | |
45 | ||
46 | generatedirt | |
47 | testsuccess aptget clean | |
48 | testfailure test -e rootdir/var/lib/apt/lists/partial/http.debian.net_debian_dists_sid_main_i18n_Translation-en | |
49 | testfailure test -e rootdir/var/cache/apt/archives/foo_1_all.deb | |
50 | testfailure test -e rootdir/var/cache/apt/archives/foo_1%3a1_all.deb | |
51 | testfailure test -e rootdir/var/cache/apt/archives/foo_2%3a1_all.deb | |
52 | testfailure test -e rootdir/var/cache/apt/archives/foo_2_all.deb | |
53 | testfailure test -e rootdir/var/cache/apt/archives/foo_3_all.deb | |
54 | testfailure test -e rootdir/var/cache/apt/archives/foo_4_all.deb | |
55 | ||
56 | if [ "$(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 | |
64 | fi | |
65 | ||
66 | directorygone() { | |
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 | } | |
78 | msgmsg 'Partial directory missing' | |
79 | directorygone 'rootdir/var/cache/apt/archives/partial' | |
80 | directorygone 'rootdir/var/lib/apt/lists/partial' | |
81 | ||
82 | msgmsg 'Archives directory missing' | |
83 | directorygone 'rootdir/var/cache/apt/archives' | |
84 | directorygone 'rootdir/var/lib/apt/lists' | |
85 | ||
86 | msgmsg 'apt directory missing' | |
87 | directorygone 'rootdir/var/cache/apt' | |
88 | directorygone 'rootdir/var/lib/apt' |