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 'Check if the right pdiff merger was used'
35 if grep -q '^pkgAcqIndexMergeDiffs::Done(): rred' $OUTPUT; then
36 if echo "$
*" | grep -q -- '-o Acquire::PDiffs::Merge=1'; then
39 msgfail "Merge shouldn
't have been used, but was"
41 elif echo "$*" | grep -q -- '-o Acquire
::PDiffs
::Merge
=1'; then
42 msgfail "Merge should have been used, but wasn't
"
50 find aptarchive -name 'Packages*' -type f -delete
51 cp ${PKGFILE} aptarchive/Packages
52 compressfile 'aptarchive/Packages'
55 rm -rf aptarchive/Packages.diff rootdir/var/lib/apt/lists
56 testsuccess aptget update "$@
"
57 cp -a rootdir/var/lib/apt/lists rootdir/var/lib/apt/lists-bak
58 testnopackage newstuff
59 testequal "$(cat ${PKGFILE})
60 " aptcache show apt oldstuff
62 msgmsg 'Testcase: apply with one patch'
63 cp ${PKGFILE}-new aptarchive/Packages
64 compressfile 'aptarchive/Packages'
65 mkdir -p aptarchive/Packages.diff
66 PATCHFILE="aptarchive
/Packages.diff
/$(date +%Y-%m-%d-%H%M.%S)"
67 diff -e ${PKGFILE} ${PKGFILE}-new > ${PATCHFILE} || true
68 cat $PATCHFILE | gzip > ${PATCHFILE}.gz
69 PATCHINDEX='aptarchive/Packages.diff/Index'
70 echo "SHA1
-Current: $(sha1sum ${PKGFILE}-new | cut -d' ' -f 1) $(stat -c%s ${PKGFILE}-new)
72 9f4148e06d7faa37062994ff10d0c842d7017513
33053002 2010-08-18-2013.28
73 $(sha1sum $PKGFILE | cut -d' ' -f 1) $(stat -c%s $PKGFILE) $(basename $PATCHFILE)
75 7651fc0ac57cd83d41c63195a9342e2db5650257
19722 2010-08-18-0814.28
76 $(sha1sum $PATCHFILE | cut -d' ' -f 1) $(stat -c%s $PATCHFILE) $(basename $PATCHFILE)" > $PATCHINDEX
77 generatereleasefiles '+1hour'
79 find aptarchive -name 'Packages*' -type f -delete
81 testnopackage oldstuff
82 testequal "$(cat ${PKGFILE}-new)
83 " aptcache show apt newstuff
85 msgmsg 'Testcase: index is already up-to-date'
86 find rootdir/var/lib/apt/lists -name '*.IndexDiff' -type f -delete
87 testsuccess aptget update "$@
"
88 testequal "$(cat ${PKGFILE}-new)
89 " aptcache show apt newstuff
91 msgmsg 'Testcase: apply with two patches'
92 cp ${PKGFILE}-new aptarchive/Packages
97 Maintainer: Joe Sixpack <joe@example.org>
99 Filename: pool/futurestuff_1.0_i386.deb
101 MD5sum: 311aeeaaae5ba33aff1ceaf3e1f76671
102 SHA1: 3c695e028f7a1ae324deeaae5ba332desa81088c
103 SHA256: b46fd154615edaae5ba33c56a5cc0e7deaef23e2da3e4f129727fd660f28f050
104 Description: some cool and shiny future stuff
105 This package will appear in the next next mirror update
106 Description-md5: d5f89fbbc2ce34c455dfee9b67d82b6b' >> aptarchive/Packages
108 compressfile 'aptarchive/Packages'
109 PATCHFILE2="aptarchive
/Packages.diff
/$(date -d 'now + 1hour' '+%Y-%m-%d-%H%M.%S')"
110 diff -e ${PKGFILE}-new aptarchive/Packages > ${PATCHFILE2} || true
111 cat $PATCHFILE2 | gzip > ${PATCHFILE2}.gz
112 echo "SHA1
-Current: $(sha1sum aptarchive/Packages | cut -d' ' -f 1) $(stat -c%s aptarchive/Packages)
114 9f4148e06d7faa37062994ff10d0c842d7017513
33053002 2010-08-18-2013.28
115 $(sha1sum ${PKGFILE} | cut -d' ' -f 1) $(stat -c%s ${PKGFILE}) $(basename ${PATCHFILE})
116 $(sha1sum ${PKGFILE}-new | cut -d' ' -f 1) $(stat -c%s ${PKGFILE}-new) $(basename ${PATCHFILE2})
118 7651fc0ac57cd83d41c63195a9342e2db5650257
19722 2010-08-18-0814.28
119 $(sha1sum $PATCHFILE | cut -d' ' -f 1) $(stat -c%s $PATCHFILE) $(basename $PATCHFILE)
120 $(sha1sum ${PATCHFILE2} | cut -d' ' -f 1) $(stat -c%s ${PATCHFILE2}) $(basename ${PATCHFILE2})" > $PATCHINDEX
121 generatereleasefiles '+2hour'
123 cp -a aptarchive/Packages Packages-future
124 find aptarchive -name 'Packages*' -type f -delete
125 rm -rf rootdir/var/lib/apt/lists
126 cp -a rootdir/var/lib/apt/lists-bak rootdir/var/lib/apt/lists
128 testnopackage oldstuff
129 testequal "$(cat Packages-future)
130 " aptcache show apt newstuff futurestuff
132 msgmsg 'Testcase: patch applying fails, but successful fallback'
133 rm -rf rootdir/var/lib/apt/lists
134 cp -a rootdir/var/lib/apt/lists-bak rootdir/var/lib/apt/lists
135 cp ${PKGFILE}-new aptarchive/Packages
136 compressfile 'aptarchive/Packages'
137 mkdir -p aptarchive/Packages.diff
138 PATCHFILE="aptarchive
/Packages.diff
/$(date +%Y-%m-%d-%H%M.%S)"
139 diff -e ${PKGFILE} ${PKGFILE}-new > ${PATCHFILE} || true
140 PATCHINDEX='aptarchive/Packages.diff/Index'
141 echo "SHA1
-Current: $(sha1sum ${PKGFILE}-new | cut -d' ' -f 1) $(stat -c%s ${PKGFILE}-new)
143 9f4148e06d7faa37062994ff10d0c842d7017513
33053002 2010-08-18-2013.28
144 $(sha1sum $PKGFILE | cut -d' ' -f 1) $(stat -c%s $PKGFILE) $(basename $PATCHFILE)
146 7651fc0ac57cd83d41c63195a9342e2db5650257
19722 2010-08-18-0814.28
147 $(sha1sum $PATCHFILE | cut -d' ' -f 1) $(stat -c%s $PATCHFILE) $(basename $PATCHFILE)" > $PATCHINDEX
148 echo 'I am Mallory and I change files' >> $PATCHFILE
149 cat $PATCHFILE | gzip > ${PATCHFILE}.gz
150 generatereleasefiles '+1hour'
152 testsuccess aptget update "$@
"
153 testnopackage oldstuff
154 testequal "$(cat ${PKGFILE}-new)
155 " aptcache show apt newstuff
158 testrun -o Debug::pkgAcquire::Diffs=1 -o Debug::pkgAcquire::rred=1 -o Acquire::PDiffs::Merge=0
159 testrun -o Debug::pkgAcquire::Diffs=1 -o Debug::pkgAcquire::rred=1 -o Acquire::PDiffs::Merge=1