]> 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 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
39 testrun() {
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})
51 " aptcache show apt oldstuff
52
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)
62 SHA1-History:
63 9f4148e06d7faa37062994ff10d0c842d7017513 33053002 2010-08-18-2013.28
64 $(sha1sum $PKGFILE | cut -d' ' -f 1) $(stat -c%s $PKGFILE) $(basename $PATCHFILE)
65 SHA1-Patches:
66 7651fc0ac57cd83d41c63195a9342e2db5650257 19722 2010-08-18-0814.28
67 $(sha1sum $PATCHFILE | cut -d' ' -f 1) $(stat -c%s $PATCHFILE) $(basename $PATCHFILE)" > $PATCHINDEX
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
75
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)
80 " aptcache show apt newstuff
81
82 # apply with two patches
83 cp ${PKGFILE}-new aptarchive/Packages
84 echo '
85 Package: futurestuff
86 Version: 1.0
87 Architecture: i386
88 Maintainer: Joe Sixpack <joe@example.org>
89 Installed-Size: 202
90 Filename: pool/futurestuff_1.0_i386.deb
91 Size: 202200
92 MD5sum: 311aeeaaae5ba33aff1ceaf3e1f76671
93 SHA1: 3c695e028f7a1ae324deeaae5ba332desa81088c
94 SHA256: b46fd154615edaae5ba33c56a5cc0e7deaef23e2da3e4f129727fd660f28f050
95 Description: some cool and shiny future stuff
96 This package will appear in the next next mirror update
97 Description-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)
104 SHA1-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})
108 SHA1-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)
133 SHA1-History:
134 9f4148e06d7faa37062994ff10d0c842d7017513 33053002 2010-08-18-2013.28
135 $(sha1sum $PKGFILE | cut -d' ' -f 1) $(stat -c%s $PKGFILE) $(basename $PATCHFILE)
136 SHA1-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
149 testrun -o Debug::pkgAcquire::Diffs=1 -o Debug::pkgAcquire::rred=1 -o Acquire::PDiffs::Merge=0
150 testrun -o Debug::pkgAcquire::Diffs=1 -o Debug::pkgAcquire::rred=1 -o Acquire::PDiffs::Merge=1