summaryrefslogtreecommitdiffstats
path: root/test/integration/test-compressed-indexes
blob: 858bf1178451e49603dbcdf64500e934de59dea1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
#!/bin/sh
set -e

TESTDIR="$(readlink -f "$(dirname "$0")")"
. "$TESTDIR/framework"

setupenvironment
configcompression 'ALL'
configarchitecture 'i386'
LOWCOSTEXT='lz4'

buildsimplenativepackage 'testpkg' 'i386' '1.0'

buildaptarchive
setupdistsaptarchive
# fake a pdiff setup as apt wouldn't try pdiffs otherwise
find aptarchive -name 'Packages' -o -name 'Sources' | while read file; do
	mkdir "${file}.diff"
	PATCHINDEX="${file}.diff/Index"
	echo 'SHA1-Current: adc83b19e793491b1c6ea0fd8b46cd9f32e592fc 0
SHA1-History:
 adc83b19e793491b1c6ea0fd8b46cd9f32e592fc 33053002 2010-08-18-2013.28
 ecfd1b19e793491b1c6ea123eabdcd9f32e592fc 33053001 2010-08-18-2013.29
SHA1-Patches:
 abc1fc0ac57cd83d41c63195a9342e2db5650257 19722 2010-08-18-0814.28
 dfe3444ac57cd83d41c63195a9342e2db5650257 19722 2010-08-18-0814.29' > $PATCHINDEX
done
generatereleasefiles
signreleasefiles

