]> git.saurik.com Git - apt.git/blame - test/integration/test-compressed-indexes
fix testcase expecting incorrect remove log from dpkg
[apt.git] / test / integration / test-compressed-indexes
CommitLineData
f213b6ea
DK
1#!/bin/sh
2set -e
3
3abb6a6a
DK
4TESTDIR="$(readlink -f "$(dirname "$0")")"
5. "$TESTDIR/framework"
f213b6ea
DK
6
7setupenvironment
bdc42211 8configcompression 'ALL'
5f982b9d 9configarchitecture 'i386'
0179cfa8 10LOWCOSTEXT='lz4'
5f982b9d
DK
11
12buildsimplenativepackage 'testpkg' 'i386' '1.0'
13
14buildaptarchive
15setupdistsaptarchive
16# fake a pdiff setup as apt wouldn't try pdiffs otherwise
17find aptarchive -name 'Packages' -o -name 'Sources' | while read file; do
18 mkdir "${file}.diff"
19 PATCHINDEX="${file}.diff/Index"
20 echo 'SHA1-Current: adc83b19e793491b1c6ea0fd8b46cd9f32e592fc 0
21SHA1-History:
22 adc83b19e793491b1c6ea0fd8b46cd9f32e592fc 33053002 2010-08-18-2013.28
23 ecfd1b19e793491b1c6ea123eabdcd9f32e592fc 33053001 2010-08-18-2013.29
24SHA1-Patches:
25 abc1fc0ac57cd83d41c63195a9342e2db5650257 19722 2010-08-18-0814.28
26 dfe3444ac57cd83d41c63195a9342e2db5650257 19722 2010-08-18-0814.29' > $PATCHINDEX
27done
28generatereleasefiles
29signreleasefiles
f213b6ea
DK
30
31testrun() {
32 local F
5f982b9d
DK
33 msgtest 'Check if all index files are' "${1:-uncompressed}"
34 if [ "$1" = 'compressed' ]; then
1dd20368 35 ! test -e rootdir/var/lib/apt/lists/*i386_Packages || F=1
5f982b9d
DK
36 ! test -e rootdir/var/lib/apt/lists/*_Sources || F=1
37 ! test -e rootdir/var/lib/apt/lists/*_Translation-en || F=1
0179cfa8 38 test -e rootdir/var/lib/apt/lists/*i386_Packages.$LOWCOSTEXT || F=1
0179cfa8
DK
39 test -e rootdir/var/lib/apt/lists/*_Sources.$LOWCOSTEXT || F=1
40 test -e rootdir/var/lib/apt/lists/*_Translation-en.$LOWCOSTEXT || F=1
5f982b9d
DK
41 # there is no point in trying pdiff if we have compressed indexes
42 # as we can't patch compressed files (well, we can, but what is the point?)
4d0818cc 43 ! test -e rootdir/var/lib/apt/lists/*diff_Index || F=1
5f982b9d
DK
44 else
45 # clear the faked pdiff indexes so the glob below works
4d0818cc 46 rm -f rootdir/var/lib/apt/lists/*diff_Index
1dd20368 47 test -e rootdir/var/lib/apt/lists/*i386_Packages || F=1
5f982b9d
DK
48 test -e rootdir/var/lib/apt/lists/*_Sources || F=1
49 test -e rootdir/var/lib/apt/lists/*_Translation-en || F=1
1dd20368 50 ! test -e rootdir/var/lib/apt/lists/*i386_Packages.* || F=1
5f982b9d
DK
51 ! test -e rootdir/var/lib/apt/lists/*_Sources.* || F=1
52 ! test -e rootdir/var/lib/apt/lists/*_Translation-en.* || F=1
f213b6ea 53 fi
5f982b9d 54 if [ -n "$F" ]; then
78bc8d6b 55 cat rootdir/tmp/testsuccess.output
5f982b9d
DK
56 ls -laR rootdir/var/lib/apt/lists/
57 msgfail
58 else
59 msgpass
60 fi
61 msgtest 'Check if package is downloadable'
03aa0847 62 cd downloaded
5f982b9d 63 testsuccess --nomsg aptget download testpkg
653ef26c 64 msgtest 'deb file is present'; testsuccess --nomsg test -f testpkg_1.0_i386.deb
a09f6eb8 65 rm -f testpkg_1.0_i386.deb
03aa0847 66 cd - >/dev/null
25b86db1 67 testsuccessequal 'Reading package lists...
5f982b9d
DK
68Building dependency tree...
69The following NEW packages will be installed:
70 testpkg
710 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
72Inst testpkg (1.0 unstable [i386])
eb1f04dd 73Conf testpkg (1.0 unstable [i386])' aptget install testpkg -s -o Debug::pkgAcquire::Auth=0 -o Debug::pkgAcquire::Worker=0
8de79b68 74 rm -f rootdir/var/cache/apt/pkgcache.bin rootdir/var/cache/apt/srcpkgcache.bin
25b86db1
DK
75 testsuccessequal "$GOODSHOW" aptcache show testpkg
76 testsuccessequal "$GOODSHOW" aptcache show testpkg
8de79b68 77 rm -f rootdir/var/cache/apt/pkgcache.bin rootdir/var/cache/apt/srcpkgcache.bin
25b86db1
DK
78 testsuccessequal "$GOODPOLICY" aptcache policy testpkg
79 testsuccessequal "$GOODPOLICY" aptcache policy testpkg
8de79b68 80 rm -f rootdir/var/cache/apt/pkgcache.bin rootdir/var/cache/apt/srcpkgcache.bin
25b86db1
DK
81 testsuccessequal "$GOODSHOWSRC" aptcache showsrc testpkg
82 testsuccessequal "$GOODSHOWSRC" aptcache showsrc testpkg
8de79b68 83 aptget clean
5f982b9d 84 msgtest 'Check if the source is aptgetable'
03aa0847 85 cd downloaded
0440d936 86 testsuccess --nomsg aptget source testpkg
03aa0847
DK
87 testsuccess test -s testpkg_1.0.dsc
88 testsuccess test -d testpkg-1.0
5f982b9d 89 rm -rf testpkg-1.0*
03aa0847 90 cd - >/dev/null
25b86db1 91 testsuccessequal "$(aptcache show testpkg -o Acquire::Languages=none)
4dde2b42 92" aptcache dumpavail
f213b6ea
DK
93}
94
68151307
DK
95echo 'Dir::Log::Planner "/dev/null";
96Debug::pkgAcquire::worker "true";
5f982b9d 97debug::pkgAcquire::Auth "true";
70b63c57
DK
98Debug::pkgAcquire::Diffs "true";
99Debug::Acquire::http "true";' > rootdir/etc/apt/apt.conf.d/99debugconf
f213b6ea 100
5f982b9d
DK
101testovermethod() {
102 forcecompressor $2
f213b6ea 103
5f982b9d
DK
104 for INDEX in 'false' 'true'; do
105 rm -rf rootdir/var/lib/apt/lists
106 echo "Acquire::GzipIndexes \"${INDEX}\";" > rootdir/etc/apt/apt.conf.d/02compressindex
107 local INDCOMP
70b63c57 108 if [ "$INDEX" = 'false' -o "$1" = 'cdrom' ]; then
5f982b9d
DK
109 INDCOMP='uncompressed'
110 else
111 INDCOMP='compressed'
b2fd8524 112 echo 'APT::Compressor::lz4::Name "lz4";' >> rootdir/etc/apt/apt.conf.d/02compressindex
5f982b9d 113 fi
f213b6ea 114
70b63c57
DK
115 msgmsg "${1}: ${COMPRESSOR}: Test with $INDCOMP indexes gzip=$INDEX"
116 if [ "${1}" = 'cdrom' ]; then
117 testsuccess aptcdrom add </dev/null
118 fi
119 testsuccess aptget update
5f982b9d 120 testrun "$INDCOMP"
f213b6ea 121
70b63c57
DK
122 if [ "${1}" != 'cdrom' ]; then
123 testsuccess aptget update -o Acquire::Pdiffs=1
124 msgmsg "${1}: ${COMPRESSOR}: Test with $INDCOMP indexes gzip=$INDEX (update unchanged with pdiffs)"
125 testrun "$INDCOMP"
f213b6ea 126
70b63c57
DK
127 testsuccess aptget update -o Acquire::Pdiffs=0
128 msgmsg "${1}: ${COMPRESSOR}: Test with $INDCOMP indexes gzip=$INDEX (update unchanged without pdiffs)"
129 testrun "$INDCOMP"
130 fi
f213b6ea 131
5f982b9d
DK
132 rm rootdir/etc/apt/apt.conf.d/02compressindex
133 done
134}
f213b6ea 135
0440d936 136testsuccess aptget update
5f982b9d
DK
137GOODSHOW="$(aptcache show testpkg)
138"
139test $(echo "$GOODSHOW" | grep -e '^Package: testpkg' -e '^Version: 1.0' -e '^Architecture: i386' | wc -l) -eq 3 || msgdie 'show is broken'
25b86db1 140testsuccessequal "$GOODSHOW" aptcache show testpkg
5f982b9d
DK
141GOODSHOWSRC="$(aptcache showsrc testpkg)
142"
143test $(echo "$GOODSHOWSRC" | grep -e '^Package: testpkg' -e '^Format: 3.0 (native)' -e '^Files:' -e '^Checksums-Sha256:' | wc -l) -eq 4 || msgdie 'showsrc is broken'
25b86db1 144testsuccessequal "$GOODSHOWSRC" aptcache showsrc testpkg
718f797c 145GOODPOLICY="$(aptcache policy testpkg)"
af9e40c9 146test $(echo "$GOODPOLICY" | grep -e '^testpkg:' -e '^ Candidate:' -e '^ Installed: (none)' -e '500 file:/' | wc -l) -eq 4 || msgdie 'file policy is broken'
25b86db1 147testsuccessequal "$GOODPOLICY" aptcache policy testpkg
912a6131 148forallsupportedcompressors testovermethod 'file'
f213b6ea 149
af9e40c9 150rewritesourceslist "copy://${TMPWORKINGDIRECTORY}/aptarchive"
f213b6ea 151rm -rf rootdir/var/lib/apt/lists
0440d936 152testsuccess aptget update
5f982b9d 153GOODPOLICY="$(aptcache policy testpkg)"
af9e40c9 154test $(echo "$GOODPOLICY" | grep -e '^testpkg:' -e '^ Candidate:' -e '^ Installed: (none)' -e '500 copy:/' | wc -l) -eq 4 || msgdie 'copy policy is broken'
25b86db1 155testsuccessequal "$GOODPOLICY" aptcache policy testpkg
912a6131 156forallsupportedcompressors testovermethod 'copy'
f213b6ea 157
af9e40c9
DK
158changetowebserver
159rm -rf rootdir/var/lib/apt/lists
160testsuccess aptget update
161GOODPOLICY="$(aptcache policy testpkg)"
162test $(echo "$GOODPOLICY" | grep -e '^testpkg:' -e '^ Candidate:' -e '^ Installed: (none)' -e '500 http://' | wc -l) -eq 4 || msgdie 'http policy is broken'
163testsuccessequal "$GOODPOLICY" aptcache policy testpkg
912a6131 164forallsupportedcompressors testovermethod 'http'
70b63c57 165
af9e40c9
DK
166changetohttpswebserver
167rm -rf rootdir/var/lib/apt/lists
168testsuccess aptget update
169GOODPOLICY="$(aptcache policy testpkg)"
170test $(echo "$GOODPOLICY" | grep -e '^testpkg:' -e '^ Candidate:' -e '^ Installed: (none)' -e '500 https://' | wc -l) -eq 4 || msgdie 'https policy is broken'
171testsuccessequal "$GOODPOLICY" aptcache policy testpkg
912a6131 172forallsupportedcompressors testovermethod 'https'
af9e40c9 173
70b63c57
DK
174changetocdrom 'Debian APT Testdisk 0.8.15'
175rm -rf rootdir/var/lib/apt/lists
176testsuccess aptcdrom add </dev/null
177GOODPOLICY="$(aptcache policy testpkg)"
af9e40c9 178test $(echo "$GOODPOLICY" | grep -e '^testpkg:' -e '^ Candidate:' -e '^ Installed: (none)' -e '500 cdrom://' | wc -l) -eq 4 || msgdie 'cdrom policy is broken'
25b86db1 179testsuccessequal "$GOODPOLICY" aptcache policy testpkg
912a6131 180forallsupportedcompressors testovermethod 'cdrom'