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