]>
Commit | Line | Data |
---|---|---|
20e6965a DK |
1 | #!/bin/sh |
2 | set -e | |
3 | ||
3abb6a6a DK |
4 | TESTDIR="$(readlink -f "$(dirname "$0")")" |
5 | . "$TESTDIR/framework" | |
20e6965a DK |
6 | |
7 | setupenvironment | |
8 | configarchitecture 'amd64' | |
9 | ||
10 | insertpackage 'testing' 'foo' 'all' '1' | |
11 | insertpackage 'unstable' 'foo' 'all' '2' | |
a9e4fd65 | 12 | insertpackage 'experimental' 'foo' 'all' '1:1' |
20e6965a DK |
13 | insertinstalledpackage 'foo' 'all' '3' |
14 | ||
6aef1942 DK |
15 | setupaptarchive --no-update |
16 | ||
17 | mkdir -p rootdir/var/lib/apt/lists/lost+found | |
18 | testsuccess apt update | |
20e6965a DK |
19 | |
20 | # nothing to do always works | |
21 | testsuccess aptget clean | |
7414af7f | 22 | testsuccess aptget clean -s |
20e6965a DK |
23 | |
24 | # generate some dirt and clean it up | |
a9e4fd65 DK |
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 | |
20e6965a | 45 | |
a9e4fd65 | 46 | generatedirt |
20e6965a | 47 | testsuccess aptget clean |
e52aad52 DK |
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 | |
a9e4fd65 DK |
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 | |
e52aad52 DK |
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 | |
20e6965a | 55 | |
8d968cc2 DK |
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 | ||
dffc17ba DK |
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' |