##
##  vpnc.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.
##

#   FIXME: rse: run-command scripts still missing

#   package information
Name:         vpnc
Summary:      Virtual Private Network Client
URL:          http://www.unix-ag.uni-kl.de/~massar/vpnc/
Vendor:       G. Keating, M. Massar, D.V.P. Christiansen
Packager:     OpenPKG Project
Distribution: OpenPKG Community
Class:        EVAL
Group:        Networking
License:      GPL
Version:      0.5.3
Release:      20091104

#   package options
%option       with_hybrid  yes

#   list of sources
Source0:      http://www.unix-ag.uni-kl.de/~massar/vpnc/vpnc-%{version}.tar.gz
Source1:      vpnc.conf
Patch0:       vpnc.patch

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

%description
    VPNC is a Virtual Private Network (VPN) client supposed to work with
    Cisco VPN concentrator 3000 Series, Cisco IOS routers, Cisco PIX /
    ASA Zecurity Appliances and Juniper/Netscreen routers. Supported
    Authentications are: Hybrid, Pre-Shared-Key + XAUTH, Pre-Shared-Key.
    Supported IKE DH-Groups are: dh1 dh2 dh5. Supported Hash Algorithms
    (IKE/IPSEC) are: md5 sha1. Supported Encryptions (IKE/IPSEC) are:
    null 1des 3des aes128 aes192 aes256. Perfect Forward Secrecy are:
    nopfs dh1 dh2 dh5.

%track
    prog vpnc = {
        version   = %{version}
        url       = http://www.unix-ag.uni-kl.de/~massar/vpnc/
        regex     = vpnc-(__VER__)\.tar\.gz
    }

%prep
    %setup -q
    %patch -p0

%build
    %{l_shtool} subst \
        -e 's;/usr/bin/perl;%{l_prefix}/bin/perl;' \
        makeman.pl
    %{l_shtool} subst \
        -e 's;/etc/vpnc/vpnc-script;%{l_prefix}/etc/vpnc/vpnc-script;' \
        -e 's;/var/run/vpnc/pid;%{l_prefix}/var/vpnc/vpnc.pid;' \
        -e 's;/etc/vpnc/default.conf;%{l_prefix}/etc/vpnc/vpnc.conf;' \
        -e 's;/etc/vpnc.conf;%{l_prefix}/etc/vpnc/vpnc.conf;' \
        -e 's;"/etc/vpnc/";"%{l_prefix}/etc/vpnc/";' \
        config.c
    %{l_shtool} subst \
        -e 's;/var/run/vpnc/;%{l_prefix}/var/vpnc;g' \
        vpnc-script.in
    %{l_make} %{l_mflags} \
        CC="%{l_cc}" \
        CFLAGS="%{l_cflags -O}" \
        CPPFLAGS="%{l_cppflags}" \
        LDFLAGS="%{l_ldflags}"
%if "%{with_hybrid}" == "yes"
        OPENSSL_GPL_VIOLATION="-DOPENSSL_GPL_VIOLATION" \
        OPENSSLLIBS="-lcrypto" \
%endif
        PREFIX=%{l_prefix}

%install
    %{l_make} %{l_mflags} install DESTDIR=$RPM_BUILD_ROOT PREFIX=%{l_prefix}
    strip $RPM_BUILD_ROOT%{l_prefix}/bin/* >/dev/null 2>&1 || true
    strip $RPM_BUILD_ROOT%{l_prefix}/sbin/* >/dev/null 2>&1 || true
    rm -rf $RPM_BUILD_ROOT%{l_prefix}/share >/dev/null 2>&1 || true
    %{l_shtool} mkdir -f -p -m 755 \
        $RPM_BUILD_ROOT%{l_prefix}/var/vpnc
    %{l_shtool} install -c -m 644 \
        %{SOURCE vpnc.conf} $RPM_BUILD_ROOT%{l_prefix}/etc/vpnc/
    rm -f $RPM_BUILD_ROOT%{l_prefix}/etc/vpnc/default.conf
    %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
        %{l_files_std} \
        '%config %{l_prefix}/etc/vpnc/*'

%files -f files

%clean

