]> git.saurik.com Git - apt.git/blob - test/integration/test-pdiff-usage
Merge remote-tracking branch 'mvo/feature/source-deb822' into debian/experimental...
[apt.git] / test / integration / test-pdiff-usage
1 #!/bin/sh
2 set -e
3
4 TESTDIR=$(readlink -f $(dirname $0))
5 . $TESTDIR/framework
6
7 setupenvironment
8 configarchitecture 'i386'
9
10 buildaptarchive
11 setupflataptarchive
12 changetowebserver
13
14 PKGFILE="${TESTDIR}/$(echo "$(basename $0)" | sed 's#^test-#Packages-#')"
15
16 echo '#!/bin/sh
17 touch merge-was-used
18 /usr/bin/diffindex-rred "$@"' > extrred
19 chmod +x extrred
20 echo 'Dir::Bin::rred "./extrred";' > rootdir/etc/apt/apt.conf.d/99rred
21
22 wasmergeused() {
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
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
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
48 testrun() {
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})
60 " aptcache show apt oldstuff
61
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)
71 SHA1-History:
72 9f4148e06d7faa37062994ff10d0c842d7017513 33053002 2010-08-18-2013.28
73 $(sha1sum $PKGFILE | cut -d' ' -f 1) $(stat -c%s $PKGFILE) $(basename $PATCHFILE)
74 SHA1-Patches:
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'
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
84
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
90
91 msgmsg 'Testcase: apply with two patches'
92 cp ${PKGFILE}-new aptarchive/Packages
93 echo '
94 Package: futurestuff
95 Version: 1.0
96 Architecture: i386
97 Maintainer: Joe Sixpack <joe@example.org>
98 Installed-Size: 202
99 Filename: pool/futurestuff_1.0_i386.deb
100 Size: 202200
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
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)
113 SHA1-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})
117 SHA1-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
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)
142 SHA1-History:
143 9f4148e06d7faa37062994ff10d0c842d7017513 33053002 2010-08-18-2013.28
144 $(sha1sum $PKGFILE | cut -d' ' -f 1) $(stat -c%s $PKGFILE) $(basename $PATCHFILE)
145 SHA1-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
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