# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem          1.0
PortGroup           github 1.0
PortGroup           cmake 1.1
PortGroup           openssl 1.0

name                openiked
github.setup        openiked openiked-portable 7.4 v
github.tarball_from archive
categories          net
license             ISC
revision            0
maintainers         {@ryanakca debian.org:rak} openmaintainer
description         Internet Key Exchange (IKEv2) daemon
long_description    A free implementation of the Internet Key Exchange (IKEv2) protocol \
                    which performs mutual authentication and which establishes and maintains\
                    IPsec VPN security policies and associations (SAs) between peers. It is \
                    intended to be a lean, clean, secure, better configurable and \
                    interoperable implementation that focusses on supporting the main standards \
                    and most important features of IKEv2.
homepage            https://www.openiked.org

checksums           rmd160  311e5da3e1cad1e1b9e081265dbf96decaef4302 \
                    sha256  cc35cb5a2a6ad40d4e2ed7e269f810394068a7388c1c32e6b769247fe6b6717f \
                    size    321104

depends_lib         port:libevent
depends_build-append port:bison

startupitem.create      yes
startupitem.executable  ${prefix}/sbin/iked -d

add_users           _iked group=_iked realname=OpenIKED\ Daemon

set sysconfdir ${prefix}/etc

configure.args-append \
                    -DCMAKE_INSTALL_SYSCONFDIR=${sysconfdir} \
                    -DCMAKE_INSTALL_MANDIR=${prefix}/share/man

post-patch {
    set openssl_install_area [openssl::install_area]
    reinplace "s|/usr/local/opt/openssl@1.1|${openssl_install_area}|g" ${worksrcpath}/CMakeLists.txt
    reinplace "s|/usr/local|${prefix}|g" ${worksrcpath}/CMakeLists.txt
}

post-destroot {
    file rename ${destroot}${sysconfdir}/iked.conf ${destroot}${sysconfdir}/iked.conf.dist
}

post-activate {
    if {![file exists ${sysconfdir}/iked.conf]} {
        file copy ${sysconfdir}/iked.conf.dist ${sysconfdir}/iked.conf
    }
}
