]> git.saurik.com Git - apt.git/blame - test/integration/test-compressed-indexes
Merge branch 'debian/sid' into debian/experimental
[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
34 ! test -e rootdir/var/lib/apt/lists/*_Packages || F=1
35 ! test -e rootdir/var/lib/apt/lists/*_Sources || F=1
36 ! test -e rootdir/var/lib/apt/lists/*_Translation-en || F=1
37 test -e rootdir/var/lib/apt/lists/*_Packages.${COMPRESS} || F=1
38 test -e rootdir/var/lib/apt/lists/*_Sources.${COMPRESS} || F=1
39 test -e rootdir/var/lib/apt/lists/*_Translation-en.${COMPRESS} || F=1
40 # there is no point in trying pdiff if we have compressed indexes
41 # as we can't patch compressed files (well, we can, but what is the point?)
42 ! test -e rootdir/var/lib/apt/lists/*.IndexDiff || F=1
43 else
44 # clear the faked pdiff indexes so the glob below works
45 rm -f rootdir/var/lib/apt/lists/*.IndexDiff
46 test -e rootdir/var/lib/apt/lists/*_Packages || F=1
47 test -e rootdir/var/lib/apt/lists/*_Sources || F=1
48 test -e rootdir/var/lib/apt/lists/*_Translation-en || F=1
49 ! test -e rootdir/var/lib/apt/lists/*_Packages.* || F=1
50 ! test -e rootdir/var/lib/apt/lists/*_Sources.* || F=1
51 ! test -e rootdir/var/lib/apt/lists/*_Translation-en.* || F=1
f213b6ea 52 fi
5f982b9d
DK
53 if [ -n "$F" ]; then
54 ls -laR rootdir/var/lib/apt/lists/
55 msgfail
56 else
57 msgpass
58 fi
59 msgtest 'Check if package is downloadable'
60 testsuccess --nomsg aptget download testpkg
61 msgtest '\tdeb file is present'; testsuccess --nomsg test -f testpkg_1.0_i386.deb
62 rm testpkg_1.0_i386.deb
63 testequal 'Reading package lists...
64Building dependency tree...
65The following NEW packages will be installed:
66 testpkg
670 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
68Inst testpkg (1.0 unstable [i386])
69Conf testpkg (1.0 unstable [i386])' aptget install testpkg -s
8de79b68 70 rm -f rootdir/var/cache/apt/pkgcache.bin rootdir/var/cache/apt/srcpkgcache.bin
f213b6ea
DK
71 testequal "$GOODSHOW" aptcache show testpkg
72 testequal "$GOODSHOW" aptcache show testpkg
8de79b68 73 rm -f rootdir/var/cache/apt/pkgcache.bin rootdir/var/cache/apt/srcpkgcache.bin
f213b6ea
DK
74 testequal "$GOODPOLICY" aptcache policy testpkg
75 testequal "$GOODPOLICY" aptcache policy testpkg
8de79b68 76 rm -f rootdir/var/cache/apt/pkgcache.bin rootdir/var/cache/apt/srcpkgcache.bin
f213b6ea
DK
77 testequal "$GOODSHOWSRC" aptcache showsrc testpkg
78 testequal "$GOODSHOWSRC" aptcache showsrc testpkg
8de79b68 79 aptget clean
5f982b9d 80 msgtest 'Check if the source is aptgetable'
0440d936 81 testsuccess --nomsg aptget source testpkg
5f982b9d
DK
82 msgtest '\tdsc file is present'; testsuccess --nomsg test -f testpkg_1.0.dsc
83 msgtest '\tdirectory is present'; testsuccess --nomsg test -d testpkg-1.0
84 rm -rf testpkg-1.0*
4dde2b42
DK
85 testequal "$(aptcache show testpkg -o Acquire::Languages=none)
86" aptcache dumpavail
f213b6ea
DK
87}
88
5f982b9d
DK
89echo 'Debug::pkgAcquire::worker "true";
90debug::pkgAcquire::Auth "true";
91Debug::pkgAcquire::Diffs "true";' > rootdir/etc/apt/apt.conf.d/99debugconf
f213b6ea 92
5f982b9d
DK
93testovermethod() {
94 forcecompressor $2
f213b6ea 95
5f982b9d
DK
96 for INDEX in 'false' 'true'; do
97 rm -rf rootdir/var/lib/apt/lists
98 echo "Acquire::GzipIndexes \"${INDEX}\";" > rootdir/etc/apt/apt.conf.d/02compressindex
99 local INDCOMP
100 if [ "$INDEX" = 'false' ]; then
101 INDCOMP='uncompressed'
102 else
103 INDCOMP='compressed'
104 fi
f213b6ea 105
5f982b9d
DK
106 testsuccess aptget update
107 msgmsg "${1}: ${COMPRESSOR}: Test with $INDCOMP indexes"
108 testrun "$INDCOMP"
f213b6ea 109
5f982b9d
DK
110 testsuccess aptget update -o Acquire::Pdiffs=1
111 msgmsg "${1}: ${COMPRESSOR}: Test with $INDCOMP indexes (update unchanged with pdiffs)"
112 testrun "$INDCOMP"
f213b6ea 113
5f982b9d
DK
114 testsuccess aptget update -o Acquire::Pdiffs=0
115 msgmsg "${1}: ${COMPRESSOR}: Test with $INDCOMP indexes (update unchanged without pdiffs)"
116 testrun "$INDCOMP"
f213b6ea 117
5f982b9d
DK
118 rm rootdir/etc/apt/apt.conf.d/02compressindex
119 done
120}
f213b6ea 121
0440d936 122testsuccess aptget update
5f982b9d
DK
123GOODSHOW="$(aptcache show testpkg)
124"
125test $(echo "$GOODSHOW" | grep -e '^Package: testpkg' -e '^Version: 1.0' -e '^Architecture: i386' | wc -l) -eq 3 || msgdie 'show is broken'
126testequal "$GOODSHOW" aptcache show testpkg
127GOODSHOWSRC="$(aptcache showsrc testpkg)
128"
129test $(echo "$GOODSHOWSRC" | grep -e '^Package: testpkg' -e '^Format: 3.0 (native)' -e '^Files:' -e '^Checksums-Sha256:' | wc -l) -eq 4 || msgdie 'showsrc is broken'
130testequal "$GOODSHOWSRC" aptcache showsrc testpkg
718f797c 131GOODPOLICY="$(aptcache policy testpkg)"
5f982b9d 132test $(echo "$GOODPOLICY" | grep -e '^testpkg:' -e '^ Candidate:' -e '^ Installed: (none)' -e '500 file:/' | wc -l) -eq 4 || msgdie 'policy is broken'
f213b6ea
DK
133testequal "$GOODPOLICY" aptcache policy testpkg
134
5f982b9d 135for COMPRESSOR in 'gzip' 'bzip2' 'lzma' 'xz'; do testovermethod 'file' $COMPRESSOR; done
f213b6ea 136
5f982b9d 137changetowebserver
f213b6ea 138rm -rf rootdir/var/lib/apt/lists
0440d936 139testsuccess aptget update
5f982b9d
DK
140GOODPOLICY="$(aptcache policy testpkg)"
141test $(echo "$GOODPOLICY" | grep -e '^testpkg:' -e '^ Candidate:' -e '^ Installed: (none)' -e '500 http://' | wc -l) -eq 4 || msgdie 'policy is broken'
142testequal "$GOODPOLICY" aptcache policy testpkg
f213b6ea 143
5f982b9d 144for COMPRESSOR in 'gzip' 'bzip2' 'lzma' 'xz'; do testovermethod 'http' $COMPRESSOR; done