2
# Split an upstream tarball into +dfsg, and libclamunrar.
4
echo -e "Usage: $0 <PATH> <VERSION>\n\t<PATH> - directory that contains clamav-<VERSION>.tar.gz";
8
test -d $1 || { echo "Directory $1 doesn't exist"; exit 2; }
9
TARBALL="$PWD/$1/clamav-$2.tar.gz"
10
test -f $TARBALL || { echo "Tarball $TARBALL doesn't exist"; exit 3; }
12
TEMP=`mktemp -d __splitXXXXXX` || { echo "Cannot create temporary directory"; exit 2; }
13
echo "Temporary directory is $TEMP"
15
echo "Extracting $TARBALL";
16
tar -xzf $TARBALL || { echo "Failed to extract $TARBALL"; exit 4; }
18
UNRARPKG=libclamunrar_$2.orig.tar.gz
19
DFSGPKG=clamav_$2+dfsg.orig.tar.gz
20
UNRARDIR="libclamunrar-$2"
25
mv clamav-$2 clamav-$2+dfsg
27
UNRARDIR="$PWD/$UNRARDIR"
28
echo "Preparing dfsg package"
30
cp -R libclamunrar_iface $UNRARDIR
31
mv libclamunrar $UNRARDIR
33
cp -R config/ $UNRARDIR
34
cp configure.in $UNRARDIR
35
cp COPYING{,.unrar,.LGPL} $UNRARDIR
37
tar -czf $DFSGPKG clamav-$2+dfsg/
39
echo "Preparing unrar package"
40
sed -i '/AC_OUTPUT/,/])/ {
42
s/^libclamav\/Makefile/libclamunrar_iface\/Makefile/p
49
s/clamscan\/clamscan.c/libclamunrar_iface\/unrar_iface.c/
51
cat <<EOF >Makefile.am &&
53
DISTCLEANFILES = target.h
54
SUBDIRS = libclamunrar_iface
58
tar -czf $UNRARPKG libclamunrar-$2/
60
printf "Test archives?"
62
if [ x$yes != xy ] ; then
63
echo "Copying tarballs to current directory"
66
echo "Ready (untested): $UNRARPKG $DFSGPKG" &&
68
echo "Removed temporary directory $TEMP" &&
73
mkdir testpfx || { echo "Failed to create testpfx"; exit 5; }
74
TESTPFX="$PWD/testpfx"
75
mkdir buildtest && cd buildtest
76
echo "Running build-test for $DFSGPKG"
77
tar -xzf ../$DFSGPKG && cd clamav-$2+dfsg
79
./configure --disable-clamav --disable-unrar --enable-milter --prefix=$TESTPFX >makelog
81
make $MAKEFLAGS >>makelog
83
make $MAKEFLAGS check >>makelog 2>&1
84
make $MAKEFLAGS install >>makelog
85
make $MAKFELAGS installcheck >>makelog
88
echo "Running build-test for $UNRARPKG"
89
tar -xzf ../$UNRARPKG && cd libclamunrar-$2
91
./configure --disable-clamav --prefix=$TESTPFX >makelog
93
make $MAKEFLAGS >>makelog
94
make $MAKEFLAGS install >>makelog
95
make $MAKEFLAGS installcheck >>makelog
98
echo "Testing whether unrar functionality works"
100
aa15bcf478d165efd2065190eb473bcb:544:ClamAV-Test-File
103
if test $? -ne 0; then
109
# clamscan will exit with exitcode 1 on success (virus found)
111
$TESTPFX/bin/clamscan buildtest/clamav-$2+dfsg/test/clam-v*.rar -dtest.hdb >clamscanlog
112
if test $? -ne 1; then
117
NDET=`grep FOUND clamscanlog | wc -l`
118
if test "0$NDET" -eq "2"; then
119
echo "All testfiles detected"
120
echo "Copying tarballs to current directory"
123
echo "Ready: $UNRARPKG $DFSGPKG" &&
125
echo "Removed temporary directory $TEMP" &&