]> git.saurik.com Git - apt.git/blame - test/integration/test-apt-acquire-additional-files
properly format multiline error messages
[apt.git] / test / integration / test-apt-acquire-additional-files
CommitLineData
1e0f0f28
DK
1#!/bin/sh
2set -e
7d2794a2
JAK
3# Cause umask failures
4umask 000
1e0f0f28 5
3abb6a6a
DK
6TESTDIR="$(readlink -f "$(dirname "$0")")"
7. "$TESTDIR/framework"
1e0f0f28
DK
8
9setupenvironment
10configarchitecture 'amd64'
59148d96 11
e93b4028 12# note that in --print-uri we talk about .xz because that is the default.
59148d96 13# This doesn't mean it is actually attempt to download it.
1e0f0f28 14configcompression '.' 'gz'
0179cfa8 15LOWCOSTEXT='lz4'
1e0f0f28
DK
16
17buildsimplenativepackage 'foo' 'amd64' '1' 'unstable'
b2fd8524 18buildsimplenativepackage 'bar' 'all' '1' 'unstable'
1e0f0f28
DK
19
20setupaptarchive --no-update
21changetowebserver
22
6c0765c0
DK
23testequal "'http://localhost:${APTHTTPPORT}/dists/unstable/InRelease' localhost:${APTHTTPPORT}_dists_unstable_InRelease 0
24'http://localhost:${APTHTTPPORT}/dists/unstable/main/source/Sources.xz' localhost:${APTHTTPPORT}_dists_unstable_main_source_Sources 0
25'http://localhost:${APTHTTPPORT}/dists/unstable/main/binary-amd64/Packages.xz' localhost:${APTHTTPPORT}_dists_unstable_main_binary-amd64_Packages 0
1dd20368 26'http://localhost:${APTHTTPPORT}/dists/unstable/main/binary-all/Packages.xz' localhost:${APTHTTPPORT}_dists_unstable_main_binary-all_Packages 0
6c0765c0
DK
27'http://localhost:${APTHTTPPORT}/dists/unstable/main/i18n/Translation-en.xz' localhost:${APTHTTPPORT}_dists_unstable_main_i18n_Translation-en 0 " aptget update --print-uris
28
29testsuccessequal "Get:1 http://localhost:${APTHTTPPORT} unstable InRelease [$(stat -c%s aptarchive/dists/unstable/InRelease) B]
30Get:2 http://localhost:${APTHTTPPORT} unstable/main Sources [$(stat -c%s aptarchive/dists/unstable/main/source/Sources.gz) B]
31Get:3 http://localhost:${APTHTTPPORT} unstable/main amd64 Packages [$(stat -c%s aptarchive/dists/unstable/main/binary-amd64/Packages.gz) B]
1dd20368
DK
32Get:4 http://localhost:${APTHTTPPORT} unstable/main all Packages [$(stat -c%s aptarchive/dists/unstable/main/binary-all/Packages.gz) B]
33Get:5 http://localhost:${APTHTTPPORT} unstable/main Translation-en [$(stat -c%s aptarchive/dists/unstable/main/i18n/Translation-en.gz) B]
1e0f0f28
DK
34Reading package lists..." aptget update
35
36testempty find rootdir/var/lib/apt/lists -name '*Contents*'
37
cd46d4eb 38msgmsg "Normal Contents file"
1e0f0f28 39cat > rootdir/etc/apt/apt.conf.d/content-target.conf <<EOF
c2a4a8dd 40Acquire::IndexTargets::deb::Contents {
d3a869e3 41 MetaKey "\$(COMPONENT)/Contents-\$(ARCHITECTURE)";
1e0f0f28 42 ShortDescription "Contents";
c2a4a8dd 43 Description "\$(RELEASE)/\$(COMPONENT) \$(ARCHITECTURE) Contents";
1e0f0f28
DK
44};
45EOF
46
1dd20368
DK
47readfile() {
48 while [ -n "$1" ]; do
49 readlink -f "./rootdir/var/lib/apt/lists/localhost:${APTHTTPPORT}_dists_unstable_main_${1}"
50 shift
51 done
52}
53
54testequal "$(readfile Contents-amd64 Contents-all)" aptget indextargets --no-release-info --format '$(FILENAME)' 'Created-By: Contents'
c2a4a8dd 55testempty aptget indextargets --format '$(FILENAME)' 'Created-By: Contents'
3fd89e62 56# lets fake the existence of a compressed Contents file
1dd20368 57touch "./rootdir/var/lib/apt/lists/localhost:${APTHTTPPORT}_dists_unstable_main_Contents-amd64.gz"
7d2794a2 58chmod 644 "./rootdir/var/lib/apt/lists/localhost:${APTHTTPPORT}_dists_unstable_main_Contents-amd64.gz"
1dd20368
DK
59testequal "$(readfile Contents-amd64.gz)" aptget indextargets --format '$(FILENAME)' 'Created-By: Contents'
60touch "./rootdir/var/lib/apt/lists/localhost:${APTHTTPPORT}_dists_unstable_main_Contents-all.gz"
7d2794a2 61chmod 644 "./rootdir/var/lib/apt/lists/localhost:${APTHTTPPORT}_dists_unstable_main_Contents-all.gz"
1dd20368 62testequal "$(readfile Contents-amd64.gz Contents-all.gz)" aptget indextargets --format '$(FILENAME)' 'Created-By: Contents'
3fd89e62 63
6c0765c0
DK
64testequal "'http://localhost:${APTHTTPPORT}/dists/unstable/InRelease' localhost:${APTHTTPPORT}_dists_unstable_InRelease 0
65'http://localhost:${APTHTTPPORT}/dists/unstable/main/source/Sources.xz' localhost:${APTHTTPPORT}_dists_unstable_main_source_Sources 0
66'http://localhost:${APTHTTPPORT}/dists/unstable/main/binary-amd64/Packages.xz' localhost:${APTHTTPPORT}_dists_unstable_main_binary-amd64_Packages 0
4e3c5633
DK
67'http://localhost:${APTHTTPPORT}/dists/unstable/main/binary-all/Packages.xz' localhost:${APTHTTPPORT}_dists_unstable_main_binary-all_Packages 0
68'http://localhost:${APTHTTPPORT}/dists/unstable/main/i18n/Translation-en.xz' localhost:${APTHTTPPORT}_dists_unstable_main_i18n_Translation-en 0
69'http://localhost:${APTHTTPPORT}/dists/unstable/main/Contents-amd64.xz' localhost:${APTHTTPPORT}_dists_unstable_main_Contents-amd64 0
70'http://localhost:${APTHTTPPORT}/dists/unstable/main/Contents-all.xz' localhost:${APTHTTPPORT}_dists_unstable_main_Contents-all 0 " aptget update --print-uris
71
72# apt believes the Contents files we faked are good
73testsuccessequal "Hit:1 http://localhost:${APTHTTPPORT} unstable InRelease
74Reading package lists..." aptget update
75testequal "$(readfile Contents-amd64.gz Contents-all.gz)" aptget indextargets --format '$(FILENAME)' 'Created-By: Contents'
76
77find rootdir/var/lib/apt/lists -name '*Contents*' -delete
78
79testequal "'http://localhost:${APTHTTPPORT}/dists/unstable/InRelease' localhost:${APTHTTPPORT}_dists_unstable_InRelease 0
80'http://localhost:${APTHTTPPORT}/dists/unstable/main/source/Sources.xz' localhost:${APTHTTPPORT}_dists_unstable_main_source_Sources 0
81'http://localhost:${APTHTTPPORT}/dists/unstable/main/binary-amd64/Packages.xz' localhost:${APTHTTPPORT}_dists_unstable_main_binary-amd64_Packages 0
1dd20368 82'http://localhost:${APTHTTPPORT}/dists/unstable/main/binary-all/Packages.xz' localhost:${APTHTTPPORT}_dists_unstable_main_binary-all_Packages 0
6c0765c0 83'http://localhost:${APTHTTPPORT}/dists/unstable/main/i18n/Translation-en.xz' localhost:${APTHTTPPORT}_dists_unstable_main_i18n_Translation-en 0
1dd20368
DK
84'http://localhost:${APTHTTPPORT}/dists/unstable/main/Contents-amd64.xz' localhost:${APTHTTPPORT}_dists_unstable_main_Contents-amd64 0
85'http://localhost:${APTHTTPPORT}/dists/unstable/main/Contents-all.xz' localhost:${APTHTTPPORT}_dists_unstable_main_Contents-all 0 " aptget update --print-uris
59148d96 86
6c0765c0
DK
87testsuccessequal "Hit:1 http://localhost:${APTHTTPPORT} unstable InRelease
88Get:2 http://localhost:${APTHTTPPORT} unstable/main amd64 Contents [$(stat -c%s aptarchive/dists/unstable/main/Contents-amd64.gz) B]
1dd20368 89Get:3 http://localhost:${APTHTTPPORT} unstable/main all Contents [$(stat -c%s aptarchive/dists/unstable/main/Contents-all.gz) B]
1e0f0f28
DK
90Reading package lists..." aptget update
91
1dd20368
DK
92testequal "rootdir/var/lib/apt/lists/localhost:${APTHTTPPORT}_dists_unstable_main_Contents-amd64" find rootdir/var/lib/apt/lists -name '*Contents-amd64*'
93testequal "rootdir/var/lib/apt/lists/localhost:${APTHTTPPORT}_dists_unstable_main_Contents-all" find rootdir/var/lib/apt/lists -name '*Contents-all*'
94testequal "$(readfile Contents-amd64 Contents-all)" aptget indextargets --format '$(FILENAME)' 'Created-By: Contents'
6c0765c0 95testsuccess cmp "rootdir/var/lib/apt/lists/localhost:${APTHTTPPORT}_dists_unstable_main_Contents-amd64" 'aptarchive/dists/unstable/main/Contents-amd64'
1dd20368 96testsuccess cmp "rootdir/var/lib/apt/lists/localhost:${APTHTTPPORT}_dists_unstable_main_Contents-all" 'aptarchive/dists/unstable/main/Contents-all'
1e0f0f28 97
1dd20368
DK
98rm ./rootdir/var/lib/apt/lists/localhost:${APTHTTPPORT}_dists_unstable_main_Contents-amd64 \
99 ./rootdir/var/lib/apt/lists/localhost:${APTHTTPPORT}_dists_unstable_main_Contents-all
c2a4a8dd 100testempty aptget indextargets --format '$(FILENAME)' 'Created-By: Contents'
653ef26c
DK
101
102# if we asked for keeping it compressed, keep it
cd46d4eb 103msgmsg "Normal Contents file with KeepCompressed"
c2a4a8dd 104echo 'Acquire::IndexTargets::deb::Contents::KeepCompressed "true";' >> rootdir/etc/apt/apt.conf.d/content-target.conf
6c0765c0
DK
105testsuccessequal "Hit:1 http://localhost:${APTHTTPPORT} unstable InRelease
106Get:2 http://localhost:${APTHTTPPORT} unstable/main amd64 Contents [$(stat -c%s aptarchive/dists/unstable/main/Contents-amd64.gz) B]
1dd20368 107Get:3 http://localhost:${APTHTTPPORT} unstable/main all Contents [$(stat -c%s aptarchive/dists/unstable/main/Contents-all.gz) B]
653ef26c
DK
108Reading package lists..." aptget update
109
0179cfa8
DK
110testequal "rootdir/var/lib/apt/lists/localhost:${APTHTTPPORT}_dists_unstable_main_Contents-amd64.$LOWCOSTEXT" find rootdir/var/lib/apt/lists -name '*Contents-amd64*'
111testequal "rootdir/var/lib/apt/lists/localhost:${APTHTTPPORT}_dists_unstable_main_Contents-all.$LOWCOSTEXT" find rootdir/var/lib/apt/lists -name '*Contents-all*'
112testequal "$(readfile Contents-amd64.$LOWCOSTEXT Contents-all.$LOWCOSTEXT)" aptget indextargets --format '$(FILENAME)' 'Created-By: Contents'
113testequal "$(apthelper cat-file rootdir/var/lib/apt/lists/localhost:${APTHTTPPORT}_dists_unstable_main_Contents-amd64.$LOWCOSTEXT)" apthelper cat-file 'aptarchive/dists/unstable/main/Contents-amd64.gz'
b2fd8524 114testequal "$(apthelper cat-file rootdir/var/lib/apt/lists/localhost:${APTHTTPPORT}_dists_unstable_main_Contents-all.$LOWCOSTEXT)" apthelper cat-file 'aptarchive/dists/unstable/main/Contents-all.gz'
653ef26c 115
0179cfa8
DK
116rm ./rootdir/var/lib/apt/lists/localhost:${APTHTTPPORT}_dists_unstable_main_Contents-amd64.$LOWCOSTEXT
117rm ./rootdir/var/lib/apt/lists/localhost:${APTHTTPPORT}_dists_unstable_main_Contents-all.$LOWCOSTEXT
c2a4a8dd 118testempty aptget indextargets --format '$(FILENAME)' 'Created-By: Contents'
653ef26c 119
cd46d4eb 120msgmsg "Compressed Contents file"
653ef26c 121# and no automatic uncompress based on the name please,
1e0f0f28
DK
122# only if we downloaded a compressed file, but target was uncompressed
123cat > rootdir/etc/apt/apt.conf.d/content-target.conf <<EOF
c2a4a8dd 124Acquire::IndexTargets::deb::Contents {
d3a869e3 125 MetaKey "\$(COMPONENT)/Contents-\$(ARCHITECTURE).gz";
1e0f0f28 126 ShortDescription "Contents.gz";
c2a4a8dd 127 Description "\$(RELEASE)/\$(COMPONENT) \$(ARCHITECTURE) Contents.gz";
1e0f0f28
DK
128};
129EOF
130
59148d96 131# the last line is utter bogus of course, but how should apt know…
6c0765c0
DK
132testequal "'http://localhost:${APTHTTPPORT}/dists/unstable/InRelease' localhost:${APTHTTPPORT}_dists_unstable_InRelease 0
133'http://localhost:${APTHTTPPORT}/dists/unstable/main/source/Sources.xz' localhost:${APTHTTPPORT}_dists_unstable_main_source_Sources 0
134'http://localhost:${APTHTTPPORT}/dists/unstable/main/binary-amd64/Packages.xz' localhost:${APTHTTPPORT}_dists_unstable_main_binary-amd64_Packages 0
1dd20368 135'http://localhost:${APTHTTPPORT}/dists/unstable/main/binary-all/Packages.xz' localhost:${APTHTTPPORT}_dists_unstable_main_binary-all_Packages 0
6c0765c0 136'http://localhost:${APTHTTPPORT}/dists/unstable/main/i18n/Translation-en.xz' localhost:${APTHTTPPORT}_dists_unstable_main_i18n_Translation-en 0
1dd20368
DK
137'http://localhost:${APTHTTPPORT}/dists/unstable/main/Contents-amd64.gz.xz' localhost:${APTHTTPPORT}_dists_unstable_main_Contents-amd64.gz 0
138'http://localhost:${APTHTTPPORT}/dists/unstable/main/Contents-all.gz.xz' localhost:${APTHTTPPORT}_dists_unstable_main_Contents-all.gz 0 " aptget update --print-uris
6c0765c0
DK
139
140testsuccessequal "Hit:1 http://localhost:${APTHTTPPORT} unstable InRelease
141Get:2 http://localhost:${APTHTTPPORT} unstable/main amd64 Contents.gz [$(stat -c%s aptarchive/dists/unstable/main/Contents-amd64.gz) B]
1dd20368 142Get:3 http://localhost:${APTHTTPPORT} unstable/main all Contents.gz [$(stat -c%s aptarchive/dists/unstable/main/Contents-all.gz) B]
1e0f0f28
DK
143Reading package lists..." aptget update
144
1dd20368
DK
145testequal "rootdir/var/lib/apt/lists/localhost:${APTHTTPPORT}_dists_unstable_main_Contents-amd64.gz" find rootdir/var/lib/apt/lists -name '*Contents-amd64*'
146testequal "rootdir/var/lib/apt/lists/localhost:${APTHTTPPORT}_dists_unstable_main_Contents-all.gz" find rootdir/var/lib/apt/lists -name '*Contents-all*'
147testequal "$(readfile Contents-amd64.gz Contents-all.gz)" aptget indextargets --format '$(FILENAME)' 'Created-By: Contents'
6c0765c0 148testsuccess cmp "rootdir/var/lib/apt/lists/localhost:${APTHTTPPORT}_dists_unstable_main_Contents-amd64.gz" 'aptarchive/dists/unstable/main/Contents-amd64.gz'
1dd20368 149testsuccess cmp "rootdir/var/lib/apt/lists/localhost:${APTHTTPPORT}_dists_unstable_main_Contents-all.gz" 'aptarchive/dists/unstable/main/Contents-all.gz'
59148d96
DK
150
151rm -f rootdir/etc/apt/apt.conf.d/content-target.conf
cd46d4eb 152msgmsg "No Contents file"
59148d96 153
6c0765c0
DK
154testequal "'http://localhost:${APTHTTPPORT}/dists/unstable/InRelease' localhost:${APTHTTPPORT}_dists_unstable_InRelease 0
155'http://localhost:${APTHTTPPORT}/dists/unstable/main/source/Sources.xz' localhost:${APTHTTPPORT}_dists_unstable_main_source_Sources 0
156'http://localhost:${APTHTTPPORT}/dists/unstable/main/binary-amd64/Packages.xz' localhost:${APTHTTPPORT}_dists_unstable_main_binary-amd64_Packages 0
1dd20368 157'http://localhost:${APTHTTPPORT}/dists/unstable/main/binary-all/Packages.xz' localhost:${APTHTTPPORT}_dists_unstable_main_binary-all_Packages 0
6c0765c0 158'http://localhost:${APTHTTPPORT}/dists/unstable/main/i18n/Translation-en.xz' localhost:${APTHTTPPORT}_dists_unstable_main_i18n_Translation-en 0 " aptget update --print-uris
59148d96 159
6c0765c0 160testsuccessequal "Hit:1 http://localhost:${APTHTTPPORT} unstable InRelease
59148d96
DK
161Reading package lists..." aptget update
162
163testempty find rootdir/var/lib/apt/lists -name '*Contents*'