4 TESTDIR
=$(readlink -f $(dirname $0))
8 configarchitecture
'i386'
14 PKGFILE
="${TESTDIR}/$(echo "$(basename $0)" | sed 's#^test-#Packages-#')"
17 testsuccess aptget update "$@
"
19 msgtest 'No intermediate patch files' 'still exist'
20 local EDS="$(find rootdir/var/lib/apt/lists -name '*.ed' -o -name '*.ed.*')"
21 if [ -z "$EDS" ]; then
29 msgtest 'Check if the right pdiff merger was used'
30 if grep -q '^pkgAcqIndexMergeDiffs::Done(): rred' rootdir/tmp/testsuccess.output; then
31 if echo "$
*" | grep -q -- '-o Acquire::PDiffs::Merge=1'; then
34 msgfail "Merge shouldn
't have been used, but was"
36 elif echo "$*" | grep -q -- '-o Acquire
::PDiffs
::Merge
=1'; then
37 msgfail "Merge should have been used, but wasn't
"
44 msgmsg "Testcase
: setup the base with
: $
*"
45 find aptarchive -name 'Packages*' -type f -delete
46 cp ${PKGFILE} aptarchive/Packages
47 compressfile 'aptarchive/Packages'
50 rm -rf aptarchive/Packages.diff rootdir/var/lib/apt/lists rootdir/var/lib/apt/lists-bak
51 testsuccess aptget update "$@
"
52 cp -a rootdir/var/lib/apt/lists rootdir/var/lib/apt/lists-bak
53 testnopackage newstuff
54 testsuccessequal "$(cat ${PKGFILE})
55 " aptcache show apt oldstuff
57 msgmsg "Testcase
: apply with one
patch: $
*"
58 cp ${PKGFILE}-new aptarchive/Packages
59 compressfile 'aptarchive/Packages'
60 mkdir -p aptarchive/Packages.diff
61 PATCHFILE="aptarchive
/Packages.diff
/$(date +%Y-%m-%d-%H%M.%S)"
62 diff -e ${PKGFILE} ${PKGFILE}-new > ${PATCHFILE} || true
63 cat $PATCHFILE | gzip > ${PATCHFILE}.gz
64 PATCHINDEX='aptarchive/Packages.diff/Index'
65 echo "SHA1
-Current: $(sha1sum ${PKGFILE}-new | cut -d' ' -f 1) $(stat -c%s ${PKGFILE}-new)
67 9f4148e06d7faa37062994ff10d0c842d7017513
33053002 2010-08-18-2013.28
68 $(sha1sum $PKGFILE | cut -d' ' -f 1) $(stat -c%s $PKGFILE) $(basename $PATCHFILE)
70 7651fc0ac57cd83d41c63195a9342e2db5650257
19722 2010-08-18-2013.28
71 $(sha1sum $PATCHFILE | cut -d' ' -f 1) $(stat -c%s $PATCHFILE) $(basename $PATCHFILE)
72 SHA256
-Current: $(sha256sum ${PKGFILE}-new | cut -d' ' -f 1) $(stat -c%s ${PKGFILE}-new)
74 01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b
33053002 2010-08-18-2013.28
75 $(sha256sum $PKGFILE | cut -d' ' -f 1) $(stat -c%s $PKGFILE) $(basename $PATCHFILE)
77 e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
19722 2010-08-18-2013.28
78 $(sha256sum $PATCHFILE | cut -d' ' -f 1) $(stat -c%s $PATCHFILE) $(basename $PATCHFILE)" > $PATCHINDEX
79 generatereleasefiles '+1hour'
81 find aptarchive -name 'Packages*' -type f -delete
83 testnopackage oldstuff
84 testsuccessequal "$(cat ${PKGFILE}-new)
85 " aptcache show apt newstuff
87 msgmsg "Testcase
: index is already up
-to-date: $
*"
88 find rootdir/var/lib/apt/lists -name '*diff_Index' -type f -delete
89 testsuccess aptget update "$@
"
90 testequal 'Hit http://localhost:8080 InRelease
91 Reading package lists...' aptget update "$@
" -o Debug::Acquire::Transaction=0 -o Debug::pkgAcquire::Diffs=0
92 testsuccessequal "$(cat ${PKGFILE}-new)
93 " aptcache show apt newstuff
95 msgmsg "Testcase
: apply with two patches
: $
*"
96 cp ${PKGFILE}-new aptarchive/Packages
101 Maintainer: Joe Sixpack <joe@example.org>
103 Filename: pool/futurestuff_1.0_i386.deb
105 MD5sum: 311aeeaaae5ba33aff1ceaf3e1f76671
106 SHA1: 3c695e028f7a1ae324deeaae5ba332desa81088c
107 SHA256: b46fd154615edaae5ba33c56a5cc0e7deaef23e2da3e4f129727fd660f28f050
108 Description: some cool and shiny future stuff
109 This package will appear in the next next mirror update
110 Description-md5: d5f89fbbc2ce34c455dfee9b67d82b6b' >> aptarchive/Packages
112 compressfile 'aptarchive/Packages'
113 PATCHFILE2="aptarchive
/Packages.diff
/$(date -d 'now + 1hour' '+%Y-%m-%d-%H%M.%S')"
114 diff -e ${PKGFILE}-new aptarchive/Packages > ${PATCHFILE2} || true
115 cat $PATCHFILE2 | gzip > ${PATCHFILE2}.gz
116 echo "SHA1
-Current: $(sha1sum aptarchive/Packages | cut -d' ' -f 1) $(stat -c%s aptarchive/Packages)
118 9f4148e06d7faa37062994ff10d0c842d7017513
33053002 2010-08-18-2013.28
119 $(sha1sum ${PKGFILE} | cut -d' ' -f 1) $(stat -c%s ${PKGFILE}) $(basename ${PATCHFILE})
120 $(sha1sum ${PKGFILE}-new | cut -d' ' -f 1) $(stat -c%s ${PKGFILE}-new) $(basename ${PATCHFILE2})
122 7651fc0ac57cd83d41c63195a9342e2db5650257
19722 2010-08-18-2013.28
123 $(sha1sum $PATCHFILE | cut -d' ' -f 1) $(stat -c%s $PATCHFILE) $(basename $PATCHFILE)
124 $(sha1sum ${PATCHFILE2} | cut -d' ' -f 1) $(stat -c%s ${PATCHFILE2}) $(basename ${PATCHFILE2})
125 SHA256
-Current: $(sha256sum aptarchive/Packages | cut -d' ' -f 1) $(stat -c%s aptarchive/Packages)
127 01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b
33053002 2010-08-18-2013.28
128 $(sha256sum $PKGFILE | cut -d' ' -f 1) $(stat -c%s $PKGFILE) $(basename $PATCHFILE)
129 $(sha256sum ${PKGFILE}-new | cut -d' ' -f 1) $(stat -c%s ${PKGFILE}-new) $(basename ${PATCHFILE2})
131 e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
19722 2010-08-18-2013.28
132 $(sha256sum $PATCHFILE | cut -d' ' -f 1) $(stat -c%s $PATCHFILE) $(basename $PATCHFILE)
133 $(sha256sum ${PATCHFILE2} | cut -d' ' -f 1) $(stat -c%s ${PATCHFILE2}) $(basename ${PATCHFILE2})" > $PATCHINDEX
134 generatereleasefiles '+2hour'
136 cp -a aptarchive/Packages Packages-future
137 find aptarchive -name 'Packages*' -type f -delete
138 rm -rf rootdir/var/lib/apt/lists
139 cp -a rootdir/var/lib/apt/lists-bak rootdir/var/lib/apt/lists
141 testnopackage oldstuff
142 testsuccessequal "$(cat Packages-future)
143 " aptcache show apt newstuff futurestuff
145 msgmsg "Testcase
: patch applying fails
, but successful fallback
: $
*"
146 rm -rf rootdir/var/lib/apt/lists
147 cp -a rootdir/var/lib/apt/lists-bak rootdir/var/lib/apt/lists
148 cp ${PKGFILE}-new aptarchive/Packages
149 compressfile 'aptarchive/Packages'
150 mkdir -p aptarchive/Packages.diff
151 PATCHFILE="aptarchive
/Packages.diff
/$(date +%Y-%m-%d-%H%M.%S)"
152 diff -e ${PKGFILE} ${PKGFILE}-new > ${PATCHFILE} || true
153 PATCHINDEX='aptarchive/Packages.diff/Index'
154 echo "SHA1
-Current: $(sha1sum ${PKGFILE}-new | cut -d' ' -f 1) $(stat -c%s ${PKGFILE}-new)
156 9f4148e06d7faa37062994ff10d0c842d7017513
33053002 2010-08-18-2013.28
157 $(sha1sum $PKGFILE | cut -d' ' -f 1) $(stat -c%s $PKGFILE) $(basename $PATCHFILE)
159 7651fc0ac57cd83d41c63195a9342e2db5650257
19722 2010-08-18-2013.28
160 $(sha1sum $PATCHFILE | cut -d' ' -f 1) $(stat -c%s $PATCHFILE) $(basename $PATCHFILE)
161 SHA256
-Current: $(sha256sum ${PKGFILE}-new | cut -d' ' -f 1) $(stat -c%s ${PKGFILE}-new)
163 01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b
33053002 2010-08-18-2013.28
164 $(sha256sum $PKGFILE | cut -d' ' -f 1) $(stat -c%s $PKGFILE) $(basename $PATCHFILE)
166 e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
19722 2010-08-18-2013.28
167 $(sha256sum $PATCHFILE | cut -d' ' -f 1) $(stat -c%s $PATCHFILE) $(basename $PATCHFILE)" > $PATCHINDEX
168 echo 'I am Mallory and I change files' >> $PATCHFILE
169 cat $PATCHFILE | gzip > ${PATCHFILE}.gz
170 generatereleasefiles '+1hour'
172 testsuccess aptget update "$@
"
173 testnopackage oldstuff
174 testsuccessequal "$(cat ${PKGFILE}-new)
175 " aptcache show apt newstuff
177 msgmsg "Testcase
: pdiff
patch bigger than index itself
: $
*"
178 rm -rf rootdir/var/lib/apt/lists
179 cp -a rootdir/var/lib/apt/lists-bak rootdir/var/lib/apt/lists
180 cp ${PKGFILE}-new aptarchive/Packages
181 compressfile 'aptarchive/Packages'
182 mkdir -p aptarchive/Packages.diff
183 PATCHFILE="aptarchive
/Packages.diff
/$(date +%Y-%m-%d-%H%M.%S)"
184 diff -e ${PKGFILE} ${PKGFILE}-new > ${PATCHFILE} || true
185 cat $PATCHFILE | gzip > ${PATCHFILE}.gz
186 PATCHINDEX='aptarchive/Packages.diff/Index'
187 echo "SHA1
-Current: $(sha1sum ${PKGFILE}-new | cut -d' ' -f 1) $(stat -c%s ${PKGFILE}-new)
189 9f4148e06d7faa37062994ff10d0c842d7017513
33053002 2010-08-18-2013.28
190 $(sha1sum $PKGFILE | cut -d' ' -f 1) $(stat -c%s $PKGFILE) $(basename $PATCHFILE)
192 7651fc0ac57cd83d41c63195a9342e2db5650257
19722 2010-08-18-2013.28
193 $(sha1sum $PATCHFILE | cut -d' ' -f 1) $(stat -c%s $PATCHFILE)000 $(basename $PATCHFILE)
194 SHA256
-Current: $(sha256sum ${PKGFILE}-new | cut -d' ' -f 1) $(stat -c%s ${PKGFILE}-new)
196 01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b
33053002 2010-08-18-2013.28
197 $(sha256sum $PKGFILE | cut -d' ' -f 1) $(stat -c%s $PKGFILE) $(basename $PATCHFILE)
199 e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
19722 2010-08-18-2013.28
200 $(sha256sum $PATCHFILE | cut -d' ' -f 1) $(stat -c%s $PATCHFILE)000 $(basename $PATCHFILE)" > $PATCHINDEX
201 generatereleasefiles '+1hour'
203 #find aptarchive -name 'Packages*' -type f -delete
204 testsuccess aptget update -o Debug::pkgAcquire::Diffs=1 "$@
"
205 cp -f rootdir/tmp/testsuccess.output rootdir/tmp/aptgetupdate.output
206 testsuccess grep 'bytes (Limit is' rootdir/tmp/aptgetupdate.output
207 testnopackage oldstuff
208 testsuccessequal "$(cat ${PKGFILE}-new)
209 " aptcache show apt newstuff
211 echo 'Debug::pkgAcquire::Diffs "true
";
212 Debug::Acquire::Transaction "true
";
213 Debug::pkgAcquire::rred "true
";' > rootdir/etc/apt/apt.conf.d/rreddebug.conf
215 testrun -o Acquire::PDiffs::Merge=0 -o APT::Get::List-Cleanup=1
216 testrun -o Acquire::PDiffs::Merge=1 -o APT::Get::List-Cleanup=1
217 testrun -o Acquire::PDiffs::Merge=0 -o APT::Get::List-Cleanup=0
218 testrun -o Acquire::PDiffs::Merge=1 -o APT::Get::List-Cleanup=0
221 echo '01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b -'
223 testrun -o Acquire::PDiffs::Merge=0 -o Acquire::ForceHash=SHA1
224 testrun -o Acquire::PDiffs::Merge=1 -o Acquire::ForceHash=SHA1
228 echo 'adc83b19e793491b1c6ea0fd8b46cd9f32e592fc -'
230 testrun -o Acquire::PDiffs::Merge=0 -o Acquire::ForceHash=SHA256
231 testrun -o Acquire::PDiffs::Merge=1 -o Acquire::ForceHash=SHA256