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