# -*- 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.20250521
revision            0
checksums           rmd160  dcf5c503db9c41c95f8fe99d7bb506fac9a2f485 \
                    sha256  b6f2628b85b1b23cc06517ec9c74f82d52c4cdbd020f3dd2f00c972a1782950e \
                    size    100340

categories          net
platforms           darwin
license             GPL-2
maintainers         {acm.org:cardi @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/
