]> git.saurik.com Git - apt.git/blame - test/integration/test-apt-update-not-modified
Don't download "optional" files not in Release :/.
[apt.git] / test / integration / test-apt-update-not-modified
CommitLineData
ba6b79bd
DK
1#!/bin/sh
2set -e
3
3abb6a6a
DK
4TESTDIR="$(readlink -f "$(dirname "$0")")"
5. "$TESTDIR/framework"
ba6b79bd
DK
6
7setupenvironment
8configarchitecture 'amd64' 'i386'
0340069c 9confighashes 'SHA256'
ba6b79bd 10
1dd20368 11insertpackage 'unstable' 'apt' 'amd64,i386' '1.0'
ba6b79bd 12
5a23c56d 13export APT_DONT_SIGN=''
ba6b79bd
DK
14setupaptarchive --no-update
15
16methodtest() {
8eafc759 17 msgmsg 'Test InRelease with' "$1"
ba6b79bd 18 rm -rf rootdir/var/lib/apt/lists
58702f85 19 cp -a aptarchive/dists aptarchive/dists.good
ba6b79bd
DK
20 # get our cache populated
21 testsuccess aptget update
22 listcurrentlistsdirectory > listsdir.lst
23
24 # hit again with a good cache
1eb1836f 25 testsuccessequal "Hit:1 $1 unstable InRelease
ba6b79bd
DK
26Reading package lists..." aptget update
27 testfileequal 'listsdir.lst' "$(listcurrentlistsdirectory)"
28
29 # drop an architecture, which means the file should be gone now
30 configarchitecture 'i386'
31 sed '/_binary-amd64_Packages/ d' listsdir.lst > listsdir-without-amd64.lst
1eb1836f 32 testsuccessequal "Hit:1 $1 unstable InRelease
ba6b79bd
DK
33Reading package lists..." aptget update
34 testfileequal 'listsdir-without-amd64.lst' "$(listcurrentlistsdirectory)"
35
58702f85 36 # readd arch so its downloaded again…
ba6b79bd 37 configarchitecture 'amd64' 'i386'
58702f85 38 # … but oh noes, hashsum mismatch!
0340069c
DK
39 SIZE=$(stat -c '%s' 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz')
40 mv aptarchive/dists/unstable/main/binary-amd64/Packages.gz aptarchive/dists/unstable/main/binary-amd64/Packages.gz.orig
41 cat > aptarchive/dists/unstable/main/binary-amd64/Packages <<EOF
58702f85
DK
42Package: thisisbad
43Architecture: amd64
44Version: 1
45EOF
46 compressfile aptarchive/dists/unstable/main/binary-amd64/Packages
1eb1836f 47 testfailureequal "Hit:1 $1 unstable InRelease
fb193b1c 48Get:2 $1 unstable/main amd64 Packages [$SIZE B]
1eb1836f 49Err:2 $1 unstable/main amd64 Packages
448c38bd 50 Hash Sum mismatch
0340069c 51 Hashes of expected file:
28ee7f19 52 - Filesize:$(stat -c '%s' 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz.orig') [weak]
0340069c
DK
53 - SHA256:$(sha256sum 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz.orig' | cut -d' ' -f 1)
54 Hashes of received file:
55 - SHA256:$(sha256sum 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz' | cut -d' ' -f 1)
28ee7f19 56 - Filesize:$(stat -c '%s' 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz') [weak]
0340069c
DK
57 Last modification reported: $(lastmodification 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz')
58 Release file created at: $(releasefiledate 'aptarchive/dists/unstable/InRelease')
95278287 59Reading package lists...
f695e761 60E: Failed to fetch $1/dists/unstable/main/binary-amd64/Packages.gz Hash Sum mismatch
0340069c 61 Hashes of expected file:
28ee7f19 62 - Filesize:$(stat -c '%s' 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz.orig') [weak]
0340069c
DK
63 - SHA256:$(sha256sum 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz.orig' | cut -d' ' -f 1)
64 Hashes of received file:
65 - SHA256:$(sha256sum 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz' | cut -d' ' -f 1)
28ee7f19 66 - Filesize:$(stat -c '%s' 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz') [weak]
0340069c
DK
67 Last modification reported: $(lastmodification 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz')
68 Release file created at: $(releasefiledate 'aptarchive/dists/unstable/InRelease')
58702f85
DK
69E: Some index files failed to download. They have been ignored, or old ones used instead." aptget update
70 testfileequal 'listsdir-without-amd64.lst' "$(listcurrentlistsdirectory)"
71 rm -rf aptarchive/dists
72 cp -a aptarchive/dists.good aptarchive/dists
73
74 # … now everything is fine again
1eb1836f
DK
75 testsuccessequal "Hit:1 $1 unstable InRelease
76Get:2 $1 unstable/main amd64 Packages [$(stat -c '%s' 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz') B]
ba6b79bd
DK
77Reading package lists..." aptget update
78 testfileequal 'listsdir.lst' "$(listcurrentlistsdirectory)"
8eafc759
DK
79
80 webserverconfig 'aptwebserver::support::modified-since' 'false'
81 webserverconfig 'aptwebserver::support::last-modified' 'false'
82 testsuccessequal "Get:1 $1 unstable InRelease [$(stat -c '%s' 'aptarchive/dists/unstable/InRelease') B]
83Reading package lists..." aptget update
84 webserverconfig 'aptwebserver::support::modified-since' 'true'
85 webserverconfig 'aptwebserver::support::last-modified' 'true'
86
87 msgmsg 'Test Release.gpg with' "$1"
88 rm -rf rootdir/var/lib/apt/lists
8eafc759
DK
89 find aptarchive/dists -name 'InRelease' -delete
90 # get our cache populated
91 testsuccess aptget update
92 listcurrentlistsdirectory > listsdir.lst
93
94 # hit again with a good cache
1eb1836f 95 testsuccessequal "Ign:1 $1 unstable InRelease
8eafc759 96 404 Not Found
1eb1836f 97Hit:2 $1 unstable Release
8eafc759
DK
98Reading package lists..." aptget update
99 testfileequal 'listsdir.lst' "$(listcurrentlistsdirectory)"
100
101 # drop an architecture, which means the file should be gone now
102 configarchitecture 'i386'
103 sed '/_binary-amd64_Packages/ d' listsdir.lst > listsdir-without-amd64.lst
1eb1836f 104 testsuccessequal "Ign:1 $1 unstable InRelease
8eafc759 105 404 Not Found
1eb1836f 106Hit:2 $1 unstable Release
8eafc759
DK
107Reading package lists..." aptget update
108 testfileequal 'listsdir-without-amd64.lst' "$(listcurrentlistsdirectory)"
109
448c38bd 110 # readd arch so its downloaded again…
8eafc759 111 configarchitecture 'amd64' 'i386'
448c38bd 112 # … but oh noes, hashsum mismatch!
0340069c
DK
113 SIZE=$(stat -c '%s' 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz')
114 mv aptarchive/dists/unstable/main/binary-amd64/Packages.gz aptarchive/dists/unstable/main/binary-amd64/Packages.gz.orig
115 cat > aptarchive/dists/unstable/main/binary-amd64/Packages <<EOF
448c38bd
DK
116Package: thisisbad
117Architecture: amd64
118Version: 1
119EOF
120 compressfile aptarchive/dists/unstable/main/binary-amd64/Packages
1eb1836f 121 testfailureequal "Ign:1 $1 unstable InRelease
448c38bd 122 404 Not Found
1eb1836f 123Hit:2 $1 unstable Release
fb193b1c 124Get:4 $1 unstable/main amd64 Packages [$SIZE B]
1eb1836f 125Err:4 $1 unstable/main amd64 Packages
448c38bd 126 Hash Sum mismatch
0340069c 127 Hashes of expected file:
28ee7f19 128 - Filesize:$(stat -c '%s' 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz.orig') [weak]
0340069c
DK
129 - SHA256:$(sha256sum 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz.orig' | cut -d' ' -f 1)
130 Hashes of received file:
131 - SHA256:$(sha256sum 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz' | cut -d' ' -f 1)
28ee7f19 132 - Filesize:$(stat -c '%s' 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz') [weak]
0340069c
DK
133 Last modification reported: $(lastmodification 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz')
134 Release file created at: $(releasefiledate 'aptarchive/dists/unstable/Release')
95278287 135Reading package lists...
f695e761 136E: Failed to fetch $1/dists/unstable/main/binary-amd64/Packages.gz Hash Sum mismatch
0340069c 137 Hashes of expected file:
28ee7f19 138 - Filesize:$(stat -c '%s' 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz.orig') [weak]
0340069c
DK
139 - SHA256:$(sha256sum 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz.orig' | cut -d' ' -f 1)
140 Hashes of received file:
141 - SHA256:$(sha256sum 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz' | cut -d' ' -f 1)
28ee7f19 142 - Filesize:$(stat -c '%s' 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz') [weak]
0340069c
DK
143 Last modification reported: $(lastmodification 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz')
144 Release file created at: $(releasefiledate 'aptarchive/dists/unstable/Release')
448c38bd
DK
145E: Some index files failed to download. They have been ignored, or old ones used instead." aptget update
146 testfileequal 'listsdir-without-amd64.lst' "$(listcurrentlistsdirectory)"
147 rm -rf aptarchive/dists
148 cp -a aptarchive/dists.good aptarchive/dists
149 find aptarchive/dists -name 'InRelease' -delete
150
151 # … now everything is fine again
1eb1836f 152 testsuccessequal "Ign:1 $1 unstable InRelease
8eafc759 153 404 Not Found
1eb1836f
DK
154Hit:2 $1 unstable Release
155Get:4 $1 unstable/main amd64 Packages [$(stat -c '%s' 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz') B]
8eafc759
DK
156Reading package lists..." aptget update
157 testfileequal 'listsdir.lst' "$(listcurrentlistsdirectory)"
158
159 webserverconfig 'aptwebserver::support::modified-since' 'false'
160 webserverconfig 'aptwebserver::support::last-modified' 'false'
1eb1836f 161 testsuccessequal "Ign:1 $1 unstable InRelease
8eafc759 162 404 Not Found
1eb1836f 163Get:2 $1 unstable Release [$(stat -c '%s' 'aptarchive/dists/unstable/Release') B]
8eafc759
DK
164Reading package lists..." aptget update
165 webserverconfig 'aptwebserver::support::modified-since' 'true'
166 webserverconfig 'aptwebserver::support::last-modified' 'true'
167
168 rm -rf aptarchive/dists
169 cp -a aptarchive/dists.good aptarchive/dists
8d041b4f
DK
170
171 # new release file, but the indexes are the same
172 redatereleasefiles '+2 hours'
173
174 rm -rf rootdir/var/lib/apt/lists.good
175 cp -a rootdir/var/lib/apt/lists rootdir/var/lib/apt/lists.good
176 testsuccessequal "Get:1 $1 unstable InRelease [$(stat -c '%s' 'aptarchive/dists/unstable/InRelease') B]
177Reading package lists..." aptget update
178
179 rm -rf rootdir/var/lib/apt/lists
180 cp -a rootdir/var/lib/apt/lists.good rootdir/var/lib/apt/lists
181 find rootdir/var/lib/apt/lists -name '*_Packages*' -delete
182 testsuccessequal "Get:1 $1 unstable InRelease [$(stat -c '%s' 'aptarchive/dists/unstable/InRelease') B]
183Get:2 $1 unstable/main amd64 Packages [$(stat -c '%s' 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz') B]
184Get:3 $1 unstable/main i386 Packages [$(stat -c '%s' 'aptarchive/dists/unstable/main/binary-i386/Packages.gz') B]
185Reading package lists..." aptget update
186
187 rm -rf aptarchive/dists
188 cp -a aptarchive/dists.good aptarchive/dists
ba6b79bd
DK
189}
190
191changetowebserver
6c0765c0 192methodtest "http://localhost:${APTHTTPPORT}"
ba6b79bd
DK
193
194changetohttpswebserver
6c0765c0 195methodtest "https://localhost:${APTHTTPSPORT}"