]> git.saurik.com Git - apt.git/blame - test/integration/test-apt-get-changelog
better error message for insufficient hashsums
[apt.git] / test / integration / test-apt-get-changelog
CommitLineData
e5837128
MV
1#!/bin/sh
2set -e
3
3abb6a6a
DK
4TESTDIR="$(readlink -f "$(dirname "$0")")"
5. "$TESTDIR/framework"
e5837128
MV
6
7setupenvironment
d56e2917 8configarchitecture 'native'
e5837128 9
b5aba909 10buildsimplenativepackage 'dpkg' 'native' '42' 'stable'
d56e2917
DK
11buildsimplenativepackage 'foo' 'all' '1.0' 'stable'
12buildsimplenativepackage 'libbar' 'all' '1.0' 'stable'
13
14getlabelfromsuite() { echo 'Testcases'; }
15getoriginfromsuite() { echo 'Debian'; }
e5837128 16
75b09312 17setupaptarchive --no-update
13845042 18changetowebserver
75b09312 19testsuccess aptget update
e5837128 20
d56e2917
DK
21testsuccessequal "'http://metadata.ftp-master.debian.org/changelogs/main/f/foo/foo_1.0_changelog' foo.changelog
22'http://metadata.ftp-master.debian.org/changelogs/main/libb/libbar/libbar_1.0_changelog' libbar.changelog" aptget changelog foo libbar --print-uris
23
24releasechanger() {
25 # modifying the Release files in lists… bad stuff. Good that this is only a test…
26 sed -i "s#^${1}: .*#${1}: ${2}#" $(find rootdir/var/lib/apt/lists -name '*Release')
27 rm -f rootdir/var/cache/apt/*.bin
28}
29releasechanger 'Origin' 'Ubuntu'
30testsuccessequal "'http://changelogs.ubuntu.com/changelogs/pool/main/f/foo/foo_1.0/changelog' foo.changelog
31'http://changelogs.ubuntu.com/changelogs/pool/main/libb/libbar/libbar_1.0/changelog' libbar.changelog" aptget changelog foo libbar --print-uris
32
33releasechanger 'Label' 'Debian'
34testsuccessequal "'http://changelogs.ubuntu.com/changelogs/pool/main/f/foo/foo_1.0/changelog' foo.changelog
35'http://changelogs.ubuntu.com/changelogs/pool/main/libb/libbar/libbar_1.0/changelog' libbar.changelog" aptget changelog foo libbar --print-uris
36
6c0765c0 37testsuccessequal "'http://localhost:${APTHTTPPORT}/main/f/foo/foo_1.0.changelog' foo.changelog
430481e7 38'http://localhost:${APTHTTPPORT}/main/libb/libbar/libbar_1.0.changelog' libbar.changelog" aptget changelog foo libbar --print-uris -o Acquire::Changelogs::URI::Label::Debian="http://localhost:${APTHTTPPORT}/@CHANGEPATH@.changelog"
d56e2917
DK
39
40sed -i '/^Origin: / a\
430481e7 41Changelogs: http://example.org/@CHANGEPATH@-changelog' $(find rootdir/var/lib/apt/lists -name '*Release')
d56e2917 42rm -f rootdir/var/cache/apt/*.bin
43acd019 43
d56e2917 44testsuccessequal "'http://example.org/main/f/foo/foo_1.0-changelog' foo.changelog
430481e7 45'http://example.org/main/libb/libbar/libbar_1.0-changelog' libbar.changelog" aptget changelog foo libbar --print-uris -o Acquire::Changelogs::URI::Label::Debian="http://localhost:${APTHTTPPORT}/@CHANGEPATH@.changelog"
e5837128 46
6c0765c0 47testsuccessequal "'http://localhost:${APTHTTPPORT}/main/f/foo/foo_1.0.changelog' foo.changelog
430481e7 48'http://localhost:${APTHTTPPORT}/main/libb/libbar/libbar_1.0.changelog' libbar.changelog" aptget changelog foo libbar --print-uris -o Acquire::Changelogs::URI::Override::Label::Debian="http://localhost:${APTHTTPPORT}/@CHANGEPATH@.changelog"
fcb144b9 49
d56e2917 50releasechanger 'Changelogs' 'no'
6fd4b4c0 51testfailuremsg 'E: Failed to fetch changelog:/foo.changelog Changelog unavailable for foo=1.0' aptget changelog foo -d
d56e2917
DK
52
53sed -i '/^Changelogs: / d' $(find rootdir/var/lib/apt/lists -name '*Release')
54releasechanger 'Label' 'Testcases'
55
430481e7 56echo "Acquire::Changelogs::URI::Label::Testcases \"http://localhost:${APTHTTPPORT}/@CHANGEPATH@/change.txt\";" > rootdir/etc/apt/apt.conf.d/changelog.conf
6c0765c0
DK
57testsuccessequal "'http://localhost:${APTHTTPPORT}/main/f/foo/foo_1.0/change.txt' foo.changelog
58'http://localhost:${APTHTTPPORT}/main/libb/libbar/libbar_1.0/change.txt' libbar.changelog" aptget changelog foo libbar --print-uris
d56e2917 59
430481e7 60echo "Acquire::Changelogs::URI::Label::Testcases \"http://localhost:${APTHTTPPORT}/pool/@CHANGEPATH@/changelog\";" > rootdir/etc/apt/apt.conf.d/changelog.conf
6c0765c0 61testsuccessequal "'http://localhost:${APTHTTPPORT}/pool/main/f/foo/foo_1.0/changelog' foo.changelog" aptget changelog foo --print-uris
03aa0847 62
a98b6615 63
d56e2917 64testsuccess aptget changelog foo -qq
d1256170 65testfileequal 'rootdir/tmp/testsuccess.output' "$(cat aptarchive/pool/main/f/foo/foo_1.0/changelog)"
d56e2917
DK
66
67testsuccess aptget changelog foo libbar -qq
d1256170
DK
68testfileequal 'rootdir/tmp/testsuccess.output' "$(cat aptarchive/pool/main/f/foo/foo_1.0/changelog)
69$(cat aptarchive/pool/main/libb/libbar/libbar_1.0/changelog)"
70
d56e2917
DK
71testsuccess aptget changelog foo -d
72testfilestats 'foo.changelog' '%U:%G:%a' '=' "${TEST_DEFAULT_USER}:${TEST_DEFAULT_GROUP}:644"
6fd4b4c0 73testfileequal 'foo.changelog' "$(cat aptarchive/pool/main/f/foo/foo_1.0/changelog)"
d56e2917 74rm -f foo.changelog
72dd5bec 75
d56e2917
DK
76testsuccess aptget changelog libbar foo -d
77testfilestats 'libbar.changelog' '%U:%G:%a' '=' "${TEST_DEFAULT_USER}:${TEST_DEFAULT_GROUP}:644"
78testfilestats 'foo.changelog' '%U:%G:%a' '=' "${TEST_DEFAULT_USER}:${TEST_DEFAULT_GROUP}:644"
6fd4b4c0
DK
79testfileequal 'libbar.changelog' "$(cat aptarchive/pool/main/libb/libbar/libbar_1.0/changelog)"
80testfileequal 'foo.changelog' "$(cat aptarchive/pool/main/f/foo/foo_1.0/changelog)"
d56e2917 81rm -f libbar.changelog foo.changelog
13845042 82
d56e2917 83# as such bogus, but can happen with multiple binaries from the same source
6c0765c0
DK
84testsuccessequal "'http://localhost:${APTHTTPPORT}/pool/main/f/foo/foo_1.0/changelog' foo.changelog
85'http://localhost:${APTHTTPPORT}/pool/main/f/foo/foo_1.0/changelog' foo.changelog" aptget changelog foo foo --print-uris
d56e2917 86testsuccess aptget changelog foo foo -qq
6fd4b4c0
DK
87testfileequal 'rootdir/tmp/testsuccess.output' "$(cat aptarchive/pool/main/f/foo/foo_1.0/changelog)
88$(cat aptarchive/pool/main/f/foo/foo_1.0/changelog)"
89testsuccess aptget changelog foo foo -d
90testfilestats 'foo.changelog' '%U:%G:%a' '=' "${TEST_DEFAULT_USER}:${TEST_DEFAULT_GROUP}:644"
91testfileequal 'foo.changelog' "$(cat aptarchive/pool/main/f/foo/foo_1.0/changelog)"
92# we have the file already, confused?
93testsuccess aptget changelog foo foo -d
94testfilestats 'foo.changelog' '%U:%G:%a' '=' "${TEST_DEFAULT_USER}:${TEST_DEFAULT_GROUP}:644"
95testfileequal 'foo.changelog' "$(cat aptarchive/pool/main/f/foo/foo_1.0/changelog)"
96echo 'bogus' > foo.changelog
872bd447 97touch -d 'now + 1 hour' foo.changelog
d56e2917
DK
98testsuccess aptget changelog foo foo -d
99testfilestats 'foo.changelog' '%U:%G:%a' '=' "${TEST_DEFAULT_USER}:${TEST_DEFAULT_GROUP}:644"
6fd4b4c0 100testfileequal 'foo.changelog' "$(cat aptarchive/pool/main/f/foo/foo_1.0/changelog)"
872bd447
DK
101echo -n 'bogus' > foo.changelog
102touch -d "$(stat -c%y aptarchive/pool/main/f/foo/foo_1.0/changelog)" foo.changelog
103testsuccess aptget changelog foo foo -d
104testfilestats 'foo.changelog' '%U:%G:%a' '=' "${TEST_DEFAULT_USER}:${TEST_DEFAULT_GROUP}:644"
105testequal 'bogus1.0) stable; urgency=low' head -n 1 foo.changelog
d56e2917 106rm -f foo.changelog
72dd5bec 107
430481e7 108# no @CHANGEPATH@ in the URI
3f760434
DK
109testequal 'E: Failed to fetch changelog:/foo.changelog Changelog unavailable for foo=1.0' \
110 aptget changelog foo -qq -d -o Acquire::Changelogs::URI::Label::Testcases="http://localhost:${APTHTTPPORT}/change.txt"
d56e2917 111testfailure test -e foo.changelog
13845042 112
3f760434
DK
113testequal "E: Failed to fetch http://localhost:${APTHTTPPORT}/does/not/exist/main/f/foo/foo_1.0/change.txt Changelog unavailable for foo=1.0 (404 Not Found)" \
114 aptget changelog foo -qq -d -o Acquire::Changelogs::URI::Label::Testcases="http://localhost:${APTHTTPPORT}/does/not/exist/@CHANGEPATH@/change.txt"
d56e2917 115testfailure test -e foo.changelog
b5aba909
DK
116
117testdpkgnotinstalled 'foo'
118testsuccessequal "'http://localhost:${APTHTTPPORT}/pool/main/f/foo/foo_1.0/changelog' foo.changelog" apt changelog foo --print-uris -o Acquire::Changelogs::AlwaysOnline=false
119testsuccessequal "'http://localhost:${APTHTTPPORT}/pool/main/f/foo/foo_1.0/changelog' foo.changelog" apt changelog foo --print-uris -o Acquire::Changelogs::AlwaysOnline=true
120
121testsuccess apt install dpkg -y
122# at this moment, we still have the Releasefile claim to be origin:ubuntu
123echo 'Acquire::Changelogs::AlwaysOnline::Origin::Ubuntu "false";' >> rootdir/etc/apt/apt.conf.d/nooriginchangelogs
124testsuccessequal "'http://localhost:${APTHTTPPORT}/pool/main/d/dpkg/dpkg_42/changelog' dpkg.changelog" apt changelog dpkg --print-uris
125testsuccessequal "'gzip:///usr/share/doc/dpkg/changelog.Debian.gz' dpkg.changelog" apt changelog dpkg --print-uris -o Acquire::Changelogs::AlwaysOnline=false
126testsuccessequal "'http://localhost:${APTHTTPPORT}/pool/main/d/dpkg/dpkg_42/changelog' dpkg.changelog" apt changelog dpkg --print-uris -o Acquire::Changelogs::AlwaysOnline=true
127testsuccessequal "'http://localhost:${APTHTTPPORT}/pool/main/d/dpkg/dpkg_42/changelog' dpkg.changelog" apt changelog dpkg --print-uris -o Acquire::Changelogs::AlwaysOnline=false -o Acquire::Changelogs::AlwaysOnline::Origin::Ubuntu=true
128testsuccessequal "'gzip:///usr/share/doc/dpkg/changelog.Debian.gz' dpkg.changelog" apt changelog dpkg --print-uris -o Acquire::Changelogs::AlwaysOnline=false -o Acquire::Changelogs::AlwaysOnline::Origin::Debian=true
129
b5aba909
DK
130testsuccess apt changelog dpkg -d
131testfilestats 'dpkg.changelog' '%U:%G:%a' '=' "${TEST_DEFAULT_USER}:${TEST_DEFAULT_GROUP}:644"
132head -n 3 dpkg.changelog > dpkg.change
133testfileequal 'dpkg.change' "$(apthelper cat-file '/usr/share/doc/dpkg/changelog.Debian.gz' | head -n 3)"
134rm -f dpkg.change dpkg.changelog