]>
Commit | Line | Data |
---|---|---|
e05672e8 MV |
1 | #!/bin/sh |
2 | # | |
3 | # test that apt-get update is transactional | |
4 | # | |
5 | set -e | |
6 | ||
7 | avoid_ims_hit() { | |
8 | touch -d '+1hour' aptarchive/dists/unstable/main/binary-i386/Packages* | |
9 | touch -d '+1hour' aptarchive/dists/unstable/main/source/Sources* | |
10 | touch -d '+1hour' aptarchive/dists/unstable/*Release* | |
11 | ||
12 | touch -d '-1hour' rootdir/var/lib/apt/lists/* | |
13 | } | |
14 | ||
15 | create_fresh_archive() | |
16 | { | |
17 | rm -rf aptarchive/* | |
18 | rm -f rootdir/var/lib/apt/lists/_* rootdir/var/lib/apt/lists/partial/* | |
19 | ||
20 | insertpackage 'unstable' 'old' 'all' '1.0' | |
21 | ||
22 | setupaptarchive | |
23 | } | |
24 | ||
25 | add_new_package() { | |
26 | insertpackage "unstable" "new" "all" "1.0" | |
27 | insertsource "unstable" "new" "all" "1.0" | |
28 | ||
29 | setupaptarchive --no-update | |
30 | ||
31 | avoid_ims_hit | |
32 | } | |
33 | ||
34 | break_repository_sources_index() { | |
35 | printf "xxx" > $APTARCHIVE/dists/unstable/main/source/Sources | |
36 | gzip -c $APTARCHIVE/dists/unstable/main/source/Sources > \ | |
37 | $APTARCHIVE/dists/unstable/main/source/Sources.gz | |
38 | avoid_ims_hit | |
39 | } | |
40 | ||
41 | test_inrelease_to_new_inrelease() { | |
42 | msgmsg "Test InRelease to new InRelease works fine" | |
43 | create_fresh_archive | |
44 | testequal "old/unstable 1.0 all" apt list -q | |
45 | ||
46 | add_new_package | |
80976dd5 MV |
47 | aptget update -o Debug::Acquire::Transaction=1 |
48 | ||
49 | testsuccess aptget update -o Debug::Acquire::Transaction=1 | |
e05672e8 MV |
50 | |
51 | testequal "new/unstable 1.0 all | |
52 | old/unstable 1.0 all" apt list -q | |
53 | } | |
54 | ||
55 | test_inrelease_to_broken_hash_reverts_all() { | |
56 | msgmsg "Test InRelease to broken InRelease reverts everything" | |
57 | create_fresh_archive | |
58 | add_new_package | |
59 | # break the Sources file | |
60 | break_repository_sources_index | |
61 | ||
62 | # test the error condition | |
63 | testequal "W: Failed to fetch file:${APTARCHIVE}/dists/unstable/InRelease | |
64 | ||
65 | W: Failed to fetch copy:${APTARCHIVE}/dists/unstable/main/source/Sources Hash Sum mismatch | |
66 | ||
67 | W: Failed to fetch copy:${APTARCHIVE}/dists/unstable/main/binary-i386/Packages | |
68 | ||
69 | E: Some index files failed to download. They have been ignored, or old ones used instead." aptget update -qq | |
70 | # ensure that the Packages file is also rolled back | |
71 | testequal "E: Unable to locate package new" aptget install new -s -qq | |
72 | } | |
73 | ||
74 | test_inreleae_to_valid_release() { | |
75 | msgmsg "Test InRelease to valid Release" | |
76 | create_fresh_archive | |
77 | add_new_package | |
78 | # switch to a unsinged repo now | |
79 | rm $APTARCHIVE/dists/unstable/InRelease | |
80 | rm $APTARCHIVE/dists/unstable/Release.gpg | |
81 | avoid_ims_hit | |
82 | ||
83 | # update works | |
84 | testsuccess aptget update -o Debug::Acquire::Transaction=1 | |
85 | ||
86 | # test that we can install the new packages but do no longer have a sig | |
87 | testsuccess aptget install old -s | |
88 | testsuccess aptget install new -s | |
89 | testfailure ls $ROOTDIR/var/lib/apt/lists/*_InRelease | |
90 | testfailure ls $ROOTDIR/var/lib/apt/lists/*_Release.gpg | |
91 | testsuccess ls $ROOTDIR/var/lib/apt/lists/*_Release | |
92 | } | |
93 | ||
94 | test_inreleae_to_release_reverts_all() { | |
95 | msgmsg "Test InRelease to broken Release reverts everything" | |
96 | create_fresh_archive | |
97 | ||
98 | # switch to a unsinged repo now | |
99 | add_new_package | |
100 | rm $APTARCHIVE/dists/unstable/InRelease | |
101 | rm $APTARCHIVE/dists/unstable/Release.gpg | |
102 | # break it | |
103 | break_repository_sources_index | |
104 | ||
105 | # ensure error | |
106 | testequal "W: Failed to fetch file:$APTARCHIVE/dists/unstable/InRelease | |
107 | ||
108 | W: Failed to fetch file:$APTARCHIVE/dists/unstable/Release | |
109 | ||
110 | W: Failed to fetch file:$APTARCHIVE/dists/unstable/Release.gpg | |
111 | ||
112 | W: Failed to fetch copy:$APTARCHIVE/dists/unstable/main/source/Sources Hash Sum mismatch | |
113 | ||
114 | W: Failed to fetch copy:$APTARCHIVE/dists/unstable/main/binary-i386/Packages | |
115 | ||
116 | E: Some index files failed to download. They have been ignored, or old ones used instead." aptget update -qq # -o Debug::acquire::transaction=1 | |
117 | ||
118 | # ensure that the Packages file is also rolled back | |
119 | testsuccess aptget install old -s | |
120 | testfailure aptget install new -s | |
121 | testsuccess ls $ROOTDIR/var/lib/apt/lists/*_InRelease | |
122 | testfailure ls $ROOTDIR/var/lib/apt/lists/*_Release | |
123 | } | |
124 | ||
125 | test_unauthenticated_to_invalid_inrelease() { | |
126 | msgmsg "Test UnAuthenticated to invalid InRelease reverts everything" | |
127 | create_fresh_archive | |
128 | rm $APTARCHIVE/dists/unstable/InRelease | |
129 | rm $APTARCHIVE/dists/unstable/Release.gpg | |
130 | avoid_ims_hit | |
131 | ||
132 | testsuccess aptget update -qq | |
133 | testequal "WARNING: The following packages cannot be authenticated! | |
134 | old | |
135 | E: There are problems and -y was used without --force-yes" aptget install -qq -y old | |
136 | ||
137 | # go to authenticated but not correct | |
138 | add_new_package | |
139 | break_repository_sources_index | |
140 | ||
6d979490 MV |
141 | testequal "W: Failed to fetch file:$APTARCHIVE/dists/unstable/InRelease |
142 | ||
e05672e8 MV |
143 | W: Failed to fetch copy:$APTARCHIVE/dists/unstable/main/source/Sources Hash Sum mismatch |
144 | ||
6d979490 MV |
145 | W: Failed to fetch copy:$APTARCHIVE/dists/unstable/main/binary-i386/Packages |
146 | ||
e05672e8 MV |
147 | E: Some index files failed to download. They have been ignored, or old ones used instead." aptget update -qq |
148 | ||
149 | testfailure ls rootdir/var/lib/apt/lists/*_InRelease | |
150 | testequal "WARNING: The following packages cannot be authenticated! | |
151 | old | |
152 | E: There are problems and -y was used without --force-yes" aptget install -qq -y old | |
153 | } | |
154 | ||
c5fced38 MV |
155 | test_inrelease_to_unauth_inrelease() { |
156 | msgmsg "Test InRelease to InRelease without sig" | |
157 | create_fresh_archive | |
158 | signreleasefiles 'Marvin Paranoid' | |
159 | avoid_ims_hit | |
160 | ||
21638c3a | 161 | testequal "W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: file: unstable InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY E8525D47528144E2 |
c5fced38 | 162 | |
21638c3a | 163 | W: Failed to fetch file:$APTARCHIVE/dists/unstable/InRelease |
c5fced38 | 164 | |
21638c3a MV |
165 | W: Some index files failed to download. They have been ignored, or old ones used instead." aptget update -qq |
166 | ||
167 | testsuccess ls rootdir/var/lib/apt/lists/*_InRelease | |
c5fced38 MV |
168 | } |
169 | ||
e05672e8 MV |
170 | TESTDIR=$(readlink -f $(dirname $0)) |
171 | . $TESTDIR/framework | |
172 | ||
173 | setupenvironment | |
174 | configarchitecture "i386" | |
175 | ||
176 | # setup the archive and ensure we have a single package that installs fine | |
177 | setupaptarchive | |
178 | APTARCHIVE=$(readlink -f ./aptarchive) | |
179 | ROOTDIR=${TMPWORKINGDIRECTORY}/rootdir | |
180 | APTARCHIVE_LISTS="$(echo $APTARCHIVE | tr "/" "_" )" | |
181 | ||
182 | # test the following cases: | |
183 | # - InRelease -> broken InRelease revert to previous state | |
184 | # - empty lists dir and broken remote leaves nothing on the system | |
185 | # - InRelease -> hashsum mismatch for one file reverts all files to previous state | |
186 | # - Release/Release.gpg -> hashsum mismatch | |
187 | # - InRelease -> Release with hashsum mismatch revert entire state and kills Release | |
188 | # - Release -> InRelease with broken Sig/Hash removes InRelease | |
189 | # going from Release/Release.gpg -> InRelease and vice versa | |
190 | # - unauthenticated -> invalid InRelease | |
191 | ||
192 | test_inrelease_to_new_inrelease | |
193 | test_inrelease_to_broken_hash_reverts_all | |
194 | ||
195 | test_inreleae_to_valid_release | |
196 | test_inreleae_to_release_reverts_all | |
197 | ||
6d979490 | 198 | test_unauthenticated_to_invalid_inrelease |
c5fced38 MV |
199 | |
200 | test_inrelease_to_unauth_inrelease |