Info3: <<
Package: clamav
Version: 0.100.1
Revision: 1

Description: Clam Anti-Virus scanner
DescDetail: <<
 Clam AntiVirus is a GPL anti-virus toolkit for UNIX, designed
 especially for e-mail scanning on mail gateways. It provides
 a number of utilities including a flexible and scalable multi-
 threaded daemon, a command line scanner and advanced tool for
 automatic database updates. The core of the package is an
 anti-virus engine available in a form of shared library.
<<
DescUsage: <<
 'clamscan' scans the current working directory for known
 viruses. See 'man clamscan' for details.

 For virus updates, run 'freshclam' from a shell prompt
 or in a cron script.
<<
DescPackaging: <<
 clamscan requires a user named 'clamav' to run in
 superuser mode regardless of how it was built. (Important when
 running the post-build tests because fink runs as root).

 During the test the virus database isn't actually installed yet so
 the one in the build directory is specified.

 The database directory %i/var/db/%n must be owned by the 'clamav'
 user. This requires a change of the owner during the build.
 Therefore, we cannot build as 'nobody'.

 Original package maintainer was Carsten Klapp
 <carstenklapp@users.sourceforge.net>.
<<
DescPort: <<
 Install virus databases into %p/var/db/clamav instead of default
 %p/share/clamav; %p/share is for static data.
<<

Maintainer: Remi Mommsen <remigius.mommsen@cern.ch>
Homepage: http://www.clamav.net/
License: GPL/OpenSSL
Source: http://www.clamav.net/downloads/production/%n-%v.tar.gz
Source-Checksum: SHA256(84e026655152247de7237184ee13003701c40be030dd68e0316111049f58a59f)

BuildDepends: <<
  fink (>= 0.24.12),
  fink-package-precedence,
  bzip2-dev,
  libiconv-dev,
  libncurses5,
  libpcre2,
  libtool2 (>= 2.4.2-4),
  libxml2 (>= 2.9.1-1),
  openssl110-dev,
  pkgconfig
<<
Depends: <<
  clamav8-shlibs (=%v-%r),
  libncurses5-shlibs
<<

PatchScript: <<
 %{default_script}
 /usr/bin/sed -i'.bak' -e 's/LC_AGE=1/LC_AGE=0/g' -e 's/-print-multi-os-directory//g' configure*
 /usr/bin/sed -i'.bak' -e 's/${wl}-flat_namespace ${wl}-undefined ${wl}suppress/${wl}-twolevel_namespace/g' libclamav/libmspack-0.5alpha/configure*
<<

SetCFLAGS: -O3
CompileScript: <<
 #!/bin/sh -ev
 ./configure --prefix=%p --mandir=%p/share/man --with-dbdir=%p/var/db/%n \
             --sysconfdir=%p/etc --enable-dependency-tracking --disable-clamav \
             --with-openssl=%p --with-pcre=%p --with-xml=%p
 make
 fink-package-precedence --prohibit-bdep=clamav8-dev .
