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