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