]> git.saurik.com Git - apt.git/blame - test/integration/test-pdiff-usage
reimplement rred to allow applying all the diffs in a single pass
[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() {
23 testsuccess aptget update "$@"
24 msgtest 'Check if the right pdiff merger was used'
25 if [ -e ./merge-was-used ]; then
26 rm -f ./merge-was-used
27 if echo "$*" | grep -q -- '-o Acquire::PDiffs::Merge=1'; then
28 msgpass
29 else
30 msgfail "Merge shouldn't have been used, but was"
31 fi
32 elif echo "$*" | grep -q -- '-o Acquire::PDiffs::Merge=1'; then
33 msgfail "Merge should have been used, but wasn't"
34 else
35 msgpass
36 fi
37}
38
39testrun() {
40 # setup the base
41 find aptarchive -name 'Packages*' -type f -delete
42 cp ${PKGFILE} aptarchive/Packages
43 compressfile 'aptarchive/Packages'
44 generatereleasefiles
45 signreleasefiles
46 rm -rf aptarchive/Packages.diff rootdir/var/lib/apt/lists
47 testsuccess aptget update "$@"
48 cp -a rootdir/var/lib/apt/lists rootdir/var/lib/apt/lists-bak
49 testnopackage newstuff
50 testequal "$(cat ${PKGFILE})
f213b6ea
DK
51" aptcache show apt oldstuff
52
47d2bc78
DK
53 # apply with one patch
54 cp ${PKGFILE}-new aptarchive/Packages
55 compressfile 'aptarchive/Packages'
56 mkdir -p aptarchive/Packages.diff
57 PATCHFILE="aptarchive/Packages.diff/$(date +%Y-%m-%d-%H%M.%S)"
58 diff -e ${PKGFILE} ${PKGFILE}-new > ${PATCHFILE} || true
59 cat $PATCHFILE | gzip > ${PATCHFILE}.gz
60 PATCHINDEX='aptarchive/Packages.diff/Index'
61 echo "SHA1-Current: $(sha1sum ${PKGFILE}-new | cut -d' ' -f 1) $(stat -c%s ${PKGFILE}-new)
f213b6ea
DK
62SHA1-History:
63 9f4148e06d7faa37062994ff10d0c842d7017513 33053002 2010-08-18-2013.28
64 $(sha1sum $PKGFILE | cut -d' ' -f 1) $(stat -c%s $PKGFILE) $(basename $PATCHFILE)
65SHA1-Patches:
66 7651fc0ac57cd83d41c63195a9342e2db5650257 19722 2010-08-18-0814.28
67 $(sha1sum $PATCHFILE | cut -d' ' -f 1) $(stat -c%s $PATCHFILE) $(basename $PATCHFILE)" > $PATCHINDEX
47d2bc78
DK
68 generatereleasefiles '+1hour'
69 signreleasefiles
70 find aptarchive -name 'Packages*' -type f -delete
71 wasmergeused "$@"
72 testnopackage oldstuff
73 testequal "$(cat ${PKGFILE}-new)
74" aptcache show apt newstuff
f213b6ea 75
47d2bc78
DK
76 # index is already up-to-date
77 find rootdir/var/lib/apt/lists -name '*.IndexDiff' -type f -delete
78 testsuccess aptget update "$@"
79 testequal "$(cat ${PKGFILE}-new)
f213b6ea 80" aptcache show apt newstuff
47d2bc78
DK
81
82 # apply with two patches
83 cp ${PKGFILE}-new aptarchive/Packages
84 echo '
85Package: futurestuff
86Version: 1.0
87Architecture: i386
88Maintainer: Joe Sixpack <joe@example.org>
89Installed-Size: 202
90Filename: pool/futurestuff_1.0_i386.deb
91Size: 202200
92MD5sum: 311aeeaaae5ba33aff1ceaf3e1f76671
93SHA1: 3c695e028f7a1ae324deeaae5ba332desa81088c
94SHA256: b46fd154615edaae5ba33c56a5cc0e7deaef23e2da3e4f129727fd660f28f050
95Description: some cool and shiny future stuff
96 This package will appear in the next next mirror update
97Description-md5: d5f89fbbc2ce34c455dfee9b67d82b6b' >> aptarchive/Packages
98
99 compressfile 'aptarchive/Packages'
100 PATCHFILE2="aptarchive/Packages.diff/$(date -d 'now + 1hour' '+%Y-%m-%d-%H%M.%S')"
101 diff -e ${PKGFILE}-new aptarchive/Packages > ${PATCHFILE2} || true
102 cat $PATCHFILE2 | gzip > ${PATCHFILE2}.gz
103 echo "SHA1-Current: $(sha1sum aptarchive/Packages | cut -d' ' -f 1) $(stat -c%s aptarchive/Packages)
104SHA1-History:
105 9f4148e06d7faa37062994ff10d0c842d7017513 33053002 2010-08-18-2013.28
106 $(sha1sum ${PKGFILE} | cut -d' ' -f 1) $(stat -c%s ${PKGFILE}) $(basename ${PATCHFILE})
107 $(sha1sum ${PKGFILE}-new | cut -d' ' -f 1) $(stat -c%s ${PKGFILE}-new) $(basename ${PATCHFILE2})
108SHA1-Patches:
109 7651fc0ac57cd83d41c63195a9342e2db5650257 19722 2010-08-18-0814.28
110 $(sha1sum $PATCHFILE | cut -d' ' -f 1) $(stat -c%s $PATCHFILE) $(basename $PATCHFILE)
111 $(sha1sum ${PATCHFILE2} | cut -d' ' -f 1) $(stat -c%s ${PATCHFILE2}) $(basename ${PATCHFILE2})" > $PATCHINDEX
112 generatereleasefiles '+2hour'
113 signreleasefiles
114 cp -a aptarchive/Packages Packages-future
115 find aptarchive -name 'Packages*' -type f -delete
116 rm -rf rootdir/var/lib/apt/lists
117 cp -a rootdir/var/lib/apt/lists-bak rootdir/var/lib/apt/lists
118 wasmergeused "$@"
119 testnopackage oldstuff
120 testequal "$(cat Packages-future)
121" aptcache show apt newstuff futurestuff
122
123 # patch applying fails, but successful fallback
124 rm -rf rootdir/var/lib/apt/lists
125 cp -a rootdir/var/lib/apt/lists-bak rootdir/var/lib/apt/lists
126 cp ${PKGFILE}-new aptarchive/Packages
127 compressfile 'aptarchive/Packages'
128 mkdir -p aptarchive/Packages.diff
129 PATCHFILE="aptarchive/Packages.diff/$(date +%Y-%m-%d-%H%M.%S)"
130 diff -e ${PKGFILE} ${PKGFILE}-new > ${PATCHFILE} || true
131 PATCHINDEX='aptarchive/Packages.diff/Index'
132 echo "SHA1-Current: $(sha1sum ${PKGFILE}-new | cut -d' ' -f 1) $(stat -c%s ${PKGFILE}-new)
133SHA1-History:
134 9f4148e06d7faa37062994ff10d0c842d7017513 33053002 2010-08-18-2013.28
135 $(sha1sum $PKGFILE | cut -d' ' -f 1) $(stat -c%s $PKGFILE) $(basename $PATCHFILE)
136SHA1-Patches:
137 7651fc0ac57cd83d41c63195a9342e2db5650257 19722 2010-08-18-0814.28
138 $(sha1sum $PATCHFILE | cut -d' ' -f 1) $(stat -c%s $PATCHFILE) $(basename $PATCHFILE)" > $PATCHINDEX
139 echo 'I am Mallory and I change files' >> $PATCHFILE
140 cat $PATCHFILE | gzip > ${PATCHFILE}.gz
141 generatereleasefiles '+1hour'
142 signreleasefiles
143 testsuccess aptget update "$@"
144 testnopackage oldstuff
145 testequal "$(cat ${PKGFILE}-new)
146" aptcache show apt newstuff
147}
148
149testrun -o Debug::pkgAcquire::Diffs=1 -o Debug::pkgAcquire::rred=1 -o Acquire::PDiffs::Merge=0
150testrun -o Debug::pkgAcquire::Diffs=1 -o Debug::pkgAcquire::rred=1 -o Acquire::PDiffs::Merge=1