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 testsuccess aptget update
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"
57 # break the Sources file
58 break_repository_sources_index
60 # test the error condition
61 testequal
"W: Failed to fetch file:${APTARCHIVE}/dists/unstable/InRelease
63 W: Failed to fetch copy:${APTARCHIVE}/dists/unstable/main/source/Sources Hash Sum mismatch
65 W: Failed to fetch copy:${APTARCHIVE}/dists/unstable/main/binary-i386/Packages
67 E: Some index files failed to download. They have been ignored, or old ones used instead." aptget update
-qq
68 # ensure that the Packages file is also rolled back
69 testequal
"E: Unable to locate package new" aptget
install new
-s -qq
72 test_inreleae_to_valid_release
() {
73 msgmsg
"Test InRelease to valid Release"
76 # switch to a unsinged repo now
77 rm $APTARCHIVE/dists
/unstable
/InRelease
78 rm $APTARCHIVE/dists
/unstable
/Release.gpg
82 testsuccess aptget update
-o Debug
::Acquire
::Transaction
=1
84 # test that we can install the new packages but do no longer have a sig
85 testsuccess aptget
install old
-s
86 testsuccess aptget
install new
-s
87 testfailure
ls $ROOTDIR/var
/lib
/apt
/lists
/*_InRelease
88 testfailure
ls $ROOTDIR/var
/lib
/apt
/lists
/*_Release.gpg
89 testsuccess
ls $ROOTDIR/var
/lib
/apt
/lists
/*_Release
92 test_inreleae_to_release_reverts_all
() {
93 msgmsg
"Test InRelease to broken Release reverts everything"
96 # switch to a unsinged repo now
98 rm $APTARCHIVE/dists
/unstable
/InRelease
99 rm $APTARCHIVE/dists
/unstable
/Release.gpg
101 break_repository_sources_index
104 testequal
"W: Failed to fetch file:$APTARCHIVE/dists/unstable/InRelease
106 W: Failed to fetch file:$APTARCHIVE/dists/unstable/Release
108 W: Failed to fetch file:$APTARCHIVE/dists/unstable/Release.gpg
110 W: Failed to fetch copy:$APTARCHIVE/dists/unstable/main/source/Sources Hash Sum mismatch
112 W: Failed to fetch copy:$APTARCHIVE/dists/unstable/main/binary-i386/Packages
114 E: Some index files failed to download. They have been ignored, or old ones used instead." aptget update
-qq # -o Debug::acquire::transaction=1
116 # ensure that the Packages file is also rolled back
117 testsuccess aptget
install old
-s
118 testfailure aptget
install new
-s
119 testsuccess
ls $ROOTDIR/var
/lib
/apt
/lists
/*_InRelease
120 testfailure
ls $ROOTDIR/var
/lib
/apt
/lists
/*_Release
123 test_unauthenticated_to_invalid_inrelease
() {
124 msgmsg
"Test UnAuthenticated to invalid InRelease reverts everything"
126 rm $APTARCHIVE/dists
/unstable
/InRelease
127 rm $APTARCHIVE/dists
/unstable
/Release.gpg
130 testsuccess aptget update
-qq
131 testequal
"WARNING: The following packages cannot be authenticated!
133 E: There are problems and -y was used without --force-yes" aptget
install -qq -y old
135 # go to authenticated but not correct
137 break_repository_sources_index
139 testequal
"W: Failed to fetch file:$APTARCHIVE/dists/unstable/InRelease
141 W: Failed to fetch copy:$APTARCHIVE/dists/unstable/main/source/Sources Hash Sum mismatch
143 W: Failed to fetch copy:$APTARCHIVE/dists/unstable/main/binary-i386/Packages
145 E: Some index files failed to download. They have been ignored, or old ones used instead." aptget update
-qq
147 testfailure
ls rootdir
/var
/lib
/apt
/lists
/*_InRelease
148 testequal
"WARNING: The following packages cannot be authenticated!
150 E: There are problems and -y was used without --force-yes" aptget
install -qq -y old
153 test_inrelease_to_unauth_inrelease
() {
154 msgmsg
"Test InRelease to InRelease without sig"
156 signreleasefiles
'Marvin Paranoid'
159 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
161 W: Failed to fetch file:$APTARCHIVE/dists/unstable/InRelease
163 W: Some index files failed to download. They have been ignored, or old ones used instead." aptget update
-qq
165 testsuccess
ls rootdir
/var
/lib
/apt
/lists
/*_InRelease
168 TESTDIR
=$(readlink -f $(dirname $0))
172 configarchitecture
"i386"
174 # setup the archive and ensure we have a single package that installs fine
176 APTARCHIVE
=$(readlink -f ./aptarchive)
177 ROOTDIR
=${TMPWORKINGDIRECTORY}/rootdir
178 APTARCHIVE_LISTS
="$(echo $APTARCHIVE | tr "/" "_" )"
180 # test the following cases:
181 # - InRelease -> broken InRelease revert to previous state
182 # - empty lists dir and broken remote leaves nothing on the system
183 # - InRelease -> hashsum mismatch for one file reverts all files to previous state
184 # - Release/Release.gpg -> hashsum mismatch
185 # - InRelease -> Release with hashsum mismatch revert entire state and kills Release
186 # - Release -> InRelease with broken Sig/Hash removes InRelease
187 # going from Release/Release.gpg -> InRelease and vice versa
188 # - unauthenticated -> invalid InRelease
190 test_inrelease_to_new_inrelease
191 test_inrelease_to_broken_hash_reverts_all
193 test_inreleae_to_valid_release
194 test_inreleae_to_release_reverts_all
196 test_unauthenticated_to_invalid_inrelease
198 test_inrelease_to_unauth_inrelease