]> git.saurik.com Git - apt.git/blob - test/integration/test-apt-update-ims
test: Explicitly pass --admindir=var/lib/dpkg to dpkg
[apt.git] / test / integration / test-apt-update-ims
1 #!/bin/sh
2 set -e
3
4 TESTDIR="$(readlink -f "$(dirname "$0")")"
5 . "$TESTDIR/framework"
6 setupenvironment
7 configarchitecture 'amd64'
8
9 insertpackage 'unstable' 'unrelated' 'all' '0.5~squeeze1'
10 insertpackage 'unstable' 'unrelated2' 'amd64' '0.5~squeeze1'
11 insertsource 'unstable' 'unrelated' 'all' '0.5~squeeze1'
12
13 export APT_DONT_SIGN=""
14 setupaptarchive --no-update
15 logcurrentarchivedirectory
16 changetowebserver
17
18 runtest() {
19 local APTOPT=""
20 if [ -n "$1" ]; then
21 APTOPT='--allow-insecure-repositories'
22 else
23 APTOPT='--no-allow-insecure-repositories'
24 fi
25
26 rm -rf rootdir/var/lib/apt/lists/
27
28 local TEST="test${1:-success}"
29 $TEST aptget update $APTOPT -o Debug::pkgAcquire::Worker=1
30 if [ "$1" = 'failure' ]; then
31 # accept the outdated Release file so we can check Hit behaviour
32 "test${2:-success}" aptget update -o Acquire::Min-ValidTime=9999999 $APTOPT
33 fi
34 listcurrentlistsdirectory > listsdir.lst
35 testsuccess grep '_Packages\(\.[0-9a-z]\+\)\?$' listsdir.lst
36 testsuccess grep '_Sources\(\.[0-9a-z]\+\)\?$' listsdir.lst
37 testsuccess grep '_Translation-en\(\.[0-9a-z]\+\)\?$' listsdir.lst
38
39 # ensure no leftovers in partial
40 testfailure ls 'rootdir/var/lib/apt/lists/partial/*'
41
42 # check that I-M-S header is kept in redirections
43 echo "$EXPECT" | sed -e 's#(invalid since [^)]\+)#(invalid since)#' > expected.output
44 $TEST aptget update -o Debug::pkgAcquire::Worker=0 -o Debug::Acquire::http=0 $APTOPT
45 sed -i -e 's#(invalid since [^)]\+)#(invalid since)#' rootdir/tmp/${TEST}.output
46 testequal "$(cat expected.output)" cat rootdir/tmp/${TEST}.output
47 testfileequal 'listsdir.lst' "$(listcurrentlistsdirectory)"
48
49 # ensure that we still do a hash check for other files on ims hit of Release
50 if grep -q '^Hit:[0-9]\+ .* InRelease$' expected.output || ! grep -q '^Ign:[0-9]\+ .* Release\(\.gpg\)\?$' expected.output; then
51 $TEST aptget update -o Debug::Acquire::gpgv=1 $APTOPT
52 cp rootdir/tmp/${TEST}.output goodsign.output
53 testfileequal 'listsdir.lst' "$(listcurrentlistsdirectory)"
54 testsuccess grep '^Got GOODSIG ' goodsign.output
55 fi
56
57 # ensure no leftovers in partial
58 testfailure ls 'rootdir/var/lib/apt/lists/partial/*'
59 }
60
61 msgmsg 'InRelease'
62 EXPECT="Hit:1 http://localhost:${APTHTTPPORT} unstable InRelease
63 Reading package lists..."
64 echo 'Acquire::GzipIndexes "0";' > rootdir/etc/apt/apt.conf.d/02compressindex
65 runtest
66 echo 'Acquire::GzipIndexes "1";' > rootdir/etc/apt/apt.conf.d/02compressindex
67 runtest
68
69 msgmsg 'Release/Release.gpg'
70 EXPECT="Ign:1 http://localhost:${APTHTTPPORT} unstable InRelease
71 404 Not Found
72 Hit:2 http://localhost:${APTHTTPPORT} unstable Release
73 Reading package lists..."
74 find aptarchive -name 'InRelease' -delete
75 logcurrentarchivedirectory
76 echo 'Acquire::GzipIndexes "0";' > rootdir/etc/apt/apt.conf.d/02compressindex
77 runtest
78 echo 'Acquire::GzipIndexes "1";' > rootdir/etc/apt/apt.conf.d/02compressindex
79 runtest
80
81 msgmsg 'Release only'
82 EXPECT="Ign:1 http://localhost:${APTHTTPPORT} unstable InRelease
83 404 Not Found
84 Hit:2 http://localhost:${APTHTTPPORT} unstable Release
85 Ign:3 http://localhost:${APTHTTPPORT} unstable Release.gpg
86 404 Not Found
87 Reading package lists...
88 W: The repository 'http://localhost:${APTHTTPPORT} unstable Release' is not signed.
89 N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.
90 N: See apt-secure(8) manpage for repository creation and user configuration details."
91 find aptarchive -name 'Release.gpg' -delete
92 logcurrentarchivedirectory
93 echo 'Acquire::GzipIndexes "0";' > rootdir/etc/apt/apt.conf.d/02compressindex
94 runtest 'warning'
95 echo 'Acquire::GzipIndexes "1";' > rootdir/etc/apt/apt.conf.d/02compressindex
96 runtest 'warning'
97
98
99 # make the release file old
100 find aptarchive -name '*Release' -exec sed -i \
101 -e "s#^Date: .*\$#Date: $(date -ud '-2 weeks' '+%a, %d %b %Y %H:%M:%S %Z')#" \
102 -e '/^Valid-Until: / d' -e "/^Date: / a\
103 Valid-Until: $(date -ud '-1 weeks' '+%a, %d %b %Y %H:%M:%S %Z')" '{}' \;
104 signreleasefiles
105 logcurrentarchivedirectory
106
107 msgmsg 'expired InRelease'
108 EXPECT="Hit:1 http://localhost:${APTHTTPPORT} unstable InRelease
109 Reading package lists...
110 E: Release file for http://localhost:${APTHTTPPORT}/dists/unstable/InRelease is expired (invalid since). Updates for this repository will not be applied."
111 echo 'Acquire::GzipIndexes "0";' > rootdir/etc/apt/apt.conf.d/02compressindex
112 runtest 'failure'
113 echo 'Acquire::GzipIndexes "1";' > rootdir/etc/apt/apt.conf.d/02compressindex
114 runtest 'failure'
115
116 msgmsg 'expired Release/Release.gpg'
117 EXPECT="Ign:1 http://localhost:${APTHTTPPORT} unstable InRelease
118 404 Not Found
119 Hit:2 http://localhost:${APTHTTPPORT} unstable Release
120 Reading package lists...
121 E: Release file for http://localhost:${APTHTTPPORT}/dists/unstable/Release is expired (invalid since). Updates for this repository will not be applied."
122 find aptarchive -name 'InRelease' -delete
123 logcurrentarchivedirectory
124 echo 'Acquire::GzipIndexes "0";' > rootdir/etc/apt/apt.conf.d/02compressindex
125 runtest 'failure'
126 echo 'Acquire::GzipIndexes "1";' > rootdir/etc/apt/apt.conf.d/02compressindex
127 runtest 'failure'
128
129 msgmsg 'expired Release only'
130 EXPECT="Ign:1 http://localhost:${APTHTTPPORT} unstable InRelease
131 404 Not Found
132 Hit:2 http://localhost:${APTHTTPPORT} unstable Release
133 Ign:3 http://localhost:${APTHTTPPORT} unstable Release.gpg
134 404 Not Found
135 Reading package lists...
136 W: The repository 'http://localhost:${APTHTTPPORT} unstable Release' is not signed.
137 N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.
138 N: See apt-secure(8) manpage for repository creation and user configuration details.
139 E: Release file for http://localhost:${APTHTTPPORT}/dists/unstable/Release is expired (invalid since). Updates for this repository will not be applied."
140 find aptarchive -name 'Release.gpg' -delete
141 logcurrentarchivedirectory
142 echo 'Acquire::GzipIndexes "0";' > rootdir/etc/apt/apt.conf.d/02compressindex
143 runtest 'failure' 'warning'
144 echo 'Acquire::GzipIndexes "1";' > rootdir/etc/apt/apt.conf.d/02compressindex
145 runtest 'failure' 'warning'
146
147
148 msgmsg 'no Release at all'
149 EXPECT="Ign:1 http://localhost:${APTHTTPPORT} unstable InRelease
150 404 Not Found
151 Ign:2 http://localhost:${APTHTTPPORT} unstable Release
152 404 Not Found
153 Ign:3 http://localhost:${APTHTTPPORT} unstable/main Sources
154 404 Not Found
155 Ign:4 http://localhost:${APTHTTPPORT} unstable/main amd64 Packages
156 404 Not Found
157 Ign:5 http://localhost:${APTHTTPPORT} unstable/main all Packages
158 404 Not Found
159 Ign:6 http://localhost:${APTHTTPPORT} unstable/main Translation-en
160 404 Not Found
161 Ign:3 http://localhost:${APTHTTPPORT} unstable/main Sources
162 404 Not Found
163 Ign:4 http://localhost:${APTHTTPPORT} unstable/main amd64 Packages
164 404 Not Found
165 Ign:5 http://localhost:${APTHTTPPORT} unstable/main all Packages
166 404 Not Found
167 Ign:6 http://localhost:${APTHTTPPORT} unstable/main Translation-en
168 404 Not Found
169 Ign:3 http://localhost:${APTHTTPPORT} unstable/main Sources
170 404 Not Found
171 Ign:4 http://localhost:${APTHTTPPORT} unstable/main amd64 Packages
172 404 Not Found
173 Ign:5 http://localhost:${APTHTTPPORT} unstable/main all Packages
174 404 Not Found
175 Ign:6 http://localhost:${APTHTTPPORT} unstable/main Translation-en
176 404 Not Found
177 Hit:3 http://localhost:${APTHTTPPORT} unstable/main Sources
178 Hit:4 http://localhost:${APTHTTPPORT} unstable/main amd64 Packages
179 Hit:5 http://localhost:${APTHTTPPORT} unstable/main all Packages
180 Hit:6 http://localhost:${APTHTTPPORT} unstable/main Translation-en
181 Reading package lists...
182 W: The repository 'http://localhost:${APTHTTPPORT} unstable Release' does not have a Release file.
183 N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.
184 N: See apt-secure(8) manpage for repository creation and user configuration details."
185 find aptarchive -name '*Release*' -delete
186 logcurrentarchivedirectory
187 echo 'Acquire::GzipIndexes "0";
188 Acquire::PDiffs "0";' > rootdir/etc/apt/apt.conf.d/02compressindex
189 runtest 'warning'
190 echo 'Acquire::GzipIndexes "1";
191 Acquire::PDiffs "0";' > rootdir/etc/apt/apt.conf.d/02compressindex
192 runtest 'warning'