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