]> git.saurik.com Git - apt.git/blob - test/integration/test-apt-update-not-modified
tests: activate dpkg multi-arch even if test is single arch
[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 export APT_DONT_SIGN=''
14 setupaptarchive --no-update
15
16 methodtest() {
17 msgmsg 'Test InRelease with' "$1"
18 rm -rf rootdir/var/lib/apt/lists
19 cp -a aptarchive/dists aptarchive/dists.good
20 # get our cache populated
21 testsuccess aptget update
22 listcurrentlistsdirectory > listsdir.lst
23
24 # hit again with a good cache
25 testsuccessequal "Hit:1 $1 unstable InRelease
26 Reading 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
32 testsuccessequal "Hit:1 $1 unstable InRelease
33 Reading package lists..." aptget update
34 testfileequal 'listsdir-without-amd64.lst' "$(listcurrentlistsdirectory)"
35
36 # readd arch so its downloaded again…
37 configarchitecture 'amd64' 'i386'
38 # … but oh noes, hashsum mismatch!
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
42 Package: thisisbad
43 Architecture: amd64
44 Version: 1
45 EOF
46 compressfile aptarchive/dists/unstable/main/binary-amd64/Packages
47 testfailureequal "Hit:1 $1 unstable InRelease
48 Get:2 $1 unstable/main amd64 Packages [$SIZE B]
49 Err:2 $1 unstable/main amd64 Packages
50 Hash Sum mismatch
51 Hashes of expected file:
52 - Checksum-FileSize:$(stat -c '%s' 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz.orig') [weak]
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)
56 - Checksum-FileSize:$(stat -c '%s' 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz') [weak]
57 Last modification reported: $(lastmodification 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz')
58 Release file created at: $(releasefiledate 'aptarchive/dists/unstable/InRelease')
59 Reading package lists...
60 E: Failed to fetch $1/dists/unstable/main/binary-amd64/Packages.gz Hash Sum mismatch
61 Hashes of expected file:
62 - Checksum-FileSize:$(stat -c '%s' 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz.orig') [weak]
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)
66 - Checksum-FileSize:$(stat -c '%s' 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz') [weak]
67 Last modification reported: $(lastmodification 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz')
68 Release file created at: $(releasefiledate 'aptarchive/dists/unstable/InRelease')
69 E: 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
75 testsuccessequal "Hit:1 $1 unstable InRelease
76 Get:2 $1 unstable/main amd64 Packages [$(stat -c '%s' 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz') B]
77 Reading package lists..." aptget update
78 testfileequal 'listsdir.lst' "$(listcurrentlistsdirectory)"
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]
83 Reading 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
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
95 testsuccessequal "Ign:1 $1 unstable InRelease
96 404 Not Found
97 Hit:2 $1 unstable Release
98 Reading 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
104 testsuccessequal "Ign:1 $1 unstable InRelease
105 404 Not Found
106 Hit:2 $1 unstable Release
107 Reading package lists..." aptget update
108 testfileequal 'listsdir-without-amd64.lst' "$(listcurrentlistsdirectory)"
109
110 # readd arch so its downloaded again…
111 configarchitecture 'amd64' 'i386'
112 # … but oh noes, hashsum mismatch!
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
116 Package: thisisbad
117 Architecture: amd64
118 Version: 1
119 EOF
120 compressfile aptarchive/dists/unstable/main/binary-amd64/Packages
121 testfailureequal "Ign:1 $1 unstable InRelease
122 404 Not Found
123 Hit:2 $1 unstable Release
124 Get:4 $1 unstable/main amd64 Packages [$SIZE B]
125 Err:4 $1 unstable/main amd64 Packages
126 Hash Sum mismatch
127 Hashes of expected file:
128 - Checksum-FileSize:$(stat -c '%s' 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz.orig') [weak]
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)
132 - Checksum-FileSize:$(stat -c '%s' 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz') [weak]
133 Last modification reported: $(lastmodification 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz')
134 Release file created at: $(releasefiledate 'aptarchive/dists/unstable/Release')
135 Reading package lists...
136 E: Failed to fetch $1/dists/unstable/main/binary-amd64/Packages.gz Hash Sum mismatch
137 Hashes of expected file:
138 - Checksum-FileSize:$(stat -c '%s' 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz.orig') [weak]
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)
142 - Checksum-FileSize:$(stat -c '%s' 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz') [weak]
143 Last modification reported: $(lastmodification 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz')
144 Release file created at: $(releasefiledate 'aptarchive/dists/unstable/Release')
145 E: 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
152 testsuccessequal "Ign:1 $1 unstable InRelease
153 404 Not Found
154 Hit:2 $1 unstable Release
155 Get:4 $1 unstable/main amd64 Packages [$(stat -c '%s' 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz') B]
156 Reading package lists..." aptget update
157 testfileequal 'listsdir.lst' "$(listcurrentlistsdirectory)"
158
159 webserverconfig 'aptwebserver::support::modified-since' 'false'
160 webserverconfig 'aptwebserver::support::last-modified' 'false'
161 testsuccessequal "Ign:1 $1 unstable InRelease
162 404 Not Found
163 Get:2 $1 unstable Release [$(stat -c '%s' 'aptarchive/dists/unstable/Release') B]
164 Reading 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
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]
177 Reading 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]
183 Get:2 $1 unstable/main amd64 Packages [$(stat -c '%s' 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz') B]
184 Get:3 $1 unstable/main i386 Packages [$(stat -c '%s' 'aptarchive/dists/unstable/main/binary-i386/Packages.gz') B]
185 Reading package lists..." aptget update
186
187 rm -rf aptarchive/dists
188 cp -a aptarchive/dists.good aptarchive/dists
189 }
190
191 changetowebserver
192 methodtest "http://localhost:${APTHTTPPORT}"
193
194 changetohttpswebserver
195 methodtest "https://localhost:${APTHTTPSPORT}"