##
##  tcpwrappers.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:         tcpwrappers
Summary:      TCP Wrappers Toolkit
URL:          http://www.web-insights.net/socket_wrappers/
Vendor:       Wietse Venema, Steve Grubb
Packager:     OpenPKG Project
Distribution: OpenPKG Community
Class:        PLUS
Group:        Networking
License:      BSD
Version:      7.6k
Release:      20080101

#   package options
%option       with_private_namespace  no

#   list of sources
Source0:      http://www.web-insights.net/socket_wrappers/socket_wrappers-%{version}.tar.gz
Source1:      hosts.allow
Patch0:       tcpwrappers.patch

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

%description
    The TCP Wrappers package allows you to monitor and filter incoming
    requests for various network services. It provides tiny daemon
    wrapper programs that can be installed without any changes to
    existing software or to existing configuration files. The wrappers
    report the name of the client host and of the requested service.
    The wrappers do not exchange information with the client or server
    applications, and impose no overhead on the actual conversation
    between the client and server applications.

    Additionally, the wrapper functionality is available as a C API
    for use in other networking applications, too.

    This package actually is based on Steve Grubb's revised version
    (Socket Wrappers) of Wietse Venema's original TCP Wrappers.

%track
    prog tcpwrappers = {
        version   = %{version}
        url       = http://www.web-insights.net/socket_wrappers/
        regex     = socket_wrappers-(__VER__)\.tar\.gz
    }

%prep
    %setup -q -n socket_wrappers-%{version}
    %patch -p0
    chmod a+w Makefile.orig
    %{l_shtool} subst \
        -e 's;/etc/hosts\.deny;%{l_prefix}/etc/tcpwrappers/hosts.deny;g' \
        -e 's;/etc/hosts\.allow;%{l_prefix}/etc/tcpwrappers/hosts.allow;g' \
        Makefile

%build
    case "%{l_platform -t}" in
        *-freebsd* ) platform="freebsd" ;;
        *-linux*   ) platform="linux"   ;;
        *-sunos*   ) platform="sunos5"  ;;
        *          ) platform="other"   ;;
    esac
    %{l_make} %{l_mflags} \
        $platform \
%if "%{with_private_namespace}" != "yes"
        NAMESPACE="" \
%endif
        CC="%{l_cc} %{l_cflags -O}"

%install
    %{l_shtool} mkdir -f -p -m 755 \
        $RPM_BUILD_ROOT%{l_prefix}/etc/tcpwrappers \
        $RPM_BUILD_ROOT%{l_prefix}/sbin \
        $RPM_BUILD_ROOT%{l_prefix}/lib \
        $RPM_BUILD_ROOT%{l_prefix}/include \
        $RPM_BUILD_ROOT%{l_prefix}/man/man3 \
        $RPM_BUILD_ROOT%{l_prefix}/man/man5 \
        $RPM_BUILD_ROOT%{l_prefix}/man/man8
    %{l_shtool} install -c -s -m 755 \
        tcpd tcpdchk tcpdmatch try-from safe_finger \
        $RPM_BUILD_ROOT%{l_prefix}/sbin/
    %{l_shtool} install -c -m 644 \
        tcpd.h $RPM_BUILD_ROOT%{l_prefix}/include/
    %{l_shtool} install -c -m 644 \
        libwrap.a $RPM_BUILD_ROOT%{l_prefix}/lib/
    %{l_shtool} install -c -m 644 \
        *.3 $RPM_BUILD_ROOT%{l_prefix}/man/man3/
    %{l_shtool} install -c -m 644 \
        *.5 $RPM_BUILD_ROOT%{l_prefix}/man/man5/
    %{l_shtool} install -c -m 644 \
        *.8 $RPM_BUILD_ROOT%{l_prefix}/man/man8/
    %{l_shtool} install -c -m 644 \
        %{SOURCE hosts.allow} \
        $RPM_BUILD_ROOT%{l_prefix}/etc/tcpwrappers/
    %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
        %{l_files_std} \
        '%config %{l_prefix}/etc/tcpwrappers/*'

%files -f files

%clean

