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

github.setup        OpenVPN easy-rsa 3.1.5 v
categories          security
platforms           any
supported_archs     noarch
license             GPL-2
maintainers         {dottedmag.net:dottedmag @dottedmag} openmaintainer
description         Command-line CA tool
long_description    Command-line CA tool from OpenVPN project

distname            EasyRSA-${version}
extract.suffix      .tgz
github.tarball_from releases

checksums           rmd160  a54fe20cb1ecdf57fb888e01fe9e7340e5fae1db \
                    sha256  9fc6081d4927e68e9baef350e6b3010c7fb4f4a5c3e645ddac901081eb6adbb2 \
                    size    75808

# diff -NaurdwB ./easy-rsa-orig ./easy-rsa-new | sed -E -e 's/\.\/.+-(orig|new)/\./' | sed -E -e 's|/opt/local|@PREFIX@|g' > ~/Downloads/patch-set-macports-paths.diff
patchfiles          patch-set-macports-paths.diff

depends_run-append  path:bin/openssl:openssl

use_configure       no

build {}

post-patch {
    reinplace "s|@PREFIX@|${prefix}|g" ${worksrcpath}/easyrsa
    reinplace "s|@PREFIX@|${prefix}|g" ${worksrcpath}/vars.example
}

destroot {
    xinstall -m 0755 ${worksrcpath}/easyrsa ${destroot}${prefix}/bin

    xinstall -d ${destroot}${prefix}/share/${name}/x509-types
    xinstall -m 0664 -W ${worksrcpath} openssl-easyrsa.cnf vars.example \
        ${destroot}${prefix}/share/${name}
    xinstall -m 0664 {*}[glob ${worksrcpath}/x509-types/*] \
        ${destroot}${prefix}/share/${name}/x509-types

    xinstall -d ${destroot}${prefix}/share/doc/${name}
    xinstall -m 0664 -W ${worksrcpath} COPYING.md ChangeLog gpl-2.0.txt \
        README.quickstart.md ${destroot}${prefix}/share/doc/${name}
    xinstall -m 0664 {*}[glob ${worksrcpath}/doc/*] \
        ${destroot}${prefix}/share/doc/${name}
}