]> git.saurik.com Git - apt.git/blame - test/integration/test-apt-ftparchive-src-cachedb
rename Calculate- to GetIndexTargets and use it as official API
[apt.git] / test / integration / test-apt-ftparchive-src-cachedb
CommitLineData
ce928105
MV
1#!/bin/sh
2set -e
3
4assert_correct_sources_file() {
25b86db1 5 testsuccessequal "Package: bar
e8fb1cdf
DK
6Format: 3.0 (native)
7Binary: bar
ce928105 8Architecture: all
4f6d26b4 9Version: 1.0
ce928105 10Directory: pool/main
e8fb1cdf
DK
11Package-List:
12 bar deb admin extra
ce928105
MV
13Files:
14 7b57dd065e51de5905288a5104d4bef5 406 bar_1.0.dsc
15 d41d8cd98f00b204e9800998ecf8427e 0 bar_1.0.tar.gz
ce928105
MV
16Checksums-Sha1:
17 17a40b76715f393ab7fd6485c9392a02f1adf903 406 bar_1.0.dsc
18 da39a3ee5e6b4b0d3255bfef95601890afd80709 0 bar_1.0.tar.gz
19Checksums-Sha256:
20 d9d7507f66a89258b6920aca47747d7a30e0e64b09ecabbf02b2efbdabf840a9 406 bar_1.0.dsc
21 e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 0 bar_1.0.tar.gz
22Checksums-Sha512:
23 ee0a9bfb6614159b45203fc29487d4f37387993ca0e6d6f27b80010498f3731d75753188ece307508ae9af0259bd11a6af15a1a38f0b87dbd5ea1273b7a7d53e 406 bar_1.0.dsc
24 cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e 0 bar_1.0.tar.gz
25
26Package: foo
e8fb1cdf
DK
27Format: 3.0 (native)
28Binary: foo
ce928105 29Architecture: all
4f6d26b4 30Version: 1.0
ce928105 31Directory: pool/main
e8fb1cdf
DK
32Package-List:
33 foo deb admin extra
ce928105
MV
34Files:
35 d144826e6f02831c1933e910c92cd7e0 171 foo_1.0.dsc
36 d41d8cd98f00b204e9800998ecf8427e 0 foo_1.0.tar.gz
ce928105
MV
37Checksums-Sha1:
38 979306aa3ccff3d61bba062bb6977e2493c6f907 171 foo_1.0.dsc
39 da39a3ee5e6b4b0d3255bfef95601890afd80709 0 foo_1.0.tar.gz
40Checksums-Sha256:
41 8c780af8b5a6d5b3c2e2f9518940beebea52ac6d6ad7b52c082dc925cfe5b532 171 foo_1.0.dsc
42 e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 0 foo_1.0.tar.gz
43Checksums-Sha512:
44 3da0240fd764657c2f3661b4d750578a9a99b0580591b133756379d48117ebda87a5ed2467f513200d6e7eaf51422cbe91c15720eef7fb4bba2cc8ff81ebc547 171 foo_1.0.dsc
45 cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e 0 foo_1.0.tar.gz
e8fb1cdf 46" aptsortpkgs ./aptarchive/dists/test/main/source/Sources -o APT::SortPkgs::Source=true
ce928105
MV
47}
48
49create_source_files() {
50 NAME="$1"
51 REQUEST_CLEARSIGN="$2"
52
53 TARFILE="aptarchive/pool/main/${NAME}_1.0.tar.gz"
54 DSC_FILE="aptarchive/pool/main/${NAME}_1.0.dsc"
55 touch $TARFILE
56 if [ "$REQUEST_CLEARSIGN" = "CLEARSIGN" ]; then
57 printf -- "-----BEGIN PGP SIGNED MESSAGE-----\n\n" > $DSC_FILE
58 fi
59 cat >> $DSC_FILE << EOF
60Format: 3.0 (native)
61Source: $NAME
62Binary: $NAME
63Architecture: all
64Version: 1.0
65Package-List:
66 $NAME deb admin extra
67Files:
68 $(md5sum $TARFILE|cut -f1 -d' ') $(stat --print="%s" $TARFILE) ${NAME}_1.0.tar.gz
69EOF
70 if [ "$REQUEST_CLEARSIGN" = "CLEARSIGN" ]; then
71 cat >> $DSC_FILE <<EOF
72
73-----BEGIN PGP SIGNATURE-----
74Version: GnuPG v1.4.11 (GNU/Linux)
75
76iEYEARECAAYFAk3k/VoACgkQliSD4VZixzQxlgCgpav7j68z48qNTDFuT9fLqwT5
77DFwAoIXatJFENEC371bMKTkUKlwZxQEk
78=iI9V
79-----END PGP SIGNATURE-----
80EOF
81 fi
82}
83
84create_clearsigned_source_files() {
85 NAME="$1"
86 create_source_files "$NAME" "CLEARSIGN"
87}
88
89#
90# main()
91#
92TESTDIR=$(readlink -f $(dirname $0))
93. $TESTDIR/framework
94setupenvironment
95configarchitecture "i386"
96
97msgtest 'Test apt-ftparchive source with missing hashes in .dsc'
98
99mkdir -p aptarchive/pool/main
100create_source_files foo
101create_clearsigned_source_files bar
102
103mkdir -p aptarchive/dists/test/main/i18n/
104mkdir -p aptarchive/dists/test/main/source/
105
106mkdir aptarchive-overrides
107mkdir aptarchive-cache
cf6bbca0 108
d9e518c6
DK
109msgtest 'generate with --db option'
110cd aptarchive
111aptftparchive --db ./test.db sources pool/main/ -q=0 -o APT::FTPArchive::ShowCacheMisses=1 > dists/test/main/source/Sources 2>stats-out.txt && msgpass || msgfail
112testsuccess grep Misses stats-out.txt
113testfileequal '../rootdir/tmp/testsuccess.output' ' Misses in Cache: 2'
114cd ..
cf6bbca0
MV
115assert_correct_sources_file
116
d9e518c6
DK
117msgtest 'generate with --db option (again to ensure its in the cache)'
118cd aptarchive
119aptftparchive --db ./test.db sources pool/main/ -q=0 -o APT::FTPArchive::ShowCacheMisses=1 > dists/test/main/source/Sources 2>stats-out.txt && msgpass || msgfail
120testsuccess grep Misses stats-out.txt
121testfileequal '../rootdir/tmp/testsuccess.output' ' Misses in Cache: 0'
122cd ..
cf6bbca0
MV
123assert_correct_sources_file
124
cf6bbca0 125# get ready for the "apt-ftparchive generate" command
ce928105
MV
126cat > apt-ftparchive.conf <<"EOF"
127Dir {
128 ArchiveDir "./aptarchive";
129 OverrideDir "./aptarchive-overrides";
130 CacheDir "./aptarchive-cache";
131};
132
133Default {
134 Packages::Compress ". gzip bzip2";
135 Contents::Compress ". gzip bzip2";
136 LongDescription "false";
137};
138
139TreeDefault {
140 BinCacheDB "packages-$(SECTION)-$(ARCH).db";
141 SrcCacheDB "sources-$(SECTION).db";
142
143 Directory "pool/$(SECTION)";
144 SrcDirectory "pool/$(SECTION)";
145
ce928105 146 Sources "$(DIST)/$(SECTION)/source/Sources";
ce928105
MV
147};
148
149Tree "dists/test" {
150 Sections "main";
151 Architectures "source";
152
153};
154EOF
155
d9e518c6
DK
156msgtest 'generate (empty cachedb)'
157testsuccess aptftparchive generate apt-ftparchive.conf -q=0 -o APT::FTPArchive::ShowCacheMisses=1
158cp rootdir/tmp/testsuccess.output stats-out.txt
159testsuccess grep Misses stats-out.txt
160testfileequal rootdir/tmp/testsuccess.output ' Misses in Cache: 2'
ce928105
MV
161assert_correct_sources_file
162
d9e518c6 163msgtest 'generate again out of the cache'
ce928105 164rm -f ./aptarchive/dists/test/main/source/Sources
d9e518c6
DK
165testsuccess aptftparchive generate apt-ftparchive.conf -q=0 -o APT::FTPArchive::ShowCacheMisses=1
166cp rootdir/tmp/testsuccess.output stats-out.txt
167testsuccess grep Misses stats-out.txt
168testfileequal rootdir/tmp/testsuccess.output ' Misses in Cache: 0'
ce928105
MV
169assert_correct_sources_file
170
171# generate invalid files
172mkdir aptarchive/pool/invalid
173printf "meep" > aptarchive/pool/invalid/invalid_1.0.dsc
174testequal "
8710a36a
DK
175E: Could not find a record in the DSC 'aptarchive/pool/invalid/invalid_1.0.dsc'" aptftparchive sources aptarchive/pool/invalid
176rm -f aptarchive/pool/invalid/invalid_1.0.dsc
177
178printf "meep: yes" > aptarchive/pool/invalid/invalid_1.0.dsc
179testequal "
ce928105
MV
180E: Could not find a Source entry in the DSC 'aptarchive/pool/invalid/invalid_1.0.dsc'" aptftparchive sources aptarchive/pool/invalid
181rm -f aptarchive/pool/invalid/invalid_1.0.dsc
182
53ba4e2c
MV
183# ensure clean works
184rm -f aptarchive/pool/main/*
d9e518c6
DK
185testsuccess aptftparchive clean apt-ftparchive.conf -q=0 -o Debug::APT::FTPArchive::Clean=1
186cp rootdir/tmp/testsuccess.output clean-out.txt
187testsuccess grep unique clean-out.txt
188testfileequal 'rootdir/tmp/testsuccess.output' "0 Number of unique keys in the tree"
189testsuccess grep sources-main.db clean-out.txt
190testfileequal 'rootdir/tmp/testsuccess.output' "sources-main.db"