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