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/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_inreleae_to_valid_release
() {
70 msgmsg
"Test InRelease to valid Release"
73 # switch to a unsinged repo now
74 rm $APTARCHIVE/dists
/unstable
/InRelease
75 rm $APTARCHIVE/dists
/unstable
/Release.gpg
79 testsuccess aptget update
-o Debug
::Acquire
::Transaction
=1
81 # test that we can install the new packages but do no longer have a sig
82 testsuccess aptget
install old
-s
83 testsuccess aptget
install new
-s
84 testfailure
ls $ROOTDIR/var
/lib
/apt
/lists
/*_InRelease
85 testfailure
ls $ROOTDIR/var
/lib
/apt
/lists
/*_Release.gpg
86 testsuccess
ls $ROOTDIR/var
/lib
/apt
/lists
/*_Release
89 test_inreleae_to_release_reverts_all
() {
90 msgmsg
"Test InRelease to broken Release reverts everything"
93 # switch to a unsinged repo now
95 rm $APTARCHIVE/dists
/unstable
/InRelease
96 rm $APTARCHIVE/dists
/unstable
/Release.gpg
98 break_repository_sources_index
101 testequal
"W: Failed to fetch file:$APTARCHIVE/dists/unstable/main/source/Sources Hash Sum mismatch
103 E: Some index files failed to download. They have been ignored, or old ones used instead." aptget update
-qq # -o Debug::acquire::transaction=1
105 # ensure that the Packages file is also rolled back
106 testsuccess aptget
install old
-s
107 testfailure aptget
install new
-s
108 testsuccess
ls $ROOTDIR/var
/lib
/apt
/lists
/*_InRelease
109 testfailure
ls $ROOTDIR/var
/lib
/apt
/lists
/*_Release
112 test_unauthenticated_to_invalid_inrelease
() {
113 msgmsg
"Test UnAuthenticated to invalid InRelease reverts everything"
115 rm $APTARCHIVE/dists
/unstable
/InRelease
116 rm $APTARCHIVE/dists
/unstable
/Release.gpg
119 testsuccess aptget update
-qq
120 testequal
"WARNING: The following packages cannot be authenticated!
122 E: There are problems and -y was used without --force-yes" aptget
install -qq -y old
124 # go to authenticated but not correct
126 break_repository_sources_index
128 testequal
"W: Failed to fetch file:$APTARCHIVE/dists/unstable/main/source/Sources Hash Sum mismatch
130 E: Some index files failed to download. They have been ignored, or old ones used instead." aptget update
-qq
132 testfailure
ls rootdir
/var
/lib
/apt
/lists
/*_InRelease
133 testequal
"WARNING: The following packages cannot be authenticated!
135 E: There are problems and -y was used without --force-yes" aptget
install -qq -y old
138 test_inrelease_to_unauth_inrelease
() {
139 msgmsg
"Test InRelease to InRelease without sig"
141 signreleasefiles
'Marvin Paranoid'
144 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
146 W: Failed to fetch file:$APTARCHIVE/dists/unstable/InRelease
148 W: Some index files failed to download. They have been ignored, or old ones used instead." aptget update
-qq
150 testsuccess
ls rootdir
/var
/lib
/apt
/lists
/*_InRelease
153 test_inrelease_to_broken_gzip
() {
154 msgmsg
"Test InRelease to broken gzip"
156 # append junk at the end of the gzip, this
157 echo "lala" >> $APTARCHIVE/dists
/unstable
/main
/source
/Sources.gz
158 # remove uncompressed file, otherwise apt will just fallback fetching
160 rm $APTARCHIVE/dists
/unstable
/main
/source
/Sources
163 testfailure aptget update
166 TESTDIR
=$(readlink -f $(dirname $0))
170 configarchitecture
"i386"
172 # setup the archive and ensure we have a single package that installs fine
174 APTARCHIVE
=$(readlink -f ./aptarchive)
175 ROOTDIR
=${TMPWORKINGDIRECTORY}/rootdir
176 APTARCHIVE_LISTS
="$(echo $APTARCHIVE | tr "/" "_" )"
178 # test the following cases:
179 # - InRelease -> broken InRelease revert to previous state
180 # - empty lists dir and broken remote leaves nothing on the system
181 # - InRelease -> hashsum mismatch for one file reverts all files to previous state
182 # - Release/Release.gpg -> hashsum mismatch
183 # - InRelease -> Release with hashsum mismatch revert entire state and kills Release
184 # - Release -> InRelease with broken Sig/Hash removes InRelease
185 # going from Release/Release.gpg -> InRelease and vice versa
186 # - unauthenticated -> invalid InRelease
192 test_inrelease_to_new_inrelease
193 test_inrelease_to_broken_hash_reverts_all
194 test_inreleae_to_valid_release
195 test_inreleae_to_release_reverts_all
196 test_unauthenticated_to_invalid_inrelease
197 test_inrelease_to_unauth_inrelease
198 test_inrelease_to_broken_gzip