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