testrun() {
	local F
	msgtest 'Check if all index files are' "${1:-uncompressed}"
	if [ "$1" = 'compressed' ]; then
		! test -e rootdir/var/lib/apt/lists/*i386_Packages || F=1
		! test -e rootdir/var/lib/apt/lists/*_Sources || F=1
		! test -e rootdir/var/lib/apt/lists/*_Translation-en || F=1
		test -e rootdir/var/lib/apt/lists/*i386_Packages.$LOWCOSTEXT || F=1
		test -e rootdir/var/lib/apt/lists/*_Sources.$LOWCOSTEXT || F=1
		test -e rootdir/var/lib/apt/lists/*_Translation-en.$LOWCOSTEXT || F=1
		# there is no point in trying pdiff if we have compressed indexes
		# as we can't patch compressed files (well, we can, but what is the point?)
		! test -e rootdir/var/lib/apt/lists/*diff_Index || F=1
	else
		# clear the faked pdiff indexes so the glob below works
		rm -f rootdir/var/lib/apt/lists/*diff_Index
		test -e rootdir/var/lib/apt/lists/*i386_Packages || F=1
		test -e rootdir/var/lib/apt/lists/*_Sources || F=1
		test -e rootdir/var/lib/apt/lists/*_Translation-en || F=1
		! test -e rootdir/var/lib/apt/lists/*i386_Packages.* || F=1
		! test -e rootdir/var/lib/apt/lists/*_Sources.* || F=1
		! test -e rootdir/var/lib/apt/lists/*_Translation-en.* || F=1
	fi
	if [ -n "$F" ]; then
		cat rootdir/tmp/testsuccess.output
		ls -laR rootdir/var/lib/apt/lists/
		msgfail
	else
		msgpass
	fi
	msgtest 'Check if package is downloadable'
	cd downloaded
	testsuccess --nomsg aptget download testpkg
	msgtest 'deb file is present'; testsuccess --nomsg test -f testpkg_1.0_i386.deb
	rm -f testpkg_1.0_i386.deb
	cd - >/dev/null
	testsuccessequal 'Reading package lists...
Building dependency tree...
The following NEW packages will be installed:
  testpkg
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Inst testpkg (1.0 unstable [i386])
Conf testpkg (1.0 unstable [i386])' aptget install testpkg -s -o Debug::pkgAcquire::Auth=0 -o Debug::pkgAcquire::Worker=0
	rm -f rootdir/var/cache/apt/pkgcache.bin rootdir/var/cache/apt/srcpkgcache.bin
	testsuccessequal "$GOODSHOW" aptcache show testpkg
	testsuccessequal "$GOODSHOW" aptcache show testpkg
	rm -f rootdir/var/cache/apt/pkgcache.bin rootdir/var/cache/apt/srcpkgcache.bin
	testsuccessequal "$GOODPOLICY" aptcache policy testpkg
	testsuccessequal "$GOODPOLICY" aptcache policy testpkg
	rm -f rootdir/var/cache/apt/pkgcache.bin rootdir/var/cache/apt/srcpkgcache.bin
	testsuccessequal "$GOODSHOWSRC" aptcache showsrc testpkg
	testsuccessequal "$GOODSHOWSRC" aptcache showsrc testpkg
	aptget clean
	msgtest 'Check if the source is aptgetable'
	cd downloaded
	testsuccess --nomsg aptget source testpkg
	testsuccess test -s testpkg_1.0.dsc
	testsuccess test -d testpkg-1.0
	rm -rf testpkg-1.0*
	cd - >/dev/null
	testsuccessequal "$(aptcache show testpkg -o Acquire::Languages=none)
" aptcache dumpavail
}

echo 'Dir::Log::Planner "/dev/null";
Debug::pkgAcquire::worker "true";
debug::pkgAcquire::Auth "true";
Debug::pkgAcquire::Diffs "true";
Debug::Acquire::http "true";' > rootdir/etc/apt/apt.conf.d/99debugconf

testovermethod() {
	forcecompressor $2

	for INDEX in 'false' 'true'; do
		rm -rf rootdir/var/lib/apt/lists
		echo "Acquire::GzipIndexes \"${INDEX}\";" > rootdir/etc/apt/apt.conf.d/02compressindex
		local INDCOMP
		if [ "$INDEX" = 'false' -o "$1" = 'cdrom' ]; then
			INDCOMP='uncompressed'
		else
			INDCOMP='compressed'
			echo 'APT::Compressor::lz4::Name "lz4";' >> rootdir/etc/apt/apt.conf.d/02compressindex
		fi

		msgmsg "${1}: ${COMPRESSOR}: Test with $INDCOMP indexes gzip=$INDEX"
		if [ "${1}" = 'cdrom' ]; then
			testsuccess aptcdrom add </dev/null
		fi
		testsuccess aptget update
		testrun "$INDCOMP"

		if [ "${1}" != 'cdrom' ]; then
			testsuccess aptget update -o Acquire::Pdiffs=1
			msgmsg "${1}: ${COMPRESSOR}: Test with $INDCOMP indexes gzip=$INDEX (update unchanged with pdiffs)"
			testrun "$INDCOMP"

			testsuccess aptget update -o Acquire::Pdiffs=0
			msgmsg "${1}: ${COMPRESSOR}: Test with $INDCOMP indexes gzip=$INDEX (update unchanged without pdiffs)"
			testrun "$INDCOMP"
		fi

		rm rootdir/etc/apt/apt.conf.d/02compressindex
	done
}

testsuccess aptget update
GOODSHOW="$(aptcache show testpkg)
"
test $(echo "$GOODSHOW" | grep -e '^Package: testpkg' -e '^Version: 1.0' -e '^Architecture: i386' | wc -l) -eq 3 || msgdie 'show is broken'
testsuccessequal "$GOODSHOW" aptcache show testpkg
GOODSHOWSRC="$(aptcache showsrc testpkg)
"
test $(echo "$GOODSHOWSRC" | grep -e '^Package: testpkg' -e '^Format: 3.0 (native)' -e '^Checksums-Sha256:' | wc -l) -eq 3 || msgdie 'showsrc is broken'
testsuccessequal "$GOODSHOWSRC" aptcache showsrc testpkg
GOODPOLICY="$(aptcache policy testpkg)"
test $(echo "$GOODPOLICY" | grep -e '^testpkg:' -e '^  Candidate:' -e '^  Installed: (none)' -e '500 file:/' | wc -l) -eq 4 || msgdie 'file policy is broken'
testsuccessequal "$GOODPOLICY" aptcache policy testpkg
forallsupportedcompressors testovermethod 'file'

rewritesourceslist "copy://${TMPWORKINGDIRECTORY}/aptarchive"
rm -rf rootdir/var/lib/apt/lists
testsuccess aptget update
GOODPOLICY="$(aptcache policy testpkg)"
test $(echo "$GOODPOLICY" | grep -e '^testpkg:' -e '^  Candidate:' -e '^  Installed: (none)' -e '500 copy:/' | wc -l) -eq 4 || msgdie 'copy policy is broken'
testsuccessequal "$GOODPOLICY" aptcache policy testpkg
forallsupportedcompressors testovermethod 'copy'

changetowebserver
rm -rf rootdir/var/lib/apt/lists
testsuccess aptget update
GOODPOLICY="$(aptcache policy testpkg)"
test $(echo "$GOODPOLICY" | grep -e '^testpkg:' -e '^  Candidate:' -e '^  Installed: (none)' -e '500 http://' | wc -l) -eq 4 || msgdie 'http policy is broken'
testsuccessequal "$GOODPOLICY" aptcache policy testpkg
forallsupportedcompressors testovermethod 'http'

changetohttpswebserver
rm -rf rootdir/var/lib/apt/lists
testsuccess aptget update
GOODPOLICY="$(aptcache policy testpkg)"
test $(echo "$GOODPOLICY" | grep -e '^testpkg:' -e '^  Candidate:' -e '^  Installed: (none)' -e '500 https://' | wc -l) -eq 4 || msgdie 'https policy is broken'
testsuccessequal "$GOODPOLICY" aptcache policy testpkg
forallsupportedcompressors testovermethod 'https'

changetocdrom 'Debian APT Testdisk 0.8.15'
rm -rf rootdir/var/lib/apt/lists
testsuccess aptcdrom add </dev/null
GOODPOLICY="$(aptcache policy testpkg)"
test $(echo "$GOODPOLICY" | grep -e '^testpkg:' -e '^  Candidate:' -e '^  Installed: (none)' -e '500 cdrom://' | wc -l) -eq 4 || msgdie 'cdrom policy is broken'
testsuccessequal "$GOODPOLICY" aptcache policy testpkg
forallsupportedcompressors testovermethod 'cdrom'