# -*- 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.2.7 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  2f0ff58a661a7c307afff5e4294e86ca2527d4cc \
                    sha256  308743bc9fe871b902d47dbe98d749daff3a05b27531684f02625ce7208d4598 \
                    size    94087

# diff -Naurd ./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

post-patch {
    foreach item { easyrsa doc/EasyRSA-Advanced.md } {
        reinplace "s|@PREFIX@|${prefix}|g" ${worksrcpath}/${item}
    }
}

depends_run-append  path:bin/openssl:openssl

use_configure       no

build {}

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}
}
