4 TESTDIR
=$(readlink -f $(dirname $0))
8 configarchitecture
'i386'
14 PKGFILE
="${TESTDIR}/$(echo "$(basename $0)" | sed 's#^test-#Packages-#')"
18 /usr/bin/diffindex-rred "$@
"' > extrred
20 echo 'Dir::Bin::rred ".
/extrred
";' > rootdir/etc/apt/apt.conf.d/99rred
23 msgtest 'Test for successful execution of' "$
*"
24 local OUTPUT=$(mktemp)
26 if aptget update "$@
" >${OUTPUT} 2>&1; then
34 msgtest 'No intermediate patch files' 'still exist'
35 local EDS="$(find rootdir/var/lib/apt/lists -name '*.ed' -o -name '*.ed.*')"
36 if [ -z "$EDS" ]; then
44 msgtest 'Check if the right pdiff merger was used'
45 if grep -q '^pkgAcqIndexMergeDiffs::Done(): rred' $OUTPUT; then
46 if echo "$
*" | grep -q -- '-o Acquire::PDiffs::Merge=1'; then
49 msgfail "Merge shouldn
't have been used, but was"
51 elif echo "$*" | grep -q -- '-o Acquire
::PDiffs
::Merge
=1'; then
52 msgfail "Merge should have been used, but wasn't
"
59 msgmsg "Testcase
: setup the base with
: $
*"
60 find aptarchive -name 'Packages*' -type f -delete
61 cp ${PKGFILE} aptarchive/Packages
62 compressfile 'aptarchive/Packages'
65 rm -rf aptarchive/Packages.diff rootdir/var/lib/apt/lists
66 testsuccess aptget update "$@
"
67 cp -a rootdir/var/lib/apt/lists rootdir/var/lib/apt/lists-bak
68 testnopackage newstuff
69 testequal "$(cat ${PKGFILE})
70 " aptcache show apt oldstuff
72 msgmsg "Testcase
: apply with one
patch: $
*"
73 cp ${PKGFILE}-new aptarchive/Packages
74 compressfile 'aptarchive/Packages'
75 mkdir -p aptarchive/Packages.diff
76 PATCHFILE="aptarchive
/Packages.diff
/$(date +%Y-%m-%d-%H%M.%S)"
77 diff -e ${PKGFILE} ${PKGFILE}-new > ${PATCHFILE} || true
78 cat $PATCHFILE | gzip > ${PATCHFILE}.gz
79 PATCHINDEX='aptarchive/Packages.diff/Index'
80 echo "SHA1
-Current: $(sha1sum ${PKGFILE}-new | cut -d' ' -f 1) $(stat -c%s ${PKGFILE}-new)
82 9f4148e06d7faa37062994ff10d0c842d7017513
33053002 2010-08-18-2013.28
83 $(sha1sum $PKGFILE | cut -d' ' -f 1) $(stat -c%s $PKGFILE) $(basename $PATCHFILE)
85 7651fc0ac57cd83d41c63195a9342e2db5650257
19722 2010-08-18-0814.28
86 $(sha1sum $PATCHFILE | cut -d' ' -f 1) $(stat -c%s $PATCHFILE) $(basename $PATCHFILE)" > $PATCHINDEX
87 generatereleasefiles '+1hour'
89 find aptarchive -name 'Packages*' -type f -delete
91 testnopackage oldstuff
92 testequal "$(cat ${PKGFILE}-new)
93 " aptcache show apt newstuff
95 msgmsg "Testcase
: index is already up
-to-date: $
*"
96 find rootdir/var/lib/apt/lists -name '*.IndexDiff' -type f -delete
97 testsuccess aptget update "$@
"
98 testequal "$(cat ${PKGFILE}-new)
99 " aptcache show apt newstuff
101 msgmsg "Testcase
: apply with two patches
: $
*"
102 cp ${PKGFILE}-new aptarchive/Packages
107 Maintainer: Joe Sixpack <joe@example.org>
109 Filename: pool/futurestuff_1.0_i386.deb
111 MD5sum: 311aeeaaae5ba33aff1ceaf3e1f76671
112 SHA1: 3c695e028f7a1ae324deeaae5ba332desa81088c
113 SHA256: b46fd154615edaae5ba33c56a5cc0e7deaef23e2da3e4f129727fd660f28f050
114 Description: some cool and shiny future stuff
115 This package will appear in the next next mirror update
116 Description-md5: d5f89fbbc2ce34c455dfee9b67d82b6b' >> aptarchive/Packages
118 compressfile 'aptarchive/Packages'
119 PATCHFILE2="aptarchive
/Packages.diff
/$(date -d 'now + 1hour' '+%Y-%m-%d-%H%M.%S')"
120 diff -e ${PKGFILE}-new aptarchive/Packages > ${PATCHFILE2} || true
121 cat $PATCHFILE2 | gzip > ${PATCHFILE2}.gz
122 echo "SHA1
-Current: $(sha1sum aptarchive/Packages | cut -d' ' -f 1) $(stat -c%s aptarchive/Packages)
124 9f4148e06d7faa37062994ff10d0c842d7017513
33053002 2010-08-18-2013.28
125 $(sha1sum ${PKGFILE} | cut -d' ' -f 1) $(stat -c%s ${PKGFILE}) $(basename ${PATCHFILE})
126 $(sha1sum ${PKGFILE}-new | cut -d' ' -f 1) $(stat -c%s ${PKGFILE}-new) $(basename ${PATCHFILE2})
128 7651fc0ac57cd83d41c63195a9342e2db5650257
19722 2010-08-18-0814.28
129 $(sha1sum $PATCHFILE | cut -d' ' -f 1) $(stat -c%s $PATCHFILE) $(basename $PATCHFILE)
130 $(sha1sum ${PATCHFILE2} | cut -d' ' -f 1) $(stat -c%s ${PATCHFILE2}) $(basename ${PATCHFILE2})" > $PATCHINDEX
131 generatereleasefiles '+2hour'
133 cp -a aptarchive/Packages Packages-future
134 find aptarchive -name 'Packages*' -type f -delete
135 rm -rf rootdir/var/lib/apt/lists
136 cp -a rootdir/var/lib/apt/lists-bak rootdir/var/lib/apt/lists
138 testnopackage oldstuff
139 testequal "$(cat Packages-future)
140 " aptcache show apt newstuff futurestuff
142 msgmsg "Testcase
: patch applying fails
, but successful fallback
: $
*"
143 rm -rf rootdir/var/lib/apt/lists
144 cp -a rootdir/var/lib/apt/lists-bak rootdir/var/lib/apt/lists
145 cp ${PKGFILE}-new aptarchive/Packages
146 compressfile 'aptarchive/Packages'
147 mkdir -p aptarchive/Packages.diff
148 PATCHFILE="aptarchive
/Packages.diff
/$(date +%Y-%m-%d-%H%M.%S)"
149 diff -e ${PKGFILE} ${PKGFILE}-new > ${PATCHFILE} || true
150 PATCHINDEX='aptarchive/Packages.diff/Index'
151 echo "SHA1
-Current: $(sha1sum ${PKGFILE}-new | cut -d' ' -f 1) $(stat -c%s ${PKGFILE}-new)
153 9f4148e06d7faa37062994ff10d0c842d7017513
33053002 2010-08-18-2013.28
154 $(sha1sum $PKGFILE | cut -d' ' -f 1) $(stat -c%s $PKGFILE) $(basename $PATCHFILE)
156 7651fc0ac57cd83d41c63195a9342e2db5650257
19722 2010-08-18-0814.28
157 $(sha1sum $PATCHFILE | cut -d' ' -f 1) $(stat -c%s $PATCHFILE) $(basename $PATCHFILE)" > $PATCHINDEX
158 echo 'I am Mallory and I change files' >> $PATCHFILE
159 cat $PATCHFILE | gzip > ${PATCHFILE}.gz
160 generatereleasefiles '+1hour'
162 testsuccess aptget update "$@
"
163 testnopackage oldstuff
164 testequal "$(cat ${PKGFILE}-new)
165 " aptcache show apt newstuff
167 echo 'Debug::pkgAcquire::Diffs "true
";
168 Debug::pkgAcquire::rred "true
";' > rootdir/etc/apt/apt.conf.d/rreddebug.conf
170 testrun -o Acquire::PDiffs::Merge=0 -o APT::Get::List-Cleanup=1
171 testrun -o Acquire::PDiffs::Merge=1 -o APT::Get::List-Cleanup=1
172 testrun -o Acquire::PDiffs::Merge=0 -o APT::Get::List-Cleanup=0
173 testrun -o Acquire::PDiffs::Merge=1 -o APT::Get::List-Cleanup=0