]> git.saurik.com Git - apt.git/blame - test/integration/test-pdiff-usage
Merge remote-tracking branch 'mvo/feature/apt-ftparchive-srccache2' 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
34d6ece7
DK
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
37 msgpass
38 else
39 echo
40 echo "$EDS"
41 msgfail
42 fi
43
47d2bc78 44 msgtest 'Check if the right pdiff merger was used'
50bd6fd3 45 if grep -q '^pkgAcqIndexMergeDiffs::Done(): rred' $OUTPUT; then
47d2bc78
DK
46 if echo "$*" | grep -q -- '-o Acquire::PDiffs::Merge=1'; then
47 msgpass
48 else
49 msgfail "Merge shouldn't have been used, but was"
50 fi
51 elif echo "$*" | grep -q -- '-o Acquire::PDiffs::Merge=1'; then
52 msgfail "Merge should have been used, but wasn't"
53 else
54 msgpass
55 fi
56}
57
58testrun() {
34d6ece7 59 msgmsg "Testcase: setup the base with: $*"
47d2bc78
DK
60 find aptarchive -name 'Packages*' -type f -delete
61 cp ${PKGFILE} aptarchive/Packages
62 compressfile 'aptarchive/Packages'
63 generatereleasefiles
64 signreleasefiles
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})
f213b6ea
DK
70" aptcache show apt oldstuff
71
34d6ece7 72 msgmsg "Testcase: apply with one patch: $*"
47d2bc78
DK
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)
f213b6ea
DK
81SHA1-History:
82 9f4148e06d7faa37062994ff10d0c842d7017513 33053002 2010-08-18-2013.28
83 $(sha1sum $PKGFILE | cut -d' ' -f 1) $(stat -c%s $PKGFILE) $(basename $PATCHFILE)
84SHA1-Patches:
85 7651fc0ac57cd83d41c63195a9342e2db5650257 19722 2010-08-18-0814.28
86 $(sha1sum $PATCHFILE | cut -d' ' -f 1) $(stat -c%s $PATCHFILE) $(basename $PATCHFILE)" > $PATCHINDEX
47d2bc78
DK
87 generatereleasefiles '+1hour'
88 signreleasefiles
89 find aptarchive -name 'Packages*' -type f -delete
90 wasmergeused "$@"
91 testnopackage oldstuff
92 testequal "$(cat ${PKGFILE}-new)
93" aptcache show apt newstuff
f213b6ea 94
34d6ece7 95 msgmsg "Testcase: index is already up-to-date: $*"
47d2bc78
DK
96 find rootdir/var/lib/apt/lists -name '*.IndexDiff' -type f -delete
97 testsuccess aptget update "$@"
98 testequal "$(cat ${PKGFILE}-new)
f213b6ea 99" aptcache show apt newstuff
47d2bc78 100
34d6ece7 101 msgmsg "Testcase: apply with two patches: $*"
47d2bc78
DK
102 cp ${PKGFILE}-new aptarchive/Packages
103 echo '
104Package: futurestuff
105Version: 1.0
106Architecture: i386
107Maintainer: Joe Sixpack <joe@example.org>
108Installed-Size: 202
109Filename: pool/futurestuff_1.0_i386.deb
110Size: 202200
111MD5sum: 311aeeaaae5ba33aff1ceaf3e1f76671
112SHA1: 3c695e028f7a1ae324deeaae5ba332desa81088c
113SHA256: b46fd154615edaae5ba33c56a5cc0e7deaef23e2da3e4f129727fd660f28f050
114Description: some cool and shiny future stuff
115 This package will appear in the next next mirror update
116Description-md5: d5f89fbbc2ce34c455dfee9b67d82b6b' >> aptarchive/Packages
117
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)
123SHA1-History:
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})
127SHA1-Patches:
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'
132 signreleasefiles
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
137 wasmergeused "$@"
138 testnopackage oldstuff
139 testequal "$(cat Packages-future)
140" aptcache show apt newstuff futurestuff
141
34d6ece7 142 msgmsg "Testcase: patch applying fails, but successful fallback: $*"
47d2bc78
DK
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)
152SHA1-History:
153 9f4148e06d7faa37062994ff10d0c842d7017513 33053002 2010-08-18-2013.28
154 $(sha1sum $PKGFILE | cut -d' ' -f 1) $(stat -c%s $PKGFILE) $(basename $PATCHFILE)
155SHA1-Patches:
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'
161 signreleasefiles
162 testsuccess aptget update "$@"
163 testnopackage oldstuff
164 testequal "$(cat ${PKGFILE}-new)
165" aptcache show apt newstuff
166}
34d6ece7
DK
167echo 'Debug::pkgAcquire::Diffs "true";
168Debug::pkgAcquire::rred "true";' > rootdir/etc/apt/apt.conf.d/rreddebug.conf
47d2bc78 169
34d6ece7
DK
170testrun -o Acquire::PDiffs::Merge=0 -o APT::Get::List-Cleanup=1
171testrun -o Acquire::PDiffs::Merge=1 -o APT::Get::List-Cleanup=1
172testrun -o Acquire::PDiffs::Merge=0 -o APT::Get::List-Cleanup=0
173testrun -o Acquire::PDiffs::Merge=1 -o APT::Get::List-Cleanup=0