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

name                signing-party
version             2.11
revision            1
checksums           rmd160  58289ade13f85ec20d65d75569cdda5e774f6bee \
                    sha256  52264331726025f413db8747795d33ef36fef318b3191a1baedfb5f59a6b534f \
                    size    224706

categories          mail security
maintainers         {cal @neverpanic} openmaintainer
platforms           darwin
description         Various OpenPGP related tools
long_description    signing-party is a collection for all kinds of PGP/GnuPG \
                    related things, including signing scripts, party \
                    preparation scripts, etc.

homepage            https://salsa.debian.org/signing-party-team/signing-party
license             BSD GPL-2 GPL-2+
master_sites        debian:s/signing-party/
distname            ${name}_${version}
worksrcdir          ${name}-${version}
extract.suffix      .orig.tar.gz

patchfiles          fix-sed-syntax.patch \
                    gpgwrap-makefile-usingtherightcompiler.patch

use_configure       no

depends_build       port:automake \
                    port:autoconf

perl5.major         5.34
depends_lib         port:perl${perl5.major} \
                    port:p${perl5.major}-class-methodmaker \
                    port:p${perl5.major}-mailtools \
                    port:p${perl5.major}-term-readkey \
                    port:p${perl5.major}-gnupg-interface \
                    port:p${perl5.major}-text-iconv \
                    port:p${perl5.major}-text-template \
                    port:p${perl5.major}-mime-tools \
                    port:p${perl5.major}-net-idn-encode \
                    port:qprint \
                    port:libmd
depends_run         path:bin/gpg:gnupg2 \
                    port:dialog \
                    port:python38

# The build scripts assume that DEB_VERSION_UPSTREAM is set to the version
# number, which is presumably true in Debian but is not true elsewhere.
# This bug needs to be reported to the developers but I am unable to locate
# their bug tracker.
build.args          DEB_VERSION_UPSTREAM=${version}

variant universal   {}
build.env-append    "CC=${configure.cc} -I${prefix}/include/libmd" \
                    "CFLAGS=${configure.cflags} [get_canonical_archflags]"

pre-build {
    reinplace "s|/usr/bin/perl|${perl5.bin}|g" \
        ${worksrcpath}/caff/caff \
        ${worksrcpath}/caff/pgp-clean \
        ${worksrcpath}/caff/pgp-fixkey \
        ${worksrcpath}/gpg-key2latex/gpg-key2latex \
        ${worksrcpath}/gpg-key2ps/gpg-key2ps \
        ${worksrcpath}/gpgdir/gpgdir \
        ${worksrcpath}/gpgdir/install.pl \
        ${worksrcpath}/gpglist/gpglist \
        ${worksrcpath}/gpgsigs/gpgsigs \
        ${worksrcpath}/keyanalyze/scripts/htmlify_report \
        ${worksrcpath}/keyanalyze/scripts/top50.pl \
        ${worksrcpath}/keyanalyze/willy/cosign \
        ${worksrcpath}/keyanalyze/willy/msd2html \
        ${worksrcpath}/keyanalyze/willy/non-recip \
        ${worksrcpath}/keyanalyze/willy/party-table.pl \
        ${worksrcpath}/keyanalyze/willy/unsign \
        ${worksrcpath}/keylookup/keylookup \
        ${worksrcpath}/sig2dot/sig2dot \
        ${worksrcpath}/springgraph/springgraph
    reinplace "s|/usr/bin/python3|${prefix}/bin/python3.8|g" \
        ${worksrcpath}/keyart/keyart \
        ${worksrcpath}/gpgparticipants/gpgparticipants-prefill
}

platform macosx {
    post-patch {
        reinplace "s!getent.*$!dscl . -read /Users/\$USER \| awk \'\{print \$2\}\'\`!" ${worksrcpath}/gpg-mailkeys/gpg-mailkeys
    }
}

