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 TESTDIR
=$(readlink -f $(dirname $0))
157 configarchitecture
"i386"
159 # setup the archive and ensure we have a single package that installs fine
161 APTARCHIVE
=$(readlink -f ./aptarchive)
162 ROOTDIR
=${TMPWORKINGDIRECTORY}/rootdir
163 APTARCHIVE_LISTS
="$(echo $APTARCHIVE | tr "/" "_" )"
165 # test the following cases:
166 # - InRelease -> broken InRelease revert to previous state
167 # - empty lists dir and broken remote leaves nothing on the system
168 # - InRelease -> hashsum mismatch for one file reverts all files to previous state
169 # - Release/Release.gpg -> hashsum mismatch
170 # - InRelease -> Release with hashsum mismatch revert entire state and kills Release
171 # - Release -> InRelease with broken Sig/Hash removes InRelease
172 # going from Release/Release.gpg -> InRelease and vice versa
173 # - unauthenticated -> invalid InRelease
175 test_inrelease_to_new_inrelease
176 test_inrelease_to_broken_hash_reverts_all
178 test_inreleae_to_valid_release
179 test_inreleae_to_release_reverts_all
181 test_unauthenticated_to_invalid_inrelease