##
##  swhoisd.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:         swhoisd
Summary:      Simple WHOIS Daemon
URL:          http://dan.drydog.com/swhoisd/
Vendor:       Dan Anderson
Packager:     OpenPKG Project
Distribution: OpenPKG Community
Class:        PLUS
Group:        WHOIS
License:      MIT-style
Version:      3.0.5
Release:      20080101

#   list of sources
Source0:      ftp://dan.drydog.com/pub/swhoisd/swhoisd-%{version}.tar.gz
Source1:      swhoisd.conf
Source2:      rc.swhoisd
Patch0:       swhoisd.patch

#   build information
BuildPreReq:  OpenPKG, openpkg >= 20160101, config
PreReq:       OpenPKG, openpkg >= 20160101
BuildPreReq:  gettext, libiconv
PreReq:       gettext, libiconv

%description
    Swhoisd provides the standard Internet WHOIS directory service. It
    is much simpler to setup and administrator than the other WHOIS
    daemons available, such as RIPE WHOIS or the original SRC WHOIS.
    This is because it uses a flat-text file instead of a complex
    database. This WHOIS server is recommended only for small databases.

%track
    prog swhoisd = {
        version   = %{version}
        url       = http://dan.drydog.com/swhoisd/
        regex     = swhoisd-(__VER__)\.tar\.gz
    }

%prep
    %setup -q
    rm -rf RCS */RCS
    %patch -p0
    %{l_prefix}/bin/config install .

%build
    %{l_shtool} subst \
        -e 's;"/etc";"%{l_prefix}/etc/swhoisd";' \
        -e 's;"/var/log";"%{l_prefix}/var/swhoisd";' \
        -e 's;"/var/run";"%{l_prefix}/var/swhoisd";' \
        src/in.swhoisd.h
    AUTOMAKE="true" \
    AUTOCONF="true" \
    CC="%{l_cc}" \
    CFLAGS="%{l_cflags -O}" \
    CPPFLAGS="%{l_cppflags}" \
    LDFLAGS="%{l_ldflags}" \
    LIBS="-lintl -liconv" \
    ./configure \
        --prefix=%{l_prefix}
    ( cd src
      %{l_make} %{l_mflags} in.swhoisd
    ) || exit $?

%install
    %{l_shtool} mkdir -f -p -m 755 \
        $RPM_BUILD_ROOT%{l_prefix}/sbin \
        $RPM_BUILD_ROOT%{l_prefix}/man/man8 \
        $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d \
        $RPM_BUILD_ROOT%{l_prefix}/etc/swhoisd \
        $RPM_BUILD_ROOT%{l_prefix}/var/swhoisd
    %{l_shtool} install -c -s -m 755 \
        src/in.swhoisd $RPM_BUILD_ROOT%{l_prefix}/sbin/swhoisd
    %{l_shtool} install -c -m 644 \
        doc/in.swhoisd.8 $RPM_BUILD_ROOT%{l_prefix}/man/man8/swhoisd.8
    %{l_shtool} install -c -m 644 %{l_value -s -a} \
        %{SOURCE swhoisd.conf} $RPM_BUILD_ROOT%{l_prefix}/etc/swhoisd/
    %{l_shtool} install -c -m 644 \
        doc/swhoisd.header doc/swhoisd.footer \
        $RPM_BUILD_ROOT%{l_prefix}/etc/swhoisd/
    %{l_shtool} install -c -m 755 %{l_value -s -a} \
        %{SOURCE rc.swhoisd} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
    %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
        %{l_files_std} \
        '%config %{l_prefix}/etc/swhoisd/*' \
        '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/swhoisd/'

%files -f files

%clean

