3 # test that apt-get update is transactional
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
*
12 touch -d '-1hour' rootdir
/var
/lib
/apt
/lists
/*
15 create_fresh_archive
()
18 rm -f rootdir
/var
/lib
/apt
/lists
/_
* rootdir
/var
/lib
/apt
/lists
/partial
/*
20 insertpackage
'unstable' 'old' 'all' '1.0'
26 insertpackage
"unstable" "new" "all" "1.0"
27 insertsource
"unstable" "new" "all" "1.0"
29 setupaptarchive
--no-update
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
41 test_inrelease_to_new_inrelease
() {
42 msgmsg
"Test InRelease to new InRelease works fine"
44 testequal
"old/unstable 1.0 all" apt list
-q
48 testsuccess aptget update
-o Debug
::Acquire
::Transaction
=1
50 testequal
"new/unstable 1.0 all
51 old/unstable 1.0 all" apt list
-q
54 test_inrelease_to_broken_hash_reverts_all
() {
55 msgmsg
"Test InRelease to broken InRelease reverts everything"
58 # break the Sources file
59 break_repository_sources_index
61 # test the error condition
62 testequal
"W: Failed to fetch file:${APTARCHIVE}/dists/unstable/InRelease
64 W: Failed to fetch file:${APTARCHIVE}/dists/unstable/main/source/Sources Hash Sum mismatch
66 E: Some index files failed to download. They have been ignored, or old ones used instead." aptget update
-qq
67 # ensure that the Packages file is also rolled back
68 testequal
"E: Unable to locate package new" aptget
install new
-s -qq
71 test_inreleae_to_valid_release
() {
72 msgmsg
"Test InRelease to valid Release"
75 # switch to a unsinged repo now
76 rm $APTARCHIVE/dists
/unstable
/InRelease
77 rm $APTARCHIVE/dists
/unstable
/Release.gpg
81 testsuccess aptget update
-o Debug
::Acquire
::Transaction
=1
83 # test that we can install the new packages but do no longer have a sig
84 testsuccess aptget
install old
-s
85 testsuccess aptget
install new
-s
86 testfailure
ls $ROOTDIR/var
/lib
/apt
/lists
/*_InRelease
87 testfailure
ls $ROOTDIR/var
/lib
/apt
/lists
/*_Release.gpg
88 testsuccess
ls $ROOTDIR/var
/lib
/apt
/lists
/*_Release
91 test_inreleae_to_release_reverts_all
() {
92 msgmsg
"Test InRelease to broken Release reverts everything"
95 # switch to a unsinged repo now
97 rm $APTARCHIVE/dists
/unstable
/InRelease
98 rm $APTARCHIVE/dists
/unstable
/Release.gpg
100 break_repository_sources_index
103 testequal
"W: Failed to fetch file:$APTARCHIVE/dists/unstable/InRelease
105 W: Failed to fetch file:$APTARCHIVE/dists/unstable/Release
107 W: Failed to fetch file:$APTARCHIVE/dists/unstable/Release.gpg
109 W: Failed to fetch file:$APTARCHIVE/dists/unstable/main/source/Sources Hash Sum mismatch
111 E: Some index files failed to download. They have been ignored, or old ones used instead." aptget update
-qq # -o Debug::acquire::transaction=1
113 # ensure that the Packages file is also rolled back
114 testsuccess aptget
install old
-s
115 testfailure aptget
install new
-s
116 testsuccess
ls $ROOTDIR/var
/lib
/apt
/lists
/*_InRelease
117 testfailure
ls $ROOTDIR/var
/lib
/apt
/lists
/*_Release
120 test_unauthenticated_to_invalid_inrelease
() {
121 msgmsg
"Test UnAuthenticated to invalid InRelease reverts everything"
123 rm $APTARCHIVE/dists
/unstable
/InRelease
124 rm $APTARCHIVE/dists
/unstable
/Release.gpg
127 testsuccess aptget update
-qq
128 testequal
"WARNING: The following packages cannot be authenticated!
130 E: There are problems and -y was used without --force-yes" aptget
install -qq -y old
132 # go to authenticated but not correct
134 break_repository_sources_index
136 testequal
"W: Failed to fetch file:$APTARCHIVE/dists/unstable/InRelease
138 W: Failed to fetch file:$APTARCHIVE/dists/unstable/main/source/Sources Hash Sum mismatch
140 E: Some index files failed to download. They have been ignored, or old ones used instead." aptget update
-qq
142 testfailure
ls rootdir
/var
/lib
/apt
/lists
/*_InRelease
143 testequal
"WARNING: The following packages cannot be authenticated!
145 E: There are problems and -y was used without --force-yes" aptget
install -qq -y old
148 test_inrelease_to_unauth_inrelease
() {
149 msgmsg
"Test InRelease to InRelease without sig"
151 signreleasefiles
'Marvin Paranoid'
154 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
156 W: Failed to fetch file:$APTARCHIVE/dists/unstable/InRelease
158 W: Some index files failed to download. They have been ignored, or old ones used instead." aptget update
-qq
160 testsuccess
ls rootdir
/var
/lib
/apt
/lists
/*_InRelease
163 test_inrelease_to_broken_gzip
() {
164 msgmsg
"Test InRelease to broken gzip"
166 # append junk at the end of the gzip, this
167 echo "lala" >> $APTARCHIVE/dists
/unstable
/main
/source
/Sources.gz
168 # remove uncompressed file, otherwise apt will just fallback fetching
170 rm $APTARCHIVE/dists
/unstable
/main
/source
/Sources
173 testfailure aptget update
176 TESTDIR
=$(readlink -f $(dirname $0))
180 configarchitecture
"i386"
182 # setup the archive and ensure we have a single package that installs fine
184 APTARCHIVE
=$(readlink -f ./aptarchive)
185 ROOTDIR
=${TMPWORKINGDIRECTORY}/rootdir
186 APTARCHIVE_LISTS
="$(echo $APTARCHIVE | tr "/" "_" )"
188 # test the following cases:
189 # - InRelease -> broken InRelease revert to previous state
190 # - empty lists dir and broken remote leaves nothing on the system
191 # - InRelease -> hashsum mismatch for one file reverts all files to previous state
192 # - Release/Release.gpg -> hashsum mismatch
193 # - InRelease -> Release with hashsum mismatch revert entire state and kills Release
194 # - Release -> InRelease with broken Sig/Hash removes InRelease
195 # going from Release/Release.gpg -> InRelease and vice versa
196 # - unauthenticated -> invalid InRelease
198 test_inrelease_to_new_inrelease
199 test_inrelease_to_broken_hash_reverts_all
200 test_inreleae_to_valid_release
201 test_inreleae_to_release_reverts_all
202 test_unauthenticated_to_invalid_inrelease
203 test_inrelease_to_unauth_inrelease
204 test_inrelease_to_broken_gzip