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
47 aptget update
-o Debug
::Acquire
::Transaction
=1
49 testsuccess aptget update
-o Debug
::Acquire
::Transaction
=1
51 testequal
"new/unstable 1.0 all
52 old/unstable 1.0 all" apt list
-q
55 test_inrelease_to_broken_hash_reverts_all
() {
56 msgmsg
"Test InRelease to broken InRelease reverts everything"
59 # break the Sources file
60 break_repository_sources_index
62 # test the error condition
63 testequal
"W: Failed to fetch file:${APTARCHIVE}/dists/unstable/InRelease
65 W: Failed to fetch copy:${APTARCHIVE}/dists/unstable/main/source/Sources Hash Sum mismatch
67 W: Failed to fetch copy:${APTARCHIVE}/dists/unstable/main/binary-i386/Packages
69 E: Some index files failed to download. They have been ignored, or old ones used instead." aptget update
-qq
70 # ensure that the Packages file is also rolled back
71 testequal
"E: Unable to locate package new" aptget
install new
-s -qq
74 test_inreleae_to_valid_release
() {
75 msgmsg
"Test InRelease to valid Release"
78 # switch to a unsinged repo now
79 rm $APTARCHIVE/dists
/unstable
/InRelease
80 rm $APTARCHIVE/dists
/unstable
/Release.gpg
84 testsuccess aptget update
-o Debug
::Acquire
::Transaction
=1
86 # test that we can install the new packages but do no longer have a sig
87 testsuccess aptget
install old
-s
88 testsuccess aptget
install new
-s
89 testfailure
ls $ROOTDIR/var
/lib
/apt
/lists
/*_InRelease
90 testfailure
ls $ROOTDIR/var
/lib
/apt
/lists
/*_Release.gpg
91 testsuccess
ls $ROOTDIR/var
/lib
/apt
/lists
/*_Release
94 test_inreleae_to_release_reverts_all
() {
95 msgmsg
"Test InRelease to broken Release reverts everything"
98 # switch to a unsinged repo now
100 rm $APTARCHIVE/dists
/unstable
/InRelease
101 rm $APTARCHIVE/dists
/unstable
/Release.gpg
103 break_repository_sources_index
106 testequal
"W: Failed to fetch file:$APTARCHIVE/dists/unstable/InRelease
108 W: Failed to fetch file:$APTARCHIVE/dists/unstable/Release
110 W: Failed to fetch file:$APTARCHIVE/dists/unstable/Release.gpg
112 W: Failed to fetch copy:$APTARCHIVE/dists/unstable/main/source/Sources Hash Sum mismatch
114 W: Failed to fetch copy:$APTARCHIVE/dists/unstable/main/binary-i386/Packages
116 E: Some index files failed to download. They have been ignored, or old ones used instead." aptget update
-qq # -o Debug::acquire::transaction=1
118 # ensure that the Packages file is also rolled back
119 testsuccess aptget
install old
-s
120 testfailure aptget
install new
-s
121 testsuccess
ls $ROOTDIR/var
/lib
/apt
/lists
/*_InRelease
122 testfailure
ls $ROOTDIR/var
/lib
/apt
/lists
/*_Release
125 test_unauthenticated_to_invalid_inrelease
() {
126 msgmsg
"Test UnAuthenticated to invalid InRelease reverts everything"
128 rm $APTARCHIVE/dists
/unstable
/InRelease
129 rm $APTARCHIVE/dists
/unstable
/Release.gpg
132 testsuccess aptget update
-qq
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
137 # go to authenticated but not correct
139 break_repository_sources_index
141 testequal
"W: Failed to fetch file:$APTARCHIVE/dists/unstable/InRelease
143 W: Failed to fetch copy:$APTARCHIVE/dists/unstable/main/source/Sources Hash Sum mismatch
145 W: Failed to fetch copy:$APTARCHIVE/dists/unstable/main/binary-i386/Packages
147 E: Some index files failed to download. They have been ignored, or old ones used instead." aptget update
-qq
149 testfailure
ls rootdir
/var
/lib
/apt
/lists
/*_InRelease
150 testequal
"WARNING: The following packages cannot be authenticated!
152 E: There are problems and -y was used without --force-yes" aptget
install -qq -y old
155 test_inrelease_to_unauth_inrelease
() {
156 msgmsg
"Test InRelease to InRelease without sig"
158 signreleasefiles
'Marvin Paranoid'
161 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
163 W: Failed to fetch file:$APTARCHIVE/dists/unstable/InRelease
165 W: Some index files failed to download. They have been ignored, or old ones used instead." aptget update
-qq
167 testsuccess
ls rootdir
/var
/lib
/apt
/lists
/*_InRelease
170 TESTDIR
=$(readlink -f $(dirname $0))
174 configarchitecture
"i386"
176 # setup the archive and ensure we have a single package that installs fine
178 APTARCHIVE
=$(readlink -f ./aptarchive)
179 ROOTDIR
=${TMPWORKINGDIRECTORY}/rootdir
180 APTARCHIVE_LISTS
="$(echo $APTARCHIVE | tr "/" "_" )"
182 # test the following cases:
183 # - InRelease -> broken InRelease revert to previous state
184 # - empty lists dir and broken remote leaves nothing on the system
185 # - InRelease -> hashsum mismatch for one file reverts all files to previous state
186 # - Release/Release.gpg -> hashsum mismatch
187 # - InRelease -> Release with hashsum mismatch revert entire state and kills Release
188 # - Release -> InRelease with broken Sig/Hash removes InRelease
189 # going from Release/Release.gpg -> InRelease and vice versa
190 # - unauthenticated -> invalid InRelease
192 test_inrelease_to_new_inrelease
193 test_inrelease_to_broken_hash_reverts_all
195 test_inreleae_to_valid_release
196 test_inreleae_to_release_reverts_all
198 test_unauthenticated_to_invalid_inrelease
200 test_inrelease_to_unauth_inrelease