##
##  hclnfsd.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:         hclnfsd
Summary:      Hummingbird NFS Authentication Daemon
URL:          http://www.hclnfsd.org/
Vendor:       Hummingbird
Packager:     OpenPKG Project
Distribution: OpenPKG Community
Class:        EVAL
Group:        Filesystem
License:      PD
Version:      10.0.0.2
Release:      20080101

#   list of sources
Source0:      http://download.openpkg.org/components/versioned/hclnfsd/hclnfsd-%{version}.tar
Source1:      hclnfsd.acl
Source2:      rc.hclnfsd
Patch0:       hclnfsd.patch

#   build information
BuildPreReq:  OpenPKG, openpkg >= 20160101, gc
PreReq:       OpenPKG, openpkg >= 20160101

%description
    hclnfsd is the Hummingbird NFS authentication daemon. It is a
    super-set of the old PCNFSD from Sun.

%track
    prog hclnfsd = {
        version   = %{version}
        url       = http://download.openpkg.org/components/versioned/hclnfsd/
        regex     = hclnfsd-(__VER__)\.tar
    }

%prep
    %setup -q -c
    %patch -p0

%build
    #   build program
    platform=""
    case "%{l_platform -t}" in
        *-freebsd* ) platform="freebsd" ;;
        *-linux*   ) platform="linux"   ;;
        *-sunos*   ) platform="solaris" ;;
        * ) echo "Platform \"%{l_platform -t}\" not supported" 1>&2; exit 1 ;;
    esac
    %{l_make} %{l_mflags} -f makefile $platform

%install

    #   create installation hierarchy
    %{l_shtool} mkdir -f -p -m 755 \
        $RPM_BUILD_ROOT%{l_prefix}/sbin \
        $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d \
        $RPM_BUILD_ROOT%{l_prefix}/etc/hclnfsd \
        $RPM_BUILD_ROOT%{l_prefix}/var/hclnfsd

    #   install program
    %{l_shtool} install -c -s -m 755 \
        hclnfsd $RPM_BUILD_ROOT%{l_prefix}/sbin/

    #   install run-command script
    %{l_shtool} install -c -m 755 %{l_value -s -a} \
        %{SOURCE rc.hclnfsd} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/

    #   install access control list
    %{l_shtool} install -c -m 755 %{l_value -s -a} \
        %{SOURCE hclnfsd.acl} $RPM_BUILD_ROOT%{l_prefix}/etc/hclnfsd/

    #   determine installation files
    %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std}

%files -f files

%clean

%post
    #   after upgrade, restart service
    [ $1 -eq 2 ] || exit 0
    eval `%{l_rc} hclnfsd status 2>/dev/null`
    [ ".$hclnfsd_active" = .yes ] && %{l_rc} hclnfsd restart
    exit 0

%preun
    #   before erase, stop service and remove log files
    [ $1 -eq 0 ] || exit 0
    %{l_rc} hclnfsd stop 2>/dev/null
    rm -f $RPM_INSTALL_PREFIX/var/hclnfsd/*
    exit 0

