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 copy:${APTARCHIVE}/dists/unstable/main/source/Sources Hash Sum mismatch
66 W: Failed to fetch copy:${APTARCHIVE}/dists/unstable/main/binary-i386/Packages
68 E: Some index files failed to download. They have been ignored, or old ones used instead." aptget update
-qq
69 # ensure that the Packages file is also rolled back
70 testequal
"E: Unable to locate package new" aptget
install new
-s -qq
73 test_inreleae_to_valid_release
() {
74 msgmsg
"Test InRelease to valid Release"
77 # switch to a unsinged repo now
78 rm $APTARCHIVE/dists
/unstable
/InRelease
79 rm $APTARCHIVE/dists
/unstable
/Release.gpg
83 testsuccess aptget update
-o Debug
::Acquire
::Transaction
=1
85 # test that we can install the new packages but do no longer have a sig
86 testsuccess aptget
install old
-s
87 testsuccess aptget
install new
-s
88 testfailure
ls $ROOTDIR/var
/lib
/apt
/lists
/*_InRelease
89 testfailure
ls $ROOTDIR/var
/lib
/apt
/lists
/*_Release.gpg
90 testsuccess
ls $ROOTDIR/var
/lib
/apt
/lists
/*_Release
93 test_inreleae_to_release_reverts_all
() {
94 msgmsg
"Test InRelease to broken Release reverts everything"
97 # switch to a unsinged repo now
99 rm $APTARCHIVE/dists
/unstable
/InRelease
100 rm $APTARCHIVE/dists
/unstable
/Release.gpg
102 break_repository_sources_index
105 testequal
"W: Failed to fetch file:$APTARCHIVE/dists/unstable/InRelease
107 W: Failed to fetch file:$APTARCHIVE/dists/unstable/Release
109 W: Failed to fetch file:$APTARCHIVE/dists/unstable/Release.gpg
111 W: Failed to fetch copy:$APTARCHIVE/dists/unstable/main/source/Sources Hash Sum mismatch
113 W: Failed to fetch copy:$APTARCHIVE/dists/unstable/main/binary-i386/Packages
115 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 # ensure that the Packages file is also rolled back
118 testsuccess aptget
install old
-s
119 testfailure aptget
install new
-s
120 testsuccess
ls $ROOTDIR/var
/lib
/apt
/lists
/*_InRelease
121 testfailure
ls $ROOTDIR/var
/lib
/apt
/lists
/*_Release
124 test_unauthenticated_to_invalid_inrelease
() {
125 msgmsg
"Test UnAuthenticated to invalid InRelease reverts everything"
127 rm $APTARCHIVE/dists
/unstable
/InRelease
128 rm $APTARCHIVE/dists
/unstable
/Release.gpg
131 testsuccess aptget update
-qq
132 testequal
"WARNING: The following packages cannot be authenticated!
134 E: There are problems and -y was used without --force-yes" aptget
install -qq -y old
136 # go to authenticated but not correct
138 break_repository_sources_index
140 testequal
"W: Failed to fetch file:$APTARCHIVE/dists/unstable/InRelease
142 W: Failed to fetch copy:$APTARCHIVE/dists/unstable/main/source/Sources Hash Sum mismatch
144 W: Failed to fetch copy:$APTARCHIVE/dists/unstable/main/binary-i386/Packages
146 E: Some index files failed to download. They have been ignored, or old ones used instead." aptget update
-qq
148 testfailure
ls rootdir
/var
/lib
/apt
/lists
/*_InRelease
149 testequal
"WARNING: The following packages cannot be authenticated!
151 E: There are problems and -y was used without --force-yes" aptget
install -qq -y old
154 test_inrelease_to_unauth_inrelease
() {
155 msgmsg
"Test InRelease to InRelease without sig"
157 signreleasefiles
'Marvin Paranoid'
160 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
162 W: Failed to fetch file:$APTARCHIVE/dists/unstable/InRelease
164 W: Some index files failed to download. They have been ignored, or old ones used instead." aptget update
-qq
166 testsuccess
ls rootdir
/var
/lib
/apt
/lists
/*_InRelease
169 TESTDIR
=$(readlink -f $(dirname $0))
173 configarchitecture
"i386"
175 # setup the archive and ensure we have a single package that installs fine
177 APTARCHIVE
=$(readlink -f ./aptarchive)
178 ROOTDIR
=${TMPWORKINGDIRECTORY}/rootdir
179 APTARCHIVE_LISTS
="$(echo $APTARCHIVE | tr "/" "_" )"
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
191 test_inrelease_to_new_inrelease
192 test_inrelease_to_broken_hash_reverts_all
194 test_inreleae_to_valid_release
195 test_inreleae_to_release_reverts_all
197 test_unauthenticated_to_invalid_inrelease
199 test_inrelease_to_unauth_inrelease