4 assert_correct_sources_file
() {
5 testequal
"Package: bar
12 7b57dd065e51de5905288a5104d4bef5 406 bar_1.0.dsc
13 d41d8cd98f00b204e9800998ecf8427e 0 bar_1.0.tar.gz
17 17a40b76715f393ab7fd6485c9392a02f1adf903 406 bar_1.0.dsc
18 da39a3ee5e6b4b0d3255bfef95601890afd80709 0 bar_1.0.tar.gz
20 d9d7507f66a89258b6920aca47747d7a30e0e64b09ecabbf02b2efbdabf840a9 406 bar_1.0.dsc
21 e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 0 bar_1.0.tar.gz
23 ee0a9bfb6614159b45203fc29487d4f37387993ca0e6d6f27b80010498f3731d75753188ece307508ae9af0259bd11a6af15a1a38f0b87dbd5ea1273b7a7d53e 406 bar_1.0.dsc
24 cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e 0 bar_1.0.tar.gz
33 d144826e6f02831c1933e910c92cd7e0 171 foo_1.0.dsc
34 d41d8cd98f00b204e9800998ecf8427e 0 foo_1.0.tar.gz
38 979306aa3ccff3d61bba062bb6977e2493c6f907 171 foo_1.0.dsc
39 da39a3ee5e6b4b0d3255bfef95601890afd80709 0 foo_1.0.tar.gz
41 8c780af8b5a6d5b3c2e2f9518940beebea52ac6d6ad7b52c082dc925cfe5b532 171 foo_1.0.dsc
42 e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 0 foo_1.0.tar.gz
44 3da0240fd764657c2f3661b4d750578a9a99b0580591b133756379d48117ebda87a5ed2467f513200d6e7eaf51422cbe91c15720eef7fb4bba2cc8ff81ebc547 171 foo_1.0.dsc
45 cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e 0 foo_1.0.tar.gz
46 " aptsortpkgs .
/aptarchive
/dists
/test
/main
/source
/Sources
49 create_source_files
() {
51 REQUEST_CLEARSIGN
="$2"
53 TARFILE
="aptarchive/pool/main/${NAME}_1.0.tar.gz"
54 DSC_FILE
="aptarchive/pool/main/${NAME}_1.0.dsc"
56 if [ "$REQUEST_CLEARSIGN" = "CLEARSIGN" ]; then
57 printf -- "-----BEGIN PGP SIGNED MESSAGE-----\n\n" > $DSC_FILE
59 cat >> $DSC_FILE << EOF
68 $(md5sum $TARFILE|cut -f1 -d' ') $(stat --print="%s" $TARFILE) ${NAME}_1.0.tar.gz
70 if [ "$REQUEST_CLEARSIGN" = "CLEARSIGN" ]; then
71 cat >> $DSC_FILE <<EOF
73 -----BEGIN PGP SIGNATURE-----
74 Version: GnuPG v1.4.11 (GNU/Linux)
76 iEYEARECAAYFAk3k/VoACgkQliSD4VZixzQxlgCgpav7j68z48qNTDFuT9fLqwT5
77 DFwAoIXatJFENEC371bMKTkUKlwZxQEk
79 -----END PGP SIGNATURE-----
84 create_clearsigned_source_files
() {
86 create_source_files
"$NAME" "CLEARSIGN"
92 TESTDIR
=$(readlink -f $(dirname $0))
95 configarchitecture
"i386"
97 msgtest
'Test apt-ftparchive source with missing hashes in .dsc'
99 mkdir -p aptarchive
/pool
/main
100 create_source_files foo
101 create_clearsigned_source_files bar
103 mkdir -p aptarchive
/dists
/test
/main
/i
18n
/
104 mkdir -p aptarchive
/dists
/test
/main
/source
/
106 mkdir aptarchive
-overrides
107 mkdir aptarchive
-cache
111 # generate with --db option
112 (cd aptarchive
&& aptftparchive
--db .
/test.db sources pool
/main
/ \
113 -o APT
::FTPArchive
::ShowCacheMisses
=1 \
114 > dists
/test
/main
/source
/Sources \
116 testequal
" Misses in Cache: 2" grep Misses stats
-out.txt
118 assert_correct_sources_file
120 # generate with --db option (again to ensure its in the cache)
121 (cd aptarchive
&& aptftparchive
--db .
/test.db sources pool
/main
/ \
122 -o APT
::FTPArchive
::ShowCacheMisses
=1 \
123 > dists
/test
/main
/source
/Sources \
125 testequal
" Misses in Cache: 0" grep Misses stats
-out.txt
127 assert_correct_sources_file
131 # get ready for the "apt-ftparchive generate" command
132 cat > apt
-ftparchive.conf
<<"EOF"
134 ArchiveDir "./aptarchive";
135 OverrideDir "./aptarchive-overrides";
136 CacheDir "./aptarchive-cache";
140 Packages::Compress ". gzip bzip2";
141 Contents::Compress ". gzip bzip2";
142 LongDescription "false";
146 BinCacheDB "packages-$(SECTION)-$(ARCH).db";
147 SrcCacheDB "sources-$(SECTION).db";
149 Directory "pool/$(SECTION)";
150 SrcDirectory "pool/$(SECTION)";
152 Sources "$(DIST)/$(SECTION)/source/Sources";
157 Architectures "source";
162 # generate (empty cachedb)
163 aptftparchive generate apt-ftparchive.conf -o APT::FTPArchive::ShowCacheMisses=1 2> stats-out.txt
164 testequal " Misses in Cache: 2" grep Misses stats-out.txt
165 assert_correct_sources_file
168 # generate again out of the cache
169 rm -f ./aptarchive/dists/test/main/source/Sources
170 aptftparchive generate apt-ftparchive.conf -o APT::FTPArchive::ShowCacheMisses=1 2> stats-out.txt
171 testequal " Misses in Cache: 0" grep Misses stats-out.txt
172 assert_correct_sources_file
176 # generate invalid files
177 mkdir aptarchive/pool/invalid
178 printf "meep" > aptarchive/pool/invalid/invalid_1.0.dsc
180 E: Could not find a record in the DSC 'aptarchive/pool/invalid/invalid_1.0.dsc'" aptftparchive sources aptarchive/pool/invalid
181 rm -f aptarchive/pool/invalid/invalid_1.0.dsc
183 printf "meep: yes" > aptarchive/pool/invalid/invalid_1.0.dsc
185 E: Could not find a Source entry in the DSC 'aptarchive/pool/invalid/invalid_1.0.dsc'" aptftparchive sources aptarchive/pool/invalid
186 rm -f aptarchive/pool/invalid/invalid_1.0.dsc
188 dd if=/dev/zero of="aptarchive/pool/invalid/toobig_1.0.dsc" bs=1k count=129 2>/dev/null
190 E: DSC file 'aptarchive/pool/invalid/toobig_1.0.dsc' is too large!" aptftparchive sources aptarchive/pool/invalid
193 rm -f aptarchive/pool/main/*
194 aptftparchive clean apt-ftparchive.conf -o Debug::APT::FTPArchive::Clean=1 > clean-out.txt 2>&1
195 testequal "0 Number of unique keys in the tree" grep unique clean-out.txt
196 testequal "sources-main.db" grep sources-main.db clean-out.txt