]>
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 | |
47 | testsuccess aptget update | |
48 | ||
49 | testequal "new/unstable 1.0 all | |
50 | old/unstable 1.0 all" apt list -q | |
51 | } | |
52 | ||
53 | test_inrelease_to_broken_hash_reverts_all() { | |
54 | msgmsg "Test InRelease to broken InRelease reverts everything" | |
55 | create_fresh_archive | |
56 | add_new_package | |
57 | # break the Sources file | |
58 | break_repository_sources_index | |
59 | ||
60 | # test the error condition | |
61 | testequal "W: Failed to fetch file:${APTARCHIVE}/dists/unstable/InRelease | |
62 | ||
63 | W: Failed to fetch copy:${APTARCHIVE}/dists/unstable/main/source/Sources Hash Sum mismatch | |
64 | ||
65 | W: Failed to fetch copy:${APTARCHIVE}/dists/unstable/main/binary-i386/Packages | |
66 | ||
67 | E: Some index files failed to download. They have been ignored, or old ones used instead." aptget update -qq | |
68 | # ensure that the Packages file is also rolled back | |
69 | testequal "E: Unable to locate package new" aptget install new -s -qq | |
70 | } | |
71 | ||
72 | test_inreleae_to_valid_release() { | |
73 | msgmsg "Test InRelease to valid Release" | |
74 | create_fresh_archive | |
75 | add_new_package | |
76 | # switch to a unsinged repo now | |
77 | rm $APTARCHIVE/dists/unstable/InRelease | |
78 | rm $APTARCHIVE/dists/unstable/Release.gpg | |
79 | avoid_ims_hit | |
80 | ||
81 | # update works | |
82 | testsuccess aptget update -o Debug::Acquire::Transaction=1 | |
83 | ||
84 | # test that we can install the new packages but do no longer have a sig | |
85 | testsuccess aptget install old -s | |
86 | testsuccess aptget install new -s | |
87 | testfailure ls $ROOTDIR/var/lib/apt/lists/*_InRelease | |
88 | testfailure ls $ROOTDIR/var/lib/apt/lists/*_Release.gpg | |
89 | testsuccess ls $ROOTDIR/var/lib/apt/lists/*_Release | |
90 | } | |
91 | ||
92 | test_inreleae_to_release_reverts_all() { | |
93 | msgmsg "Test InRelease to broken Release reverts everything" | |
94 | create_fresh_archive | |
95 | ||
96 | # switch to a unsinged repo now | |
97 | add_new_package | |
98 | rm $APTARCHIVE/dists/unstable/InRelease | |
99 | rm $APTARCHIVE/dists/unstable/Release.gpg | |
100 | # break it | |
101 | break_repository_sources_index | |
102 | ||
103 | # ensure error | |
104 | testequal "W: Failed to fetch file:$APTARCHIVE/dists/unstable/InRelease | |
105 | ||
106 | W: Failed to fetch file:$APTARCHIVE/dists/unstable/Release | |
107 | ||
108 | W: Failed to fetch file:$APTARCHIVE/dists/unstable/Release.gpg | |
109 | ||
110 | W: Failed to fetch copy:$APTARCHIVE/dists/unstable/main/source/Sources Hash Sum mismatch | |
111 | ||
112 | W: Failed to fetch copy:$APTARCHIVE/dists/unstable/main/binary-i386/Packages | |
113 | ||
114 | E: Some index files failed to download. They have been ignored, or old ones used instead." aptget update -qq # -o Debug::acquire::transaction=1 | |
115 | ||
116 | # ensure that the Packages file is also rolled back | |
117 | testsuccess aptget install old -s | |
118 | testfailure aptget install new -s | |
119 | testsuccess ls $ROOTDIR/var/lib/apt/lists/*_InRelease | |
120 | testfailure ls $ROOTDIR/var/lib/apt/lists/*_Release | |
121 | } | |
122 | ||
123 | test_unauthenticated_to_invalid_inrelease() { | |
124 | msgmsg "Test UnAuthenticated to invalid InRelease reverts everything" | |
125 | create_fresh_archive | |
126 | rm $APTARCHIVE/dists/unstable/InRelease | |
127 | rm $APTARCHIVE/dists/unstable/Release.gpg | |
128 | avoid_ims_hit | |
129 | ||
130 | testsuccess aptget update -qq | |
131 | testequal "WARNING: The following packages cannot be authenticated! | |
132 | old | |
133 | E: There are problems and -y was used without --force-yes" aptget install -qq -y old | |
134 | ||
135 | # go to authenticated but not correct | |
136 | add_new_package | |
137 | break_repository_sources_index | |
138 | ||
6d979490 MV |
139 | testequal "W: Failed to fetch file:$APTARCHIVE/dists/unstable/InRelease |
140 | ||
e05672e8 MV |
141 | W: Failed to fetch copy:$APTARCHIVE/dists/unstable/main/source/Sources Hash Sum mismatch |
142 | ||
6d979490 MV |
143 | W: Failed to fetch copy:$APTARCHIVE/dists/unstable/main/binary-i386/Packages |
144 | ||
e05672e8 MV |
145 | E: Some index files failed to download. They have been ignored, or old ones used instead." aptget update -qq |
146 | ||
147 | testfailure ls rootdir/var/lib/apt/lists/*_InRelease | |
148 | testequal "WARNING: The following packages cannot be authenticated! | |
149 | old | |
150 | E: There are problems and -y was used without --force-yes" aptget install -qq -y old | |
151 | } | |
152 | ||
c5fced38 MV |
153 | test_inrelease_to_unauth_inrelease() { |
154 | msgmsg "Test InRelease to InRelease without sig" | |
155 | create_fresh_archive | |
156 | signreleasefiles 'Marvin Paranoid' | |
157 | avoid_ims_hit | |
158 | ||
159 | testsuccess aptget update -qq | |
160 | ||
161 | testequal "WARNING: The following packages cannot be authenticated! | |
162 | old | |
163 | E: There are problems and -y was used without --force-yes" aptget install -qq -y old | |
164 | ||
165 | testfailure ls rootdir/var/lib/apt/lists/*_InRelease | |
166 | testsuccess ls rootdir/var/lib/apt/lists/*_Release | |
167 | } | |
168 | ||
e05672e8 MV |
169 | TESTDIR=$(readlink -f $(dirname $0)) |
170 | . $TESTDIR/framework | |
171 | ||
172 | setupenvironment | |
173 | configarchitecture "i386" | |
174 | ||
175 | # setup the archive and ensure we have a single package that installs fine | |
176 | setupaptarchive | |
177 | APTARCHIVE=$(readlink -f ./aptarchive) | |
178 | ROOTDIR=${TMPWORKINGDIRECTORY}/rootdir | |
179 | APTARCHIVE_LISTS="$(echo $APTARCHIVE | tr "/" "_" )" | |
180 | ||
181 | # test the following cases: | |
182 | # - InRelease -> broken InRelease revert to previous state | |
183 | # - empty lists dir and broken remote leaves nothing on the system | |
184 | # - InRelease -> hashsum mismatch for one file reverts all files to previous state | |
185 | # - Release/Release.gpg -> hashsum mismatch | |
186 | # - InRelease -> Release with hashsum mismatch revert entire state and kills Release | |
187 | # - Release -> InRelease with broken Sig/Hash removes InRelease | |
188 | # going from Release/Release.gpg -> InRelease and vice versa | |
189 | # - unauthenticated -> invalid InRelease | |
190 | ||
191 | test_inrelease_to_new_inrelease | |
192 | test_inrelease_to_broken_hash_reverts_all | |
193 | ||
194 | test_inreleae_to_valid_release | |
195 | test_inreleae_to_release_reverts_all | |
196 | ||
6d979490 | 197 | test_unauthenticated_to_invalid_inrelease |
c5fced38 MV |
198 | |
199 | test_inrelease_to_unauth_inrelease |