# -*- 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

name                wireguard-tools
version             1.0.20210914
revision            1
checksums           rmd160  a989471297b6713c59dc3e850aee59fef9e4cd2a \
                    sha256  97ff31489217bb265b7ae850d3d0f335ab07d2652ba1feec88b734bc96bd05ac \
                    size    99744

categories          net
platforms           darwin
license             GPL-2
maintainers         {isi.edu:calvin @cardi} openmaintainer
description         Tools for the WireGuard VPN
long_description    \
    wireguard-tools contains command-line tools to interact with \
    the userspace Go implementation of WireGuard. Currently there \
    are two tools: wg, to set and retrieve configuration of \
    WireGuard interfaces, and wg-quick, set up a WireGuard interface \
    simply.

homepage            https://www.wireguard.com/
master_sites        https://git.zx2c4.com/wireguard-tools/snapshot/
distname            wireguard-tools-${version}
use_xz              yes

depends_run         port:bash \
                    port:wireguard-go

use_configure       no

build.pre_args      -C src
build.target

destroot.pre_args   -C src
destroot.args       install
destroot.post_args-append \
                    PREFIX=${prefix} \
                    SYSCONFDIR=${prefix}/etc \
                    WITH_BASHCOMPLETION=yes \
                    WITH_SYSTEMDUNITS=no \
                    WITH_WGQUICK=yes

post-destroot {
    set completions_path \
                    ${prefix}/share/bash-completion/completions
    set sysconfdir  ${prefix}/etc
    reinplace -E "s|^\(CONFIG_SEARCH_PATHS=.*\)\(/usr/local/etc\)|\\1${sysconfdir}|" ${destroot}${prefix}/bin/wg-quick
    reinplace -E "s|\(search_paths\\+=.*\)\(/usr/local/etc\)|\\1${sysconfdir}|" ${destroot}${completions_path}/wg-quick
    xinstall -d ${destroot}${sysconfdir}/wireguard
    copy ${filespath}/wg0.conf.example ${destroot}${sysconfdir}/wireguard
}

livecheck.name      wireguard-tools
livecheck.url       https://git.zx2c4.com/wireguard-tools/refs/