]> git.saurik.com Git - apt.git/blob - test/integration/test-pdiff-usage
Merge branch 'debian/sid' 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 wasmergeused() {
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
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
38 msgtest 'Check if the right pdiff merger was used'
39 if grep -q '^pkgAcqIndexMergeDiffs::Done(): rred' $OUTPUT; then
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
52 testrun() {
53 msgmsg "Testcase: setup the base with: $*"
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})
64 " aptcache show apt oldstuff
65
66 msgmsg "Testcase: apply with one patch: $*"
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)
75 SHA1-History:
76 9f4148e06d7faa37062994ff10d0c842d7017513 33053002 2010-08-18-2013.28
77 $(sha1sum $PKGFILE | cut -d' ' -f 1) $(stat -c%s $PKGFILE) $(basename $PATCHFILE)
78 SHA1-Patches:
79 7651fc0ac57cd83d41c63195a9342e2db5650257 19722 2010-08-18-0814.28
80 $(sha1sum $PATCHFILE | cut -d' ' -f 1) $(stat -c%s $PATCHFILE) $(basename $PATCHFILE)" > $PATCHINDEX
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
88
89 msgmsg "Testcase: index is already up-to-date: $*"
90 find rootdir/var/lib/apt/lists -name '*.IndexDiff' -type f -delete
91 testsuccess aptget update "$@"
92 testequal "$(cat ${PKGFILE}-new)
93 " aptcache show apt newstuff
94
95 msgmsg "Testcase: apply with two patches: $*"
96 cp ${PKGFILE}-new aptarchive/Packages
97 echo '
98 Package: futurestuff
99 Version: 1.0
100 Architecture: i386
101 Maintainer: Joe Sixpack <joe@example.org>
102 Installed-Size: 202
103 Filename: pool/futurestuff_1.0_i386.deb
104 Size: 202200
105 MD5sum: 311aeeaaae5ba33aff1ceaf3e1f76671
106 SHA1: 3c695e028f7a1ae324deeaae5ba332desa81088c
107 SHA256: b46fd154615edaae5ba33c56a5cc0e7deaef23e2da3e4f129727fd660f28f050
108 Description: some cool and shiny future stuff
109 This package will appear in the next next mirror update
110 Description-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)
117 SHA1-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})
121 SHA1-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
136 msgmsg "Testcase: patch applying fails, but successful fallback: $*"
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)
146 SHA1-History:
147 9f4148e06d7faa37062994ff10d0c842d7017513 33053002 2010-08-18-2013.28
148 $(sha1sum $PKGFILE | cut -d' ' -f 1) $(stat -c%s $PKGFILE) $(basename $PATCHFILE)
149 SHA1-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 }
161 echo 'Debug::pkgAcquire::Diffs "true";
162 Debug::pkgAcquire::rred "true";' > rootdir/etc/apt/apt.conf.d/rreddebug.conf
163
164 testrun -o Acquire::PDiffs::Merge=0 -o APT::Get::List-Cleanup=1
165 testrun -o Acquire::PDiffs::Merge=1 -o APT::Get::List-Cleanup=1
166 testrun -o Acquire::PDiffs::Merge=0 -o APT::Get::List-Cleanup=0
167 testrun -o Acquire::PDiffs::Merge=1 -o APT::Get::List-Cleanup=0