]> git.saurik.com Git - apt.git/blob - test/integration/test-apt-by-hash-update
c00ab497b71701175c36815bd9eaf31ee7023193
[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
14 setupaptarchive --no-update
15
16 # make Packages *only* accessible by-hash for this test
17 mkdir -p aptarchive/dists/unstable/main/binary-i386/by-hash/SHA512
18 (cd aptarchive/dists/unstable/main/binary-i386/by-hash/SHA512 &&
19 mv ../../Packages* . &&
20 ln -s Packages.gz $(sha512sum Packages.gz|cut -f1 -d' ') )
21
22 # add sources
23 mkdir -p aptarchive/dists/unstable/main/source/by-hash/SHA512
24 (cd aptarchive/dists/unstable/main/source/by-hash/SHA512 &&
25 ln -s ../../Sources.gz $(sha512sum ../../Sources.gz|cut -f1 -d' ')
26 )
27
28 ensureitsbroken() {
29 rm -rf rootdir/var/lib/apt/lists
30 # we moved the Packages file away, normal update won't work
31 testfailure aptget update "$@"
32 # ensure we do not know about "foo"
33 testfailureequal "Reading package lists...
34 Building dependency tree...
35 E: Unable to locate package foo" aptget install -q -s foo
36 }
37 ensureitsbroken
38 ensureitsbroken -o Acquire::By-Hash=1
39
40 ensureitworks() {
41 rm -rf rootdir/var/lib/apt/lists
42 testsuccess aptget update -o Acquire::Languages=none "$@"
43 testsuccessequal "Inst foo (1.0 unstable [all])
44 Conf foo (1.0 unstable [all])" aptget install -qq -s foo
45 }
46 msgmsg 'Test by-hash via' 'config option'
47 ensureitworks -o Acquire::By-Hash=force
48
49 msgmsg 'Test by-hash via' 'release option'
50 cp -a aptarchive/dists aptarchive/dists.bak
51 # add magic string to Release file ...
52 sed -i '/^Suite: / a \
53 Acquire-By-Hash: yes' aptarchive/dists/unstable/Release
54 signreleasefiles
55 ensureitworks
56 ensureitsbroken -o Acquire::By-Hash=0
57
58 msgmsg 'Test by-hash via' 'sources option'
59 sed -i "s#^\(deb\(-src\)\?\) #\1 [by-hash=yes] #" rootdir/etc/apt/sources.list.d/*
60 ensureitworks
61 #ensureitsbroken -o Acquire::By-Hash=0
62
63 rm -rf aptarchive/dists
64 cp -a aptarchive/dists.bak aptarchive/dists
65 #ensureitworks -o Acquire::By-Hash=force
66 ensureitsbroken -o Acquire::By-Hash=1
67 ensureitsbroken -o Acquire::By-Hash=0
68
69 sed -i "s#^\(deb\(-src\)\?\) \[by-hash=yes\] #\1 [by-hash=force] #" rootdir/etc/apt/sources.list.d/*
70 ensureitworks
71 #ensureitsbroken -o Acquire::By-Hash=0