]> git.saurik.com Git - apt.git/blame - test/integration/test-apt-get-clean
create non-existent files in edit-sources with 644 instead of 640
[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'
a9e4fd65 12insertpackage 'experimental' 'foo' 'all' '1:1'
20e6965a
DK
13insertinstalledpackage 'foo' 'all' '3'
14
6aef1942
DK
15setupaptarchive --no-update
16
17mkdir -p rootdir/var/lib/apt/lists/lost+found
18testsuccess apt update
20e6965a
DK
19
20# nothing to do always works
21testsuccess aptget clean
7414af7f 22testsuccess aptget clean -s
20e6965a
DK
23
24# generate some dirt and clean it up
a9e4fd65
DK
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
20e6965a 45
a9e4fd65 46generatedirt
20e6965a 47testsuccess aptget clean
e52aad52
DK
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
a9e4fd65
DK
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
e52aad52
DK
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
20e6965a 55
8d968cc2
DK
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
dffc17ba
DK
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'