]> git.saurik.com Git - apt.git/blame - test/integration/test-apt-ftparchive-by-hash
Ensure that no by-hash file for "Release/InRelease is written"
[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
22# build one pacakge
23buildsimplenativepackage 'foo' 'i386' '1' 'unstable'
24buildaptarchivefromincoming
25
26# verify initial run
27verify_by_hash
28previous_hash=$(sha256sum aptarchive/dists/unstable/main/binary-i386/Packages | cut -f1 -d' ')
29
30# insert new package
31buildsimplenativepackage 'bar' 'i386' '1' 'unstable'
32# and build again
33buildaptarchivefromincoming
34
35# ensure the new package packag is there
36testsuccess zgrep "Package: bar" aptarchive/dists/unstable/main/binary-i386/Packages.gz
37
38# ensure we have the by-hash stuff
39verify_by_hash
40
41# ensure the old hash is still there
42testsuccess stat aptarchive/dists/unstable/main/binary-i386/by-hash/SHA256/$previous_hash
43
44# ensure we have it in the Release file
45testsuccess grep "Acquire-By-Hash: true" aptarchive/dists/unstable/*Release
46
47# now ensure gc work
48for i in $(seq 3); do
49 buildsimplenativepackage 'bar' 'i386' "$i" 'unstable'
50 buildaptarchivefromincoming
51done
52
53hash_count=$(ls aptarchive/dists/unstable/main/binary-i386/by-hash/SHA256/|wc -l)
54# we have 2 files (uncompressed, gz) per run, 5 runs in total
55# by default apt-ftparchive keeps three generations (current plus 2 older)
56msgtest "Check that gc for by-hash works… "
57if [ "$hash_count" = "6" ]; then
58 msgpass
59else
60 echo "Got $hash_count expected 6"
61 msgfail
62fi
63
64# ensure the current generation is still there
65verify_by_hash
66