destroot {
        # install executables
        xinstall -m 0755 \
            ${worksrcpath}/caff/caff \
            ${worksrcpath}/caff/pgp-clean \
            ${worksrcpath}/caff/pgp-fixkey \
            ${worksrcpath}/gpg-key2ps/gpg-key2ps \
            ${worksrcpath}/gpg-mailkeys/gpg-mailkeys \
            ${worksrcpath}/gpglist/gpglist \
            ${worksrcpath}/gpgparticipants/gpgparticipants \
            ${worksrcpath}/gpgparticipants/gpgparticipants-prefill \
            ${worksrcpath}/gpgsigs/gpgsigs \
            ${worksrcpath}/gpgwrap/bin/gpgwrap \
            ${worksrcpath}/keyanalyze/keyanalyze \
            ${worksrcpath}/keyanalyze/pgpring/pgpring \
            ${worksrcpath}/keyanalyze/process_keys \
            ${worksrcpath}/keyart/keyart \
            ${worksrcpath}/keylookup/keylookup \
            ${worksrcpath}/sig2dot/sig2dot \
            ${worksrcpath}/springgraph/springgraph \
            ${destroot}${prefix}/bin
        # install manpages
        xinstall -m 0644 \
            ${worksrcpath}/caff/caff.1 \
            ${worksrcpath}/caff/pgp-clean.1 \
            ${worksrcpath}/caff/pgp-fixkey.1 \
            ${worksrcpath}/gpg-key2ps/gpg-key2ps.1 \
            ${worksrcpath}/gpg-mailkeys/gpg-mailkeys.1 \
            ${worksrcpath}/gpglist/gpglist.1 \
            ${worksrcpath}/gpgparticipants/gpgparticipants-prefill.1 \
            ${worksrcpath}/gpgparticipants/gpgparticipants.1 \
            ${worksrcpath}/gpgsigs/gpgsigs.1 \
            ${worksrcpath}/gpgwrap/doc/gpgwrap.1 \
            ${worksrcpath}/keyanalyze/keyanalyze.1 \
            ${worksrcpath}/keyanalyze/pgpring/pgpring.1 \
            ${worksrcpath}/keyanalyze/process_keys.1 \
            ${worksrcpath}/keyart/doc/keyart.1 \
            ${worksrcpath}/keylookup/keylookup.1 \
            ${worksrcpath}/sig2dot/sig2dot.1 \
            ${worksrcpath}/springgraph/springgraph.1 \
            ${destroot}${prefix}/share/man/man1
        # install example configurations and scripts in share/doc
        xinstall -d -m 0755 \
            ${destroot}${prefix}/share/doc/${name} \
            ${destroot}${prefix}/share/doc/${name}/examples \
            ${destroot}${prefix}/share/doc/${name}/examples/keyanalyze \
            ${destroot}${prefix}/share/doc/${name}/examples/keyart
        xinstall -m 0644 \
            ${worksrcpath}/caff/caffrc.sample \
            ${worksrcpath}/gpg-mailkeys/example.gpg-mailkeysrc \
            ${destroot}${prefix}/share/doc/${name}
        copy \
            ${worksrcpath}/keyanalyze/scripts \
            ${worksrcpath}/keyanalyze/willy \
            ${worksrcpath}/keyanalyze/analyze.sh \
            ${destroot}${prefix}/share/doc/${name}/examples/keyanalyze
        copy \
            ${worksrcpath}/keyart/doc/druken-bishop.txt \
            ${worksrcpath}/keyart/doc/examples \
            ${worksrcpath}/keyart/doc/party-worksheet \
            ${destroot}${prefix}/share/doc/${name}/examples/keyart
}

notes               "Some example configuration files have been installed to ${prefix}/share/doc/signing-party."

livecheck.type      regex
livecheck.url       http://packages.debian.org/unstable/misc/${name}
livecheck.regex     ${name} .(\[0-9.\]+)
