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