summaryrefslogtreecommitdiffstats
path: root/test/integration/test-bug-595691-empty-and-broken-archive-files
blob: d71bd2ce5a875840973fb4d6d9e98662c14ebad0 (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
#!/bin/sh
set -e

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

buildaptarchive
touch aptarchive/Packages
setupflataptarchive

failureupdate() {
	rm -rf rootdir/var/lib/apt
	testfailure aptget update --allow-insecure-repositories
	testsuccess grep "^E: Failed to fetch store:${1}  Empty files can't be valid archives$" rootdir/tmp/testfailure.output
}
successupdate() {
	rm -rf rootdir/var/lib/apt
	testwarning aptget update --allow-insecure-repositories
}

createemptyarchive() {
	find aptarchive/ \( -name "Packages*" -o -name "en*" \) -type f -delete
	touch aptarchive/Packages
	echo -n "" | $COMPRESSOR_CMD > aptarchive/${1}.$COMPRESS
	find aptarchive -name '*Release*' -delete
	rm -f aptarchive/Packages
}

createemptyfile() {
	find aptarchive/ \( -name "Packages*" -o -name "en*" \) -type f -delete
	touch aptarchive/Packages aptarchive/${1}.$COMPRESS
	find aptarchive -name '*Release*' -delete
	rm -f aptarchive/Packages
}

testoverfile() {
	local APTARCHIVE="$(readlink -f ./aptarchive)"
	forcecompressor "$1"

	msgmsg 'archive over file' "Packages.$COMPRESS"
	createemptyarchive 'Packages'
	successupdate
	createemptyfile 'Packages'
	failureupdate "$(readlink -f rootdir/var/lib/apt/lists/partial/$(echo "$APTARCHIVE" | sed -e 's#/#_#g')_Packages.${COMPRESS})"
}

testoverhttp() {
	forcecompressor "$1"

	msgmsg 'archive over http' "Packages.$COMPRESS"
	createemptyarchive 'Packages'
	successupdate
	createemptyfile 'Packages'
	failureupdate "$(readlink -f rootdir/var/lib/apt/lists/partial/localhost:${APTHTTPPORT}_Packages.${COMPRESS})"
}

forallsupportedcompressors testoverfile

# do the same again with http instead of file
changetowebserver

forallsupportedcompressors testoverhttp