]> git.saurik.com Git - apt.git/blame - test/integration/test-apt-ftparchive-cachedb
Merge EDSP 0.5 w/ multi-arch support for external solvers
[apt.git] / test / integration / test-apt-ftparchive-cachedb
CommitLineData
0a3b93fc
MV
1#!/bin/sh
2set -e
3
4ensure_correct_packages_file() {
5 testequal "Package: foo
6Priority: optional
7Section: others
a6fd378a 8$(dpkg-deb -I ./aptarchive/pool/main/foo_1_i386.deb | grep 'Installed-Size:' | sed 's#^ ##')
0a3b93fc
MV
9Maintainer: Joe Sixpack <joe@example.org>
10Architecture: i386
11Version: 1
12Filename: pool/main/foo_1_i386.deb" head -n8 ./aptarchive/dists/test/main/binary-i386/Packages
13}
14
15ensure_correct_contents_file() {
16 testequal "usr/bin/foo-i386 others/foo
17usr/share/doc/foo/FEATURES others/foo
18usr/share/doc/foo/changelog others/foo
19usr/share/doc/foo/copyright others/foo" cat ./aptarchive/dists/test/Contents-i386
20}
21
22#
23# main()
24#
25TESTDIR=$(readlink -f $(dirname $0))
26. $TESTDIR/framework
27setupenvironment
a6fd378a 28configarchitecture 'i386'
0a3b93fc
MV
29
30mkdir -p aptarchive/dists/test/main/i18n/
31mkdir -p aptarchive/dists/test/main/source/
32mkdir -p aptarchive/dists/test/main/binary-i386
33mkdir -p aptarchive/pool/main
34
35mkdir aptarchive-overrides
36mkdir aptarchive-cache
37cat > ftparchive.conf <<"EOF"
38Dir {
39 ArchiveDir "./aptarchive";
40 OverrideDir "./aptarchive-overrides";
41 CacheDir "./aptarchive-cache";
42};
43
44Default {
45 Packages::Compress ". gzip bzip2";
46 Contents::Compress ". gzip bzip2";
47 LongDescription "false";
48};
49
50TreeDefault {
51 BinCacheDB "packages-$(SECTION)-$(ARCH).db";
52
53 Directory "pool/$(SECTION)";
54 SrcDirectory "pool/$(SECTION)";
55
56 Packages "$(DIST)/$(SECTION)/binary-$(ARCH)/Packages";
57 Contents "$(DIST)/Contents-$(ARCH)";
58};
59
60Tree "dists/test" {
61 Sections "main";
62 Architectures "i386";
63
64};
65EOF
66
67# build one pacakge
68buildsimplenativepackage 'foo' 'i386' '1' 'test'
69mv incoming/* aptarchive/pool/main/
70
71# generate (empty cachedb)
72aptftparchive generate ftparchive.conf -o APT::FTPArchive::ShowCacheMisses=1 2> stats-out.txt
73ensure_correct_packages_file
74ensure_correct_contents_file
75testequal " Misses in Cache: 2
76 dists/test/Contents-i386: New 402 B Misses in Cache: 0" grep Misses stats-out.txt
77
78# generate again
79aptftparchive generate ftparchive.conf -o APT::FTPArchive::ShowCacheMisses=1 2> stats-out.txt
80ensure_correct_packages_file
81ensure_correct_contents_file
82testequal " Misses in Cache: 0
83 dists/test/Contents-i386: Misses in Cache: 0" grep Misses stats-out.txt
84
85# and again (with removing the Packages file)
86rm -f ./aptarchive/dists/test/main/binary-i386/*
87rm -f ./aptarchive/dists/test/Contents-i386
88aptftparchive generate ftparchive.conf -o APT::FTPArchive::ShowCacheMisses=1 2> stats-out.txt
89ensure_correct_packages_file
90ensure_correct_contents_file
91testequal " Misses in Cache: 0
92 dists/test/Contents-i386: New 402 B Misses in Cache: 0" grep Misses stats-out.txt
93
53ba4e2c
MV
94# and clean
95rm -rf aptarchive/pool/main/*
96testequal "packages-main-i386.db" aptftparchive clean ftparchive.conf
97aptftparchive clean ftparchive.conf -o Debug::APT::FTPArchive::Clean=1 > clean-out.txt 2>&1
98testequal "0 Number of unique keys in the tree" grep unique clean-out.txt
99testequal "packages-main-i386.db" grep packages-main-i386.db clean-out.txt
100