]> git.saurik.com Git - apt.git/blame - test/integration/test-apt-ftparchive-by-hash
add --sha512 option + documentation for apt-ftparchive
[apt.git] / test / integration / test-apt-ftparchive-by-hash
CommitLineData
7852873a
MV
1#!/bin/sh
2set -e
3
4verify_by_hash() {
5 for hash_gen in SHA1:sha1sum SHA256:sha256sum SHA512:sha512sum; do
6 hash=$(echo ${hash_gen} | cut -f1 -d:)
7 gen=$(echo ${hash_gen} | cut -f2 -d:)
8 testsuccess stat aptarchive/dists/unstable/main/binary-i386/by-hash/$hash/$($gen aptarchive/dists/unstable/main/binary-i386/Packages | cut -f1 -d' ')
9 testsuccess stat aptarchive/dists/unstable/main/binary-i386/by-hash/$hash/$($gen aptarchive/dists/unstable/main/binary-i386/Packages.gz | cut -f1 -d' ')
10 done
11}
12
13#
14# main()
15#
16TESTDIR=$(readlink -f $(dirname $0))
17. $TESTDIR/framework
18setupenvironment
19configarchitecture 'i386'
20configcompression 'gz' '.'
21
e8e52cd0
MV
22# enable by-hash in apt-ftparchive
23echo 'APT::FTPArchive::DoByHash "1";' >> aptconfig.conf
24
7852873a
MV
25# build one pacakge
26buildsimplenativepackage 'foo' 'i386' '1' 'unstable'
27buildaptarchivefromincoming
28
29# verify initial run
30verify_by_hash
31previous_hash=$(sha256sum aptarchive/dists/unstable/main/binary-i386/Packages | cut -f1 -d' ')
32
33# insert new package
34buildsimplenativepackage 'bar' 'i386' '1' 'unstable'
35# and build again
36buildaptarchivefromincoming
37
38# ensure the new package packag is there
39testsuccess zgrep "Package: bar" aptarchive/dists/unstable/main/binary-i386/Packages.gz
40
41# ensure we have the by-hash stuff
42verify_by_hash
43
44# ensure the old hash is still there
45testsuccess stat aptarchive/dists/unstable/main/binary-i386/by-hash/SHA256/$previous_hash
46
47# ensure we have it in the Release file
48testsuccess grep "Acquire-By-Hash: true" aptarchive/dists/unstable/*Release
49
50# now ensure gc work
51for i in $(seq 3); do
52 buildsimplenativepackage 'bar' 'i386' "$i" 'unstable'
53 buildaptarchivefromincoming
54done
55
56hash_count=$(ls aptarchive/dists/unstable/main/binary-i386/by-hash/SHA256/|wc -l)
57# we have 2 files (uncompressed, gz) per run, 5 runs in total
58# by default apt-ftparchive keeps three generations (current plus 2 older)
59msgtest "Check that gc for by-hash works… "
60if [ "$hash_count" = "6" ]; then
61 msgpass
62else
63 echo "Got $hash_count expected 6"
64 msgfail
65fi
66
67# ensure the current generation is still there
68verify_by_hash
69