]> git.saurik.com Git - apt.git/blame - test/integration/test-pdiff-usage
Merge branch 'debian/experimental-no-abi-break' into debian/sid
[apt.git] / test / integration / test-pdiff-usage
CommitLineData
f213b6ea
DK
1#!/bin/sh
2set -e
3
9962ae93 4TESTDIR=$(readlink -f $(dirname $0))
f213b6ea
DK
5. $TESTDIR/framework
6
7setupenvironment
47d2bc78 8configarchitecture 'i386'
f213b6ea
DK
9
10buildaptarchive
11setupflataptarchive
12changetowebserver
f213b6ea 13
f213b6ea 14PKGFILE="${TESTDIR}/$(echo "$(basename $0)" | sed 's#^test-#Packages-#')"
47d2bc78
DK
15
16echo '#!/bin/sh
17touch merge-was-used
18/usr/bin/diffindex-rred "$@"' > extrred
19chmod +x extrred
20echo 'Dir::Bin::rred "./extrred";' > rootdir/etc/apt/apt.conf.d/99rred
21
22wasmergeused() {
50bd6fd3
DK
23 msgtest 'Test for successful execution of' "$*"
24 local OUTPUT=$(mktemp)
25 addtrap "rm $OUTPUT;"
26 if aptget update "$@" >${OUTPUT} 2>&1; then
27 msgpass
28 else
29 echo
30 cat $OUTPUT
31 msgfail
32 fi
33
47d2bc78 34 msgtest 'Check if the right pdiff merger was used'
50bd6fd3 35 if grep -q '^pkgAcqIndexMergeDiffs::Done(): rred' $OUTPUT; then
47d2bc78
DK
36 if echo "$*" | grep -q -- '-o Acquire::PDiffs::Merge=1'; then
37 msgpass
38 else
39 msgfail "Merge shouldn't have been used, but was"
40 fi
41 elif echo "$*" | grep -q -- '-o Acquire::PDiffs::Merge=1'; then
42 msgfail "Merge should have been used, but wasn't"
43 else
44 msgpass
45 fi
46}
47
48testrun() {
49 # setup the base
50 find aptarchive -name 'Packages*' -type f -delete
51 cp ${PKGFILE} aptarchive/Packages
52 compressfile 'aptarchive/Packages'
53 generatereleasefiles
54 signreleasefiles
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})
f213b6ea
DK
60" aptcache show apt oldstuff
61
50bd6fd3 62 msgmsg 'Testcase: apply with one patch'
47d2bc78
DK
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)
f213b6ea
DK
71SHA1-History:
72 9f4148e06d7faa37062994ff10d0c842d7017513 33053002 2010-08-18-2013.28
73 $(sha1sum $PKGFILE | cut -d' ' -f 1) $(stat -c%s $PKGFILE) $(basename $PATCHFILE)
74SHA1-Patches:
75 7651fc0ac57cd83d41c63195a9342e2db5650257 19722 2010-08-18-0814.28
76 $(sha1sum $PATCHFILE | cut -d' ' -f 1) $(stat -c%s $PATCHFILE) $(basename $PATCHFILE)" > $PATCHINDEX
47d2bc78
DK
77 generatereleasefiles '+1hour'
78 signreleasefiles
79 find aptarchive -name 'Packages*' -type f -delete
80 wasmergeused "$@"
81 testnopackage oldstuff
82 testequal "$(cat ${PKGFILE}-new)
83" aptcache show apt newstuff
f213b6ea 84
50bd6fd3 85 msgmsg 'Testcase: index is already up-to-date'
47d2bc78
DK
86 find rootdir/var/lib/apt/lists -name '*.IndexDiff' -type f -delete
87 testsuccess aptget update "$@"
88 testequal "$(cat ${PKGFILE}-new)
f213b6ea 89" aptcache show apt newstuff
47d2bc78 90
50bd6fd3 91 msgmsg 'Testcase: apply with two patches'
47d2bc78
DK
92 cp ${PKGFILE}-new aptarchive/Packages
93 echo '
94Package: futurestuff
95Version: 1.0
96Architecture: i386
97Maintainer: Joe Sixpack <joe@example.org>
98Installed-Size: 202
99Filename: pool/futurestuff_1.0_i386.deb
100Size: 202200
101MD5sum: 311aeeaaae5ba33aff1ceaf3e1f76671
102SHA1: 3c695e028f7a1ae324deeaae5ba332desa81088c
103SHA256: b46fd154615edaae5ba33c56a5cc0e7deaef23e2da3e4f129727fd660f28f050
104Description: some cool and shiny future stuff
105 This package will appear in the next next mirror update
106Description-md5: d5f89fbbc2ce34c455dfee9b67d82b6b' >> aptarchive/Packages
107
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)
113SHA1-History:
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})
117SHA1-Patches:
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'
122 signreleasefiles
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
127 wasmergeused "$@"
128 testnopackage oldstuff
129 testequal "$(cat Packages-future)
130" aptcache show apt newstuff futurestuff
131
50bd6fd3 132 msgmsg 'Testcase: patch applying fails, but successful fallback'
47d2bc78
DK
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)
142SHA1-History:
143 9f4148e06d7faa37062994ff10d0c842d7017513 33053002 2010-08-18-2013.28
144 $(sha1sum $PKGFILE | cut -d' ' -f 1) $(stat -c%s $PKGFILE) $(basename $PATCHFILE)
145SHA1-Patches:
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'
151 signreleasefiles
152 testsuccess aptget update "$@"
153 testnopackage oldstuff
154 testequal "$(cat ${PKGFILE}-new)
155" aptcache show apt newstuff
156}
157
158testrun -o Debug::pkgAcquire::Diffs=1 -o Debug::pkgAcquire::rred=1 -o Acquire::PDiffs::Merge=0
159testrun -o Debug::pkgAcquire::Diffs=1 -o Debug::pkgAcquire::rred=1 -o Acquire::PDiffs::Merge=1