##
##  fprot.spec -- OpenPKG RPM Package Specification
##  Copyright (c) 2000-2025 OpenPKG Project <http://openpkg.org/>
##
##  Permission to use, copy, modify, and distribute this software for
##  any purpose with or without fee is hereby granted, provided that
##  the above copyright notice and this permission notice appear in all
##  copies.
##
##  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
##  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
##  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
##  IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
##  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
##  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
##  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
##  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
##  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
##  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
##  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
##  SUCH DAMAGE.
##

#   package information
Name:         fprot
Summary:      F-Prot Anti-Virus
URL:          http://www.f-prot.com/
Vendor:       FRISK Software International
Packager:     OpenPKG Project
Distribution: OpenPKG Community
Class:        EVAL
Group:        AntiVirus
License:      Commercial/Free-Private-Use
Version:      4.6.7
Release:      20080101

#   list of sources
Source0:      ftp://ftp.f-prot.com/pub/bsd/fp-freebsd-ws-%{version}.tar.gz
Source1:      ftp://ftp.f-prot.com/pub/linux/fp-linux-ws-%{version}.tar.gz
Source2:      ftp://ftp.f-prot.com/pub/solaris/fp-solaris-i386-ws-%{version}.tar.gz
Source3:      ftp://ftp.f-prot.com/pub/solaris/fp-solaris-sparc-ws-%{version}.tar.gz
Source4:      rc.fprot

#   build information
BuildPreReq:  OpenPKG, openpkg >= 20160101
PreReq:       OpenPKG, openpkg >= 20160101, perl, perl-www, perl-net, infozip

%description
    F-PROT is the AntiVirus scanner from FRISK Software International.
    It is free for private use.

%track
    prog fprot = {
        version   = %{version}
        url       = ftp://ftp.f-prot.com/pub/bsd/
        regex     = fp-freebsd-ws-(__VER__)\.tar\.gz
    }

%prep
    %setup -q -T -c

    #   unpack platform-specific Engine
    case "%{l_platform -t}" in
        *-freebsd*   ) engine="%{SOURCE0}" ;;
        *-linux*     ) engine="%{SOURCE1}" ;;
        x?86-sunos*  ) engine="%{SOURCE2}" ;;
        amd64-sunos* ) engine="%{SOURCE2}" ;;
        sun*-sunos*  ) engine="%{SOURCE3}" ;;
        * ) echo "Sorry, platform %{l_platform -t} not supported" 1>&2; exit 1 ;;
    esac
    %{l_gzip} -d -c $engine | %{l_tar} xf -

%build

%install
    %{l_shtool} mkdir -f -p -m 755 \
        $RPM_BUILD_ROOT%{l_prefix}/bin \
        $RPM_BUILD_ROOT%{l_prefix}/sbin \
        $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d \
        $RPM_BUILD_ROOT%{l_prefix}/libexec/fprot \
        $RPM_BUILD_ROOT%{l_prefix}/share/fprot \
        $RPM_BUILD_ROOT%{l_prefix}/man/man1 \
        $RPM_BUILD_ROOT%{l_prefix}/man/man8
    %{l_shtool} install -c -s -m 755 \
        f-prot/f-prot $RPM_BUILD_ROOT%{l_prefix}/libexec/fprot/
    ln \
        $RPM_BUILD_ROOT%{l_prefix}/libexec/fprot/f-prot \
        $RPM_BUILD_ROOT%{l_prefix}/share/fprot/f-prot
    #   intentionally execute f-prot through the link in the data directory
    ( echo "#!/bin/sh"
      echo "exec %{l_prefix}/share/fprot/f-prot \${1+\"\$@\"}"
    ) >f-prot.sh
    %{l_shtool} install -c -m 755 \
        f-prot.sh $RPM_BUILD_ROOT%{l_prefix}/bin/f-prot
    %{l_shtool} install -c -m 644 \
        f-prot/man_pages/f-prot.1 \
        $RPM_BUILD_ROOT%{l_prefix}/man/man1/
    %{l_shtool} install -c -m 755 \
        -e 's;/usr/bin/perl;%{l_prefix}/bin/perl;' \
        -e 's;/var/tmp/f-prot/;/tmp/fprot/;' \
        -e 's;/usr/local/f-prot/;%{l_prefix}/share/fprot;' \
        -e 's;"unzip;"%{l_prefix}/bin/unzip;g' \
        -e 's;> /dev/null;>/dev/null 2>\&1;g' \
        -e 's;\(signatureDirectory =\).*;\1 "%{l_prefix}/share/fprot/", 1;' \
        f-prot/tools/check-updates.pl \
        $RPM_BUILD_ROOT%{l_prefix}/sbin/f-prot-update
    %{l_shtool} install -c -m 644 \
        f-prot/man_pages/check-updates.pl.8 \
        $RPM_BUILD_ROOT%{l_prefix}/man/man8/
    %{l_shtool} install -c -m 644 \
        f-prot/ENGLISH.TX0 f-prot/*.DEF \
        $RPM_BUILD_ROOT%{l_prefix}/share/fprot/
    %{l_shtool} install -c -m 755 %{l_value -s -a} \
        %{SOURCE rc.fprot} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
    %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std}

%files -f files

%clean

