]> git.saurik.com Git - apt.git/blob - test/integration/test-pdiff-usage
only consider versioned kernel packages in autoremove
[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 '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
44 msgtest 'Check if the right pdiff merger was used'
45 if grep -q '^pkgAcqIndexMergeDiffs::Done(): rred' $OUTPUT; then
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
58 testrun() {
59 msgmsg "Testcase: setup the base with: $*"
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})
70 " aptcache show apt oldstuff
71
72 msgmsg "Testcase: apply with one patch: $*"
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)
81 SHA1-History:
82 9f4148e06d7faa37062994ff10d0c842d7017513 33053002 2010-08-18-2013.28
83 $(sha1sum $PKGFILE | cut -d' ' -f 1) $(stat -c%s $PKGFILE) $(basename $PATCHFILE)
84 SHA1-Patches:
85 7651fc0ac57cd83d41c63195a9342e2db5650257 19722 2010-08-18-0814.28
86 $(sha1sum $PATCHFILE | cut -d' ' -f 1) $(stat -c%s $PATCHFILE) $(basename $PATCHFILE)" > $PATCHINDEX
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
94
95 msgmsg "Testcase: index is already up-to-date: $*"
96 find rootdir/var/lib/apt/lists -name '*.IndexDiff' -type f -delete
97 testsuccess aptget update "$@"
98 testequal "$(cat ${PKGFILE}-new)
99 " aptcache show apt newstuff
100
101 msgmsg "Testcase: apply with two patches: $*"
102 cp ${PKGFILE}-new aptarchive/Packages
103 echo '
104 Package: futurestuff
105 Version: 1.0
106 Architecture: i386
107 Maintainer: Joe Sixpack <joe@example.org>
108 Installed-Size: 202
109 Filename: pool/futurestuff_1.0_i386.deb
110 Size: 202200
111 MD5sum: 311aeeaaae5ba33aff1ceaf3e1f76671
112 SHA1: 3c695e028f7a1ae324deeaae5ba332desa81088c
113 SHA256: b46fd154615edaae5ba33c56a5cc0e7deaef23e2da3e4f129727fd660f28f050
114 Description: some cool and shiny future stuff
115 This package will appear in the next next mirror update
116 Description-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)
123 SHA1-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})
127 SHA1-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
142 msgmsg "Testcase: patch applying fails, but successful fallback: $*"
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)
152 SHA1-History:
153 9f4148e06d7faa37062994ff10d0c842d7017513 33053002 2010-08-18-2013.28
154 $(sha1sum $PKGFILE | cut -d' ' -f 1) $(stat -c%s $PKGFILE) $(basename $PATCHFILE)
155 SHA1-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 }
167 echo 'Debug::pkgAcquire::Diffs "true";
168 Debug::pkgAcquire::rred "true";' > rootdir/etc/apt/apt.conf.d/rreddebug.conf
169
170 testrun -o Acquire::PDiffs::Merge=0 -o APT::Get::List-Cleanup=1
171 testrun -o Acquire::PDiffs::Merge=1 -o APT::Get::List-Cleanup=1
172 testrun -o Acquire::PDiffs::Merge=0 -o APT::Get::List-Cleanup=0
173 testrun -o Acquire::PDiffs::Merge=1 -o APT::Get::List-Cleanup=0