##
##  sslh.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 version
%define       V_opkg   1.18
%define       V_dist   v1.18
%define       V_subdir v1.18

#   package information
Name:         sslh
Summary:      SSL/SSH Server Multiplexer
URL:          http://www.rutschle.net/tech/sslh.shtml
Vendor:       Yves Rutschle
Packager:     OpenPKG Project
Distribution: OpenPKG Community
Class:        EVAL
Group:        Networking
License:      GPL
Version:      %{V_opkg}
Release:      20160405

#   package options
%option       with_fsl  yes

#   list of sources
Source0:      http://www.rutschle.net/tech/sslh/sslh-%{V_dist}.tar.gz
Source1:      rc.sslh
Source2:      fsl.sslh
Patch0:       sslh.patch

#   build information
BuildPreReq:  OpenPKG, openpkg >= 20160101, make, gcc, perl
PreReq:       OpenPKG, openpkg >= 20160101
%if "%{with_fsl}" == "yes"
BuildPreReq:  fsl
PreReq:       fsl
%endif

%description
    sslh(8) lets one accept both HTTPS and SSH connections on the same
    port. It makes it possible to connect to an SSH server on port 443
    (usually from inside a corporate firewall which does not allow
    outgoing SSH connections, but outgoing HTTPS connections) while
    still serving HTTPS on that same port.

%track
    prog sslh = {
        version   = %{version}
        url       = http://www.rutschle.net/tech/sslh.shtml
        regex     = sslh-v(__VER__)\.tar\.gz
    }

%prep
    %setup -q -n sslh-%{V_subdir}
    %patch -p0

%build
    %{l_make} %{l_mflags} \
        CC="%{l_cc}" \
        CFLAGS="%{l_cflags -O} %{l_cppflags}" \
        LDFLAGS="-L. %{l_ldflags} %{l_fsl_ldflags}" \
        LIBS="%{l_fsl_libs}"

%install
    %{l_shtool} mkdir -f -p -m 755 \
        $RPM_BUILD_ROOT%{l_prefix}/etc/fsl \
        $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d \
        $RPM_BUILD_ROOT%{l_prefix}/sbin \
        $RPM_BUILD_ROOT%{l_prefix}/man/man8 \
        $RPM_BUILD_ROOT%{l_prefix}/var/sslh
    %{l_shtool} install -c -s -m 755 \
        sslh-fork $RPM_BUILD_ROOT%{l_prefix}/sbin/sslh
    %{l_shtool} install -c -m 644 \
        sslh.8 $RPM_BUILD_ROOT%{l_prefix}/man/man8/
    %{l_shtool} install -c -m 755 %{l_value -s -a} \
        %{SOURCE rc.sslh} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
    %{l_shtool} install -c -m 644 %{l_value -s -a} \
        %{SOURCE fsl.sslh} $RPM_BUILD_ROOT%{l_prefix}/etc/fsl/
    %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
        %{l_files_std} \
        '%attr(-,%{l_nusr},%{l_ngrp}) %{l_prefix}/var/sslh'

%files -f files

%clean

