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'
22 setupaptarchive
--no-update
26 insertpackage
"unstable" "new" "all" "1.0"
27 insertsource
"unstable" "new" "all" "1.0"
29 setupaptarchive
--no-update "$@"
32 break_repository_sources_index
() {
33 printf 'xxx' > $APTARCHIVE/dists
/unstable
/main
/source
/Sources
34 compressfile
"$APTARCHIVE/dists/unstable/main/source/Sources" "$@"
37 start_with_good_inrelease
() {
39 testsuccess aptget update
40 testequal
"old/unstable 1.0 all" apt list
-q
43 test_inrelease_to_new_inrelease
() {
44 msgmsg
'Test InRelease to new InRelease works fine'
45 start_with_good_inrelease
47 add_new_package
'+1hour'
48 testsuccess aptget update
-o Debug
::Acquire
::Transaction
=1
49 testequal
"new/unstable 1.0 all
50 old/unstable 1.0 all" apt list
-q
53 test_inrelease_to_broken_hash_reverts_all
() {
54 msgmsg
'Test InRelease to broken InRelease reverts everything'
55 start_with_good_inrelease
57 add_new_package
'+1hour'
58 # break the Sources file
59 break_repository_sources_index
'+1hour'
61 # test the error condition
62 testequal
"W: Failed to fetch file:${APTARCHIVE}/dists/unstable/main/source/Sources Hash Sum mismatch
64 E: Some index files failed to download. They have been ignored, or old ones used instead." aptget update
-qq
65 # ensure that the Packages file is also rolled back
66 testequal
"E: Unable to locate package new" aptget
install new
-s -qq
69 test_inrelease_to_valid_release
() {
70 msgmsg
'Test InRelease to valid Release'
71 start_with_good_inrelease
73 add_new_package
'+1hour'
74 # switch to a unsigned repo now
75 rm $APTARCHIVE/dists
/unstable
/InRelease
76 rm $APTARCHIVE/dists
/unstable
/Release.gpg
79 testequal
"E: The repository 'file: unstable Release.gpg' is no longer signed." aptget update
-qq
81 # test that we can install the new packages but do no longer have a sig
82 testsuccess aptget
install old
-s
83 testfailure aptget
install new
-s
84 testsuccess
ls $ROOTDIR/var
/lib
/apt
/lists
/*_InRelease
85 testfailure
ls $ROOTDIR/var
/lib
/apt
/lists
/*_Release
88 test_inrelease_to_release_reverts_all
() {
89 msgmsg
'Test InRelease to broken Release reverts everything'
90 start_with_good_inrelease
92 # switch to a unsigned repo now
93 add_new_package
'+1hour'
94 rm $APTARCHIVE/dists
/unstable
/InRelease
95 rm $APTARCHIVE/dists
/unstable
/Release.gpg
98 break_repository_sources_index
'+1hour'
101 testequal
"E: The repository 'file: unstable Release.gpg' is no longer signed." aptget update
-qq # -o Debug::acquire::transaction=1
103 # ensure that the Packages file is also rolled back
104 testsuccess aptget
install old
-s
105 testfailure aptget
install new
-s
106 testsuccess
ls $ROOTDIR/var
/lib
/apt
/lists
/*_InRelease
107 testfailure
ls $ROOTDIR/var
/lib
/apt
/lists
/*_Release
110 test_unauthenticated_to_invalid_inrelease
() {
111 msgmsg
'Test UnAuthenticated to invalid InRelease reverts everything'
113 rm $APTARCHIVE/dists
/unstable
/InRelease
114 rm $APTARCHIVE/dists
/unstable
/Release.gpg
116 testsuccess aptget update
--allow-insecure-repositories
117 testequal
"WARNING: The following packages cannot be authenticated!
119 E: There are problems and -y was used without --force-yes" aptget
install -qq -y old
121 # go to authenticated but not correct
122 add_new_package
'+1hour'
123 break_repository_sources_index
'+1hour'
125 testequal
"W: Failed to fetch file:$APTARCHIVE/dists/unstable/main/source/Sources Hash Sum mismatch
127 E: Some index files failed to download. They have been ignored, or old ones used instead." aptget update
-qq
129 testfailure
ls rootdir
/var
/lib
/apt
/lists
/*_InRelease
130 testequal
"WARNING: The following packages cannot be authenticated!
132 E: There are problems and -y was used without --force-yes" aptget
install -qq -y old
135 test_inrelease_to_unauth_inrelease
() {
136 msgmsg
'Test InRelease to InRelease without good sig'
137 start_with_good_inrelease
139 signreleasefiles
'Marvin Paranoid'
141 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
143 W: Failed to fetch file:$APTARCHIVE/dists/unstable/InRelease The following signatures couldn't be verified because the public key is not available: NO_PUBKEY E8525D47528144E2
145 W: Some index files failed to download. They have been ignored, or old ones used instead." aptget update
-qq
147 testsuccess
ls rootdir
/var
/lib
/apt
/lists
/*_InRelease
150 test_inrelease_to_broken_gzip
() {
151 msgmsg
"Test InRelease to broken gzip"
152 start_with_good_inrelease
154 # append junk at the end of the compressed file
155 echo "lala" >> $APTARCHIVE/dists
/unstable
/main
/source
/Sources.gz
156 touch -d '+2min' $APTARCHIVE/dists
/unstable
/main
/source
/Sources.gz
157 # remove uncompressed file to avoid fallback
158 rm $APTARCHIVE/dists
/unstable
/main
/source
/Sources
160 testfailure aptget update
163 TESTDIR
=$(readlink -f $(dirname $0))
167 configarchitecture
"i386"
169 # setup the archive and ensure we have a single package that installs fine
171 APTARCHIVE
=$(readlink -f ./aptarchive)
172 ROOTDIR
=${TMPWORKINGDIRECTORY}/rootdir
173 APTARCHIVE_LISTS
="$(echo $APTARCHIVE | tr "/" "_" )"
175 # test the following cases:
176 # - InRelease -> broken InRelease revert to previous state
177 # - empty lists dir and broken remote leaves nothing on the system
178 # - InRelease -> hashsum mismatch for one file reverts all files to previous state
179 # - Release/Release.gpg -> hashsum mismatch
180 # - InRelease -> Release with hashsum mismatch revert entire state and kills Release
181 # - Release -> InRelease with broken Sig/Hash removes InRelease
182 # going from Release/Release.gpg -> InRelease and vice versa
183 # - unauthenticated -> invalid InRelease
189 test_inrelease_to_new_inrelease
190 test_inrelease_to_broken_hash_reverts_all
191 test_inrelease_to_valid_release
192 test_inrelease_to_release_reverts_all
193 test_unauthenticated_to_invalid_inrelease
194 test_inrelease_to_unauth_inrelease
195 test_inrelease_to_broken_gzip