]> git.saurik.com Git - apt.git/blob - test/integration/test-apt-by-hash-update
ensure FileFd doesn't try to open /dev/null as atomic and co
[apt.git] / test / integration / test-apt-by-hash-update
1 #!/bin/sh
2 set -e
3
4 TESTDIR=$(readlink -f $(dirname $0))
5 . $TESTDIR/framework
6
7 setupenvironment
8 configarchitecture 'i386'
9 confighashes 'SHA512'
10 configcompression '.' 'gz'
11
12 insertpackage 'unstable' 'foo' 'all' '1.0'
13 insertpackage 'unstable' 'bar' 'i386' '1.0'
14
15 setupaptarchive --no-update
16
17 # make Packages *only* accessible by-hash for this test
18 makebyhashonly() {
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 }
25 makebyhashonly 'binary-i386' 'Packages'
26 makebyhashonly 'binary-all' 'Packages'
27 makebyhashonly 'source' 'Sources'
28
29 ensureitsbroken() {
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...
35 Building dependency tree...
36 E: Unable to locate package foo" aptget install -q -s foo
37 }
38 ensureitsbroken
39 ensureitsbroken -o Acquire::By-Hash=1
40
41 ensureitworks() {
42 rm -rf rootdir/var/lib/apt/lists
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
49 testsuccessequal "Inst foo (1.0 unstable [all])
50 Conf foo (1.0 unstable [all])" aptget install -qq -s foo
51 testsuccessequal "Inst bar (1.0 unstable [i386])
52 Conf bar (1.0 unstable [i386])" aptget install -qq -s bar
53 }
54 msgmsg 'Test by-hash via' 'config option'
55 ensureitworks -o Acquire::By-Hash=force
56
57 msgmsg 'Test by-hash via' 'release option'
58 cp -a aptarchive/dists aptarchive/dists.bak
59 # add magic string to Release file ...
60 sed -i '/^Suite: / a \
61 Acquire-By-Hash: yes' aptarchive/dists/unstable/Release
62 signreleasefiles
63 ensureitworks
64 ensureitsbroken -o Acquire::By-Hash=0
65
66 msgmsg 'Test by-hash via' 'sources option'
67 sed -i "s#^\(deb\(-src\)\?\) #\1 [by-hash=yes] #" rootdir/etc/apt/sources.list.d/*
68 ensureitworks
69 #ensureitsbroken -o Acquire::By-Hash=0
70
71 rm -rf aptarchive/dists
72 cp -a aptarchive/dists.bak aptarchive/dists
73 #ensureitworks -o Acquire::By-Hash=force
74 ensureitsbroken -o Acquire::By-Hash=1
75 ensureitsbroken -o Acquire::By-Hash=0
76
77 sed -i "s#^\(deb\(-src\)\?\) \[by-hash=yes\] #\1 [by-hash=force] #" rootdir/etc/apt/sources.list.d/*
78 ensureitworks
79 #ensureitsbroken -o Acquire::By-Hash=0