blob: 32dd3e852dc4b2178366748967906f9d64fa72ac (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
#!/bin/sh
set -e
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
mkdir -p rootdir/var/lib/apt/lists/partial
testsuccess test -d rootdir/var/lib/apt/lists/partial
# nothing to do always works (part 1)
for cmd in aptget apt; do
for sub in distclean dist-clean; do
testsuccess $cmd $sub
testsuccess $cmd $sub -s
done
done
testsuccess test -d rootdir/var/lib/apt/lists/partial
testsuccess apt update
# nothing to do always works (part 2)
for cmd in aptget apt; do
for sub in clean autoclean auto-clean; do
testsuccess $cmd $sub
testsuccess $cmd $sub -s
done
done
# generate some dirt and clean it up
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
}
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
msgmsg 'distclean'
listcurrentlistsdirectory > aptdistclean.before
testsuccessequal '3' grep -c -e 'Release$' aptdistclean.before
testsuccess grep -e 'Packages$' -e 'Sources$' -e 'Translation-*$' aptdistclean.before
testsuccess apt distclean
listcurrentlistsdirectory > aptdistclean.after
testfailure cmp aptdistclean.before aptdistclean.after
testsuccessequal '3' grep -c -e 'Release$' aptdistclean.after
testfailureequal '0' grep -c -e 'Packages$' -e 'Sources$' -e 'Translation-*$' aptdistclean.after
for dirt in Packages.gz Sources.xz Release2gpg Release_Packages; do
touch "rootdir/var/lib/apt/lists/_foo_bar_$dirt"
done
listcurrentlistsdirectory > aptdistclean.before
testsuccess apt distclean
listcurrentlistsdirectory > aptdistclean.cleaned
testsuccess cmp aptdistclean.after aptdistclean.cleaned
directorygone() {
rm -rf "$1"
testsuccess apt autoclean
testfailure test -d "$1"
testsuccess apt clean
# clean creates an empty partial directory via GetLock
if [ "$(basename "$1")" = 'partial' ]; then
testsuccess test -d "$1"
else
testfailure test -d "$1"
fi
}
msgmsg 'Partial directory missing'
directorygone 'rootdir/var/cache/apt/archives/partial'
directorygone 'rootdir/var/lib/apt/lists/partial'
msgmsg 'Archives directory missing'
directorygone 'rootdir/var/cache/apt/archives'
directorygone 'rootdir/var/lib/apt/lists'
msgmsg 'apt directory missing'
directorygone 'rootdir/var/cache/apt'
directorygone 'rootdir/var/lib/apt'
|