]> git.saurik.com Git - apt.git/blob - test/integration/test-apt-update-not-modified
deprecate confusing Pkg.CandVersion() method
[apt.git] / test / integration / test-apt-update-not-modified
1 #!/bin/sh
2 set -e
3
4 TESTDIR="$(readlink -f "$(dirname "$0")")"
5 . "$TESTDIR/framework"
6
7 setupenvironment
8 configarchitecture 'amd64' 'i386'
9 confighashes 'SHA256'
10
11 insertpackage 'unstable' 'apt' 'amd64,i386' '1.0'
12
13 setupaptarchive --no-update
14
15 methodtest() {
16 msgmsg 'Test InRelease with' "$1"
17 rm -rf rootdir/var/lib/apt/lists
18 cp -a aptarchive/dists aptarchive/dists.good
19 # get our cache populated
20 testsuccess aptget update
21 listcurrentlistsdirectory > listsdir.lst
22
23 # hit again with a good cache
24 testsuccessequal "Hit:1 $1 unstable InRelease
25 Reading 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
31 testsuccessequal "Hit:1 $1 unstable InRelease
32 Reading package lists..." aptget update
33 testfileequal 'listsdir-without-amd64.lst' "$(listcurrentlistsdirectory)"
34
35 # readd arch so its downloaded again…
36 configarchitecture 'amd64' 'i386'
37 # … but oh noes, hashsum mismatch!
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
41 Package: thisisbad
42 Architecture: amd64
43 Version: 1
44 EOF
45 compressfile aptarchive/dists/unstable/main/binary-amd64/Packages
46 testfailureequal "Hit:1 $1 unstable InRelease
47 Get:2 $1 unstable/main amd64 Packages [$SIZE B]
48 Err:2 $1 unstable/main amd64 Packages
49 Hash Sum mismatch
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')
58 Reading package lists...
59 E: Failed to fetch $1/dists/unstable/main/binary-amd64/Packages.gz Hash Sum mismatch
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')
68 E: 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
74 testsuccessequal "Hit:1 $1 unstable InRelease
75 Get:2 $1 unstable/main amd64 Packages [$(stat -c '%s' 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz') B]
76 Reading package lists..." aptget update
77 testfileequal 'listsdir.lst' "$(listcurrentlistsdirectory)"
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]
82 Reading 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
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
94 testsuccessequal "Ign:1 $1 unstable InRelease
95 404 Not Found
96 Hit:2 $1 unstable Release
97 Reading 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
103 testsuccessequal "Ign:1 $1 unstable InRelease
104 404 Not Found
105 Hit:2 $1 unstable Release
106 Reading package lists..." aptget update
107 testfileequal 'listsdir-without-amd64.lst' "$(listcurrentlistsdirectory)"
108
109 # readd arch so its downloaded again…
110 configarchitecture 'amd64' 'i386'
111 # … but oh noes, hashsum mismatch!
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
115 Package: thisisbad
116 Architecture: amd64
117 Version: 1
118 EOF
119 compressfile aptarchive/dists/unstable/main/binary-amd64/Packages
120 testfailureequal "Ign:1 $1 unstable InRelease
121 404 Not Found
122 Hit:2 $1 unstable Release
123 Get:4 $1 unstable/main amd64 Packages [$SIZE B]
124 Err:4 $1 unstable/main amd64 Packages
125 Hash Sum mismatch
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')
134 Reading package lists...
135 E: Failed to fetch $1/dists/unstable/main/binary-amd64/Packages.gz Hash Sum mismatch
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')
144 E: 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
151 testsuccessequal "Ign:1 $1 unstable InRelease
152 404 Not Found
153 Hit:2 $1 unstable Release
154 Get:4 $1 unstable/main amd64 Packages [$(stat -c '%s' 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz') B]
155 Reading package lists..." aptget update
156 testfileequal 'listsdir.lst' "$(listcurrentlistsdirectory)"
157
158 webserverconfig 'aptwebserver::support::modified-since' 'false'
159 webserverconfig 'aptwebserver::support::last-modified' 'false'
160 testsuccessequal "Ign:1 $1 unstable InRelease
161 404 Not Found
162 Get:2 $1 unstable Release [$(stat -c '%s' 'aptarchive/dists/unstable/Release') B]
163 Reading 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
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]
176 Reading 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]
182 Get:2 $1 unstable/main amd64 Packages [$(stat -c '%s' 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz') B]
183 Get:3 $1 unstable/main i386 Packages [$(stat -c '%s' 'aptarchive/dists/unstable/main/binary-i386/Packages.gz') B]
184 Reading package lists..." aptget update
185
186 rm -rf aptarchive/dists
187 cp -a aptarchive/dists.good aptarchive/dists
188 }
189
190 changetowebserver
191 methodtest "http://localhost:${APTHTTPPORT}"
192
193 changetohttpswebserver
194 methodtest "https://localhost:${APTHTTPSPORT}"