<<
InstallScript: <<
 #!/bin/sh -ev
 /usr/bin/make install DESTDIR=%d

 for configfile in clamav-milter.conf clamd.conf freshclam.conf ; do
   /usr/bin/sed -e "s/^Example/#Example/" -e "s:^#PidFile /var/run:PidFile /var/run:" \
      -e "s:#LocalSocket /tmp/:LocalSocket /tmp/:" \
      etc/${configfile}.sample > %i/etc/${configfile}
   rm -f  %i/etc/${configfile}.sample
 done

 /usr/bin/install -d -m 755 %i/share/doc/%n
 /bin/mv docs/* %i/share/doc/%n
 (cd %i/share/doc/%n; /bin/rm -R Makefile Makefile.am Makefile.in man) || exit 1
 /usr/bin/install -d -m 755 %i/share/doc/%n/test/
 /bin/cp -r test/* %i/share/doc/%n/test/
<<
ConfFiles: %p/etc/clamav-milter.conf %p/etc/freshclam.conf
DocFiles: COPYING*

SplitOff: <<
  Description: Shared libraries for ClamAV
  Package: clamav8-shlibs
  Depends: <<
    bzip2-shlibs,
    libpcre2-shlibs,
    libtool2-shlibs (>= 2.4.2-4),
    libxml2-shlibs (>= 2.9.1-1),
    openssl110-shlibs
  <<
  Files: <<
    lib/libclamav.8.dylib
    lib/libclamunrar.8.dylib
    lib/libclammspack.0.dylib
  <<
  Shlibs: <<
    %p/lib/libclamav.8.dylib          9.0.0 %n (>= 0.95-1)
    %p/lib/libclamunrar.8.dylib       9.0.0 %n (>= 0.95-1)
    %p/lib/libclammspack.0.dylib      2.0.0 %n (>= 0.100-1)
  <<
<<
SplitOff2: <<
  Description: ClamAV daemon
  DescDetail: <<
    Installs and runs the ClamAV daemon using the daemonic package.
  <<
  DescUsage: <<
    In order to use the clamd daemon, you need to call 'clamdscan'
    (note the d in contrast to the standard 'clamscan'
    command).

    You might want to edit %p/etc/clamd.conf to suit your
    needs. Additionally, enable 'NotifyClamd' in
    %p/etc/freshclam.conf such that the ClamAV daemon gets notified
    about virus definition updates.
  <<
  Package: clamav-daemon
  Depends: <<
    clamav,
    daemonic
  <<
  Files: <<
    etc/clamd.conf
    bin/clamdscan
    sbin/clamd
  <<
  ConfFiles: %p/etc/clamd.conf
  DaemonicName: clamav
  DaemonicFile: <<
     <service>
       <description>ClamAV</description>
       <message>ClamAV anti-virus daemon</message>
       <daemon name="clamd">
         <executable background="yes">%p/sbin/clamd</executable>
         <configfile>%p/etc/clamd.conf</configfile>
         <pidfile>/var/run/clamd.pid</pidfile>
        </daemon>
     </service>
  <<
  PostInstScript: <<
    daemonic enable clamav
    /Library/StartupItems/daemonic-clamav/daemonic-clamav start
  <<
  PreRmScript: <<
    # deamonic knows nothing about 'stop'
    #/Library/StartupItems/daemonic-clamav/daemonic-clamav stop
    # Location of pid file for clamav versions < 0.95-13
    if [ -r %p/var/run/clamd.pid ]; then
      kill -s TERM `cat %p/var/run/clamd.pid`
    fi
    # New location of pid file
    if [ -r /var/run/clamd.pid ]; then
      kill -s TERM `cat /var/run/clamd.pid`
    fi
    if [ $1 != "upgrade" ]; then
      daemonic remove clamav
    fi
  <<
<<
SplitOff3: <<
  Description: Developer files for ClamAV
  Package: clamav8-dev
  Depends: <<
    clamav (=%v-%r)
  <<
  Provides: clamav-dev
  BuildDependsOnly: true
  Files: <<
    bin/clamav-config
    include
    lib/pkgconfig
    lib/*a
    lib/*dylib
  <<
<<

InfoTest: <<
 TestSuiteSize: medium
 TestSource: http://database.clamav.net/main.cvd
 TestSource-Checksum: SHA256(9520cc7827ddc5267684f2c5c7044cf2df1f62606ca81402cbeae12183763a90)
 # need to get the daily virus definitions to succeed with all test files
 # a given snapshot has to be cached to avoid daily changing md5sum
 TestSource2: http://cern.ch/mommsen/fink/daily.cvd
 TestSource2-Checksum: SHA256(5ceba23e24c11924e7fe03a115e67dbbc517f39a2bd9813597aeadad3308106d)
 TestScript: <<
   #!/bin/sh -ev
   make check || exit 2
   for clamfile in `/bin/ls -1 %b/test/clam*`; do
     %b/clamscan/clamscan --database=%b/.. $clamfile && exit 2
   done
 <<
<<

PostInstScript: <<
 # need to change permissions here as these files might already been
 # installed, in which case the permission are not adjusted
 /bin/mkdir -p %p/var/db/clamav
 /usr/sbin/chown -R clamav:admin %p/var/db/clamav
 /bin/chmod g+w %p/var/db/clamav
 /bin/chmod g+w %p/etc/freshclam.conf

 printf "\nDo you want to download the latest virus definitions now? [Yn] "
 YN=yes
 if ! read -t 20 YN; then
   echo "Yes"
 fi
 case $YN in
   [nN]|[nN][oO]) echo "Your virus definitions might be out-dated." ;;
   *) set +e ; %p/bin/freshclam ;;
 esac
 printf "\nTo download the latest virus definitions in future, run 'freshclam'.\n"
<<
PreRmScript: <<
  if [ $1 != "upgrade" ]; then
    # Remove db files
    /bin/rm -rf %p/var/db/clamav
  fi
<<
<<