set -u . "$TESTSDIR"/test.inc # First test if finding the binaries works properly... testrun - --lunzip=NONE --unxz=NONE __dumpuncompressors 3< testfile dd if=/dev/zero bs=1024 count=1024 >> testfile echo "" >> testfile echo "middle" >> testfile dd if=/dev/zero bs=1024 count=1024 >> testfile echo "" >> testfile echo "end" >> testfile echo "Ohm" > smallfile echo gzip -c testfile \> testfile.gz gzip -c testfile > testfile.gz echo bzip2 -c testfile \> testfile.bz2 bzip2 -c testfile > testfile.bz2 echo lzma -c testfile \> testfile.lzma lzma -c testfile > testfile.lzma echo xz -c testfile \> testfile.xz xz -c testfile > testfile.xz echo gzip -c smallfile \> smallfile.gz gzip -c smallfile > smallfile.gz echo bzip2 -c smallfile \> smallfile.bz2 bzip2 -c smallfile > smallfile.bz2 echo lzma -c smallfile \> smallfile.lzma lzma -c smallfile > smallfile.lzma echo xz -c smallfile \> smallfile.xz xz -c smallfile > smallfile.xz echo gzip -c \< /dev/null \> emptyfile.gz gzip -c < /dev/null > emptyfile.gz echo bzip2 -c \< /dev/null \> emptyfile.bz2 bzip2 -c < /dev/null > emptyfile.bz2 echo lzma -c \< /dev/null \> emptyfile.lzma lzma -c < /dev/null > emptyfile.lzma echo xz -c \< /dev/null \> emptyfile.xz xz -c < /dev/null > emptyfile.xz testrun - --lunzip /bin/cat __uncompress .lz notexists.lz notexists.lz.uncompressed 3< testfile.lz lzip -c testfile > testfile.lz echo lzip -c smallfile \> smallfile.lz lzip -c smallfile > smallfile.lz testrun - __uncompress .lz testfile.lz testfile.lz.uncompressed 3< concatenatedtestfile.${ext} testrun - __uncompress .${ext} concatenatedtestfile.${ext} concatenatedtestfile.${ext}.uncompressed 3< concatenatedtestfile cat testfile.${ext} testfile.${ext} > concatenatedtestfile.${ext} testrun - __uncompress .${ext} concatenatedtestfile.${ext} concatenatedtestfile.${ext}.uncompressed 3< invalidtestfile.${ext} testrun - __uncompress .${ext} invalidtestfile.${ext} invalidtestfile.${ext}.uncompressed 3< invalidtestfile.xz testrun - __uncompress .xz invalidtestfile.xz invalidtestfile.xz.uncompressed 3< fake.lz.uncompressed exited with errorcode 1! -v0*=There have been errors! returns 255 EOF dodo test ! -e fake.lz.uncompressed # Now check for compressed parts of an .a file: cat > control < control.tar.bz2 tar -cf - ./control | bzip2 > control.tar.bz2 echo tar -cf - testfile\* \| lzma \> data.tar.lzma tar -cf - testfile* | lzma > data.tar.lzma echo tar -cf - testfile\* \| bzip2 \> data.tar.bz2 tar -cf - testfile* | bzip2 > data.tar.bz2 echo tar -cf - testfile\* \| gzip \> data.tar.gz tar -cf - testfile* | gzip > data.tar.gz echo tar -cf - testfile\* \| xz \> data.tar.xz tar -cf - testfile* | xz > data.tar.xz echo 2.0 > debian-binary datatestlist="gz bz2 lzma xz" for ext in $datatestlist ; do dodo ar qcfS fake_${ext}.deb debian-binary control.tar.bz2 data.tar.${ext} # one .deb with trailing garbage at the end of the data tar: echo "trailing garbage" >> data.tar.${ext} dodo ar qcfS fake_${ext}_t.deb debian-binary control.tar.bz2 data.tar.${ext} # and one .deb where the the length is correct but the .ar header differs cp fake_${ext}_t.deb fake_${ext}_w.deb origlength=$(stat -c '%s' fake_${ext}.deb) newlength=$(stat -c '%s' fake_${ext}_w.deb) if test $((origlength + 18)) -eq $((newlength)) ; then # new length is 17 + one padding, so original did not have padding: truncate -s "$origlength" fake_${ext}_w.deb else # also remove the padding byte: truncate -s "$((origlength - 1))" fake_${ext}_w.deb fi done rm debian-binary control *.tar.* # TODO: there could be a problem here with .deb files that have data after the # ./control file in data.tar and using an external uncompressor. # But how to test this when there is no way to trigger it in the default built? testrun - __extractcontrol fake_gz.deb 3< debian/control < debian/dirs dd if=/dev/zero of=debian/zzz bs=1024 count=4096 tar -cf - debian | $compressor_program > fake_1-1.debian.tar.$compressor mkdir fake-1 mkdir fake-1.orig cp -al debian fake-1/debian cp -al debian fake-1.orig/debian sed -e 's/1/2/' fake-1/debian/dirs > fake-1/debian.dirs.new mv fake-1/debian.dirs.new fake-1/debian/dirs diff -ruN fake-1.orig fake-1 | $compressor_program > fake_1-1.diff.$compressor rm -r debian # .debian.tar and .diff usually do not happen at the same time, but easier testing... cat > fake_1-1.dsc << EOF Format: 3.0 Source: fake Binary: abinary Architecture: all Version: 17 Maintainer: Me Files: $(mdandsize fake_1-1.diff.${compressor}) fake_1-1.diff.${compressor} $(mdandsize fake_1-1.debian.tar.${compressor}) fake_1-1.debian.tar.${compressor} 00000000000000000000000000000000 0 fake_1.orig.tar.${compressor} EOF testrun - __extractsourcesection fake_1-1.dsc 3< fake_1-1.debian.tar.${compressor} tar -cf - debian | ${compressor_program} > fake_1-1.debian.tar.${compressor} rm -r debian testrun - __extractsourcesection fake_1-1.dsc 3< fake-1/debian/control < fake-1/debian/aaaaa < fake_1-1.diff.${compressor} rm -r fake-1 fake-1.orig cat > fake_1-1.dsc << EOF Format: 3.0 Source: fake Binary: abinary Architecture: all Version: 17 Maintainer: Me Files: $(mdandsize fake_1-1.diff.${compressor}) fake_1-1.diff.${compressor} $(mdandsize fake_1-1.debian.tar.${compressor}) fake_1-1.debian.tar.${compressor} 00000000000000000000000000000000 0 fake_1.orig.tar.${compressor} EOF testrun - __extractsourcesection fake_1-1.dsc 3< fake_1-2.diff < fake_1-2.dsc << EOF Format: 3.0 Source: fake Binary: abinary Architecture: all Version: 17 Maintainer: Me Files: $(mdandsize fake_1-2.diff.gz) fake_1-2.diff.gz 00000000000000000000000000000000 0 fake_1.orig.tar.gz EOF testrun - __extractsourcesection fake_1-2.dsc 3<