]> git.saurik.com Git - apt.git/blame - test/integration/test-apt-get-clean
require $(HASH)-Download field in .diff/Index files
[apt.git] / test / integration / test-apt-get-clean
CommitLineData
20e6965a
DK
1#!/bin/sh
2set -e
3
3abb6a6a
DK
4TESTDIR="$(readlink -f "$(dirname "$0")")"
5. "$TESTDIR/framework"
20e6965a
DK
6
7setupenvironment
8configarchitecture 'amd64'
9
10insertpackage 'testing' 'foo' 'all' '1'
11insertpackage 'unstable' 'foo' 'all' '2'
12insertinstalledpackage 'foo' 'all' '3'
13
6aef1942
DK
14setupaptarchive --no-update
15
16mkdir -p rootdir/var/lib/apt/lists/lost+found
17testsuccess apt update
20e6965a
DK
18
19# nothing to do always works
20testsuccess aptget clean
7414af7f 21testsuccess aptget clean -s
20e6965a
DK
22
23# generate some dirt and clean it up
24touch rootdir/var/lib/apt/lists/partial/http.debian.net_debian_dists_sid_main_i18n_Translation-en
6aef1942 25mkdir -p rootdir/var/cache/apt/archives/lost+found
20e6965a
DK
26touch rootdir/var/cache/apt/archives/foo_1_all.deb
27touch rootdir/var/cache/apt/archives/foo_2_all.deb
28touch rootdir/var/cache/apt/archives/foo_3_all.deb
29touch rootdir/var/cache/apt/archives/foo_4_all.deb
30
31testsuccess aptget clean
32
e52aad52
DK
33testfailure test -e rootdir/var/lib/apt/lists/partial/http.debian.net_debian_dists_sid_main_i18n_Translation-en
34testfailure test -e rootdir/var/cache/apt/archives/foo_1_all.deb
35testfailure test -e rootdir/var/cache/apt/archives/foo_2_all.deb
36testfailure test -e rootdir/var/cache/apt/archives/foo_3_all.deb
37testfailure test -e rootdir/var/cache/apt/archives/foo_4_all.deb
20e6965a 38
8d968cc2
DK
39if [ "$(id -u)" != '0' ]; then
40 msgmsg 'No clean if lock can not be acquired'
41 touch rootdir/var/cache/apt/archives/foo_4_all.deb
42 touch rootdir/var/cache/apt/archives/lock
43 chmod 444 rootdir/var/cache/apt/archives/lock
44 testfailure apt clean
45 testsuccess test -e rootdir/var/cache/apt/archives/foo_4_all.deb
46 chmod 644 rootdir/var/cache/apt/archives/lock
47fi
48
dffc17ba
DK
49directorygone() {
50 rm -rf "$1"
51 testsuccess apt autoclean
52 testfailure test -d "$1"
53 testsuccess apt clean
54 # clean creates an empty partial directory via GetLock
55 if [ "$(basename "$1")" = 'partial' ]; then
56 testsuccess test -d "$1"
57 else
58 testfailure test -d "$1"
59 fi
60}
61msgmsg 'Partial directory missing'
62directorygone 'rootdir/var/cache/apt/archives/partial'
63directorygone 'rootdir/var/lib/apt/lists/partial'
64
65msgmsg 'Archives directory missing'
66directorygone 'rootdir/var/cache/apt/archives'
67directorygone 'rootdir/var/lib/apt/lists'
68
69msgmsg 'apt directory missing'
70directorygone 'rootdir/var/cache/apt'
71directorygone 'rootdir/var/lib/apt'