# -*- 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             0.0.20191012
revision            0
checksums           rmd160  fce033d725580c606145735a2f2f9cd4341cfe7d \
                    sha256  93573193c9c1c22fde31eb1729ad428ca39da77a603a3d81561a9816ccecfa8e \
                    size    331812

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/snapshot/
distname            WireGuard-${version}
use_xz              yes

depends_run         port:bash \
                    port:wireguard-go

use_configure       no

# only build and install the tools for macOS
build.pre_args      -C src/tools
build.target

destroot.pre_args   -C src/tools
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
}

livecheck.name      WireGuard
livecheck.url       https://git.zx2c4.com/WireGuard/refs/