]> git.saurik.com Git - apt.git/blame_incremental - test/integration/test-apt-by-hash-update
fallback to well-known URI if by-hash fails
[apt.git] / test / integration / test-apt-by-hash-update
... / ...
CommitLineData
1#!/bin/sh
2set -e
3
4TESTDIR=$(readlink -f $(dirname $0))
5. $TESTDIR/framework
6
7setupenvironment
8configarchitecture 'i386'
9confighashes 'SHA512'
10configcompression '.' 'gz'
11
12insertpackage 'unstable' 'foo' 'all' '1.0'
13
14setupaptarchive --no-update
15
16# make Packages *only* accessible by-hash for this test
17makebyhashonly() {
18 local NORMAL="$(readlink -f "./aptarchive/dists/unstable/main/${1}")"
19 local BYHASH="${NORMAL}/by-hash/SHA512"
20 mkdir -p "${BYHASH}"
21 find "${NORMAL}/" -maxdepth 1 -name "${2}*" -exec mv '{}' "$BYHASH" \;
22 ln -s "${BYHASH}/${2}.gz" "${BYHASH}/$(sha512sum "${BYHASH}/${2}.gz" | cut -f1 -d' ')"
23}
24makebyhashonly 'binary-i386' 'Packages'
25makebyhashonly 'source' 'Sources'
26
27ensureitsbroken() {
28 rm -rf rootdir/var/lib/apt/lists
29 # we moved the Packages file away, normal update won't work
30 testfailure aptget update "$@"
31 # ensure we do not know about "foo"
32 testfailureequal "Reading package lists...
33Building dependency tree...
34E: Unable to locate package foo" aptget install -q -s foo
35}
36ensureitsbroken
37ensureitsbroken -o Acquire::By-Hash=1
38
39ensureitworks() {
40 rm -rf rootdir/var/lib/apt/lists
41 testsuccess aptget update "$@" -o Acquire::Languages=none
42 testfailure grep '^Ign' rootdir/tmp/testsuccess.output
43 rm -rf rootdir/var/lib/apt/lists
44 testsuccess aptget update "$@"
45 cp -f rootdir/tmp/testsuccess.output rootdir/tmp/aptupdate.output
46 testsuccess grep '^Ign' rootdir/tmp/aptupdate.output
47 testsuccessequal "Inst foo (1.0 unstable [all])
48Conf foo (1.0 unstable [all])" aptget install -qq -s foo
49}
50msgmsg 'Test by-hash via' 'config option'
51ensureitworks -o Acquire::By-Hash=force
52
53msgmsg 'Test by-hash via' 'release option'
54cp -a aptarchive/dists aptarchive/dists.bak
55# add magic string to Release file ...
56sed -i '/^Suite: / a \
57Acquire-By-Hash: yes' aptarchive/dists/unstable/Release
58signreleasefiles
59ensureitworks
60ensureitsbroken -o Acquire::By-Hash=0
61
62msgmsg 'Test by-hash via' 'sources option'
63sed -i "s#^\(deb\(-src\)\?\) #\1 [by-hash=yes] #" rootdir/etc/apt/sources.list.d/*
64ensureitworks
65#ensureitsbroken -o Acquire::By-Hash=0
66
67rm -rf aptarchive/dists
68cp -a aptarchive/dists.bak aptarchive/dists
69#ensureitworks -o Acquire::By-Hash=force
70ensureitsbroken -o Acquire::By-Hash=1
71ensureitsbroken -o Acquire::By-Hash=0
72
73sed -i "s#^\(deb\(-src\)\?\) \[by-hash=yes\] #\1 [by-hash=force] #" rootdir/etc/apt/sources.list.d/*
74ensureitworks
75#ensureitsbroken -o Acquire::By-Hash=0