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 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_inreleae_to_release_reverts_all
() {
89 msgmsg
"Test InRelease to broken Release reverts everything"
92 # switch to a unsinged repo now
94 rm $APTARCHIVE/dists
/unstable
/InRelease
95 rm $APTARCHIVE/dists
/unstable
/Release.gpg
97 break_repository_sources_index
100 testequal
"E: The repository 'file: unstable Release.gpg' is no longer signed." aptget update
-qq # -o Debug::acquire::transaction=1
102 # ensure that the Packages file is also rolled back
103 testsuccess aptget
install old
-s
104 testfailure aptget
install new
-s
105 testsuccess
ls $ROOTDIR/var
/lib
/apt
/lists
/*_InRelease
106 testfailure
ls $ROOTDIR/var
/lib
/apt
/lists
/*_Release
109 test_unauthenticated_to_invalid_inrelease
() {
110 msgmsg
"Test UnAuthenticated to invalid InRelease reverts everything"
112 rm -rf rootdir
/var
/lib
/apt
/lists
/*
113 rm $APTARCHIVE/dists
/unstable
/InRelease
114 rm $APTARCHIVE/dists
/unstable
/Release.gpg
117 testsuccess aptget update
-qq
118 testequal
"WARNING: The following packages cannot be authenticated!
120 E: There are problems and -y was used without --force-yes" aptget
install -qq -y old
122 # go to authenticated but not correct
124 break_repository_sources_index
126 testequal
"W: Failed to fetch file:$APTARCHIVE/dists/unstable/main/source/Sources Hash Sum mismatch
128 E: Some index files failed to download. They have been ignored, or old ones used instead." aptget update
-qq
130 testfailure
ls rootdir
/var
/lib
/apt
/lists
/*_InRelease
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
136 test_inrelease_to_unauth_inrelease
() {
137 msgmsg
"Test InRelease to InRelease without sig"
139 signreleasefiles
'Marvin Paranoid'
142 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
144 W: Failed to fetch file:$APTARCHIVE/dists/unstable/InRelease
146 W: Some index files failed to download. They have been ignored, or old ones used instead." aptget update
-qq
148 testsuccess
ls rootdir
/var
/lib
/apt
/lists
/*_InRelease
151 test_inrelease_to_broken_gzip
() {
152 msgmsg
"Test InRelease to broken gzip"
154 # append junk at the end of the gzip, this
155 echo "lala" >> $APTARCHIVE/dists
/unstable
/main
/source
/Sources.gz
156 # remove uncompressed file, otherwise apt will just fallback fetching
158 rm $APTARCHIVE/dists
/unstable
/main
/source
/Sources
161 testfailure aptget update
164 TESTDIR
=$(readlink -f $(dirname $0))
168 configarchitecture
"i386"
170 # setup the archive and ensure we have a single package that installs fine
172 APTARCHIVE
=$(readlink -f ./aptarchive)
173 ROOTDIR
=${TMPWORKINGDIRECTORY}/rootdir
174 APTARCHIVE_LISTS
="$(echo $APTARCHIVE | tr "/" "_" )"
176 # test the following cases:
177 # - InRelease -> broken InRelease revert to previous state
178 # - empty lists dir and broken remote leaves nothing on the system
179 # - InRelease -> hashsum mismatch for one file reverts all files to previous state
180 # - Release/Release.gpg -> hashsum mismatch
181 # - InRelease -> Release with hashsum mismatch revert entire state and kills Release
182 # - Release -> InRelease with broken Sig/Hash removes InRelease
183 # going from Release/Release.gpg -> InRelease and vice versa
184 # - unauthenticated -> invalid InRelease
190 test_inrelease_to_new_inrelease
191 test_inrelease_to_broken_hash_reverts_all
192 test_inreleae_to_valid_release
193 test_inreleae_to_release_reverts_all
194 test_unauthenticated_to_invalid_inrelease
195 test_inrelease_to_unauth_inrelease
196 test_inrelease_to_broken_gzip