]> git.saurik.com Git - apt.git/blob - test/integration/test-bug-595691-empty-and-broken-archive-files
ignore for _apt inaccessible TMPDIR in pkgAcqChangelog
[apt.git] / test / integration / test-bug-595691-empty-and-broken-archive-files
1 #!/bin/sh
2 set -e
3
4 TESTDIR=$(readlink -f $(dirname $0))
5 . $TESTDIR/framework
6 setupenvironment
7 configarchitecture "i386"
8
9 buildaptarchive
10 touch aptarchive/Packages
11 setupflataptarchive
12
13 testaptgetupdate() {
14 rm -rf rootdir/var/lib/apt
15 aptget update >testaptgetupdate.diff 2>&1 || true
16 sed -i -e '/Ign /,+1d' -e '/Release/ d' -e 's#\[[0-9]* [kMGTPY]*B\]#\[\]#' testaptgetupdate.diff
17 GIVEN="$1"
18 shift
19 msgtest "Test for correctness of" "apt-get update with $*"
20 if [ -z "$GIVEN" ]; then
21 echo -n "" | checkdiff - testaptgetupdate.diff && msgpass || msgfail
22 else
23 echo "$GIVEN" | checkdiff - testaptgetupdate.diff && msgpass || msgfail
24 fi
25 rm testaptgetupdate.diff
26 }
27
28 createemptyarchive() {
29 find aptarchive/ \( -name "Packages*" -o -name "en*" \) -type f -delete
30 touch aptarchive/Packages
31 echo -n "" | $COMPRESSOR_CMD > aptarchive/${1}.$COMPRESS
32 generatereleasefiles
33 signreleasefiles
34 rm -f aptarchive/Packages
35 }
36
37 createemptyfile() {
38 find aptarchive/ \( -name "Packages*" -o -name "en*" \) -type f -delete
39 touch aptarchive/Packages aptarchive/${1}.$COMPRESS
40 generatereleasefiles
41 signreleasefiles
42 rm -f aptarchive/Packages
43 }
44
45 testoverfile() {
46 local APTARCHIVE="$(readlink -f ./aptarchive)"
47 forcecompressor "$1"
48
49 createemptyarchive 'Packages'
50 testaptgetupdate "Get:2 file:$APTARCHIVE Packages []
51 Reading package lists..." "empty archive Packages.$COMPRESS over file"
52
53 createemptyfile 'Packages'
54 testaptgetupdate "Get:2 file:$APTARCHIVE Packages
55 Err:2 file:$APTARCHIVE Packages
56 Empty files can't be valid archives
57 W: Failed to fetch ${COMPRESSOR}:${APTARCHIVE}/Packages.$COMPRESS Empty files can't be valid archives
58 E: Some index files failed to download. They have been ignored, or old ones used instead." "empty file Packages.$COMPRESS over file"
59 }
60
61 testoverhttp() {
62 forcecompressor "$1"
63
64 createemptyarchive 'Packages'
65 testaptgetupdate "Get:2 http://localhost:8080 Packages []
66 Reading package lists..." "empty archive Packages.$COMPRESS over http"
67
68 createemptyfile 'Packages'
69 #FIXME: we should response with a good error message instead
70 testaptgetupdate "Get:2 http://localhost:8080 Packages
71 Err:2 http://localhost:8080 Packages
72 Empty files can't be valid archives
73 W: Failed to fetch ${COMPRESSOR}:$(readlink -f rootdir/var/lib/apt/lists/partial/localhost:8080_Packages.${COMPRESS}) Empty files can't be valid archives
74 E: Some index files failed to download. They have been ignored, or old ones used instead." "empty file Packages.$COMPRESS over http"
75 }
76
77 for COMPRESSOR in 'gzip' 'bzip2' 'lzma' 'xz'; do testoverfile $COMPRESSOR; done
78
79 # do the same again with http instead of file
80 changetowebserver
81
82 for COMPRESSOR in 'gzip' 'bzip2' 'lzma' 'xz'; do testoverhttp $COMPRESSOR; done