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