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

PortSystem          1.0
name                monkeysphere
version             0.26
categories          net security
maintainers         nomaintainer
description         use the OpenPGP web of trust to verify ssh connections
long_description    SSH key-based authentication is tried-and-true, \
                    but it lacks a true Public Key Infrastructure for \
                    key certification, revocation and expiration. \
                    Monkeysphere is a framework that uses the OpenPGP \
                    web of trust for these PKI functions.  It can be \
                    used in both directions: for users to get \
                    validated host keys, and for hosts to authenticate \
                    users.
homepage            http://web.monkeysphere.info/
platforms           darwin

depends_run         bin:ssh:openssh \
                    port:gnupg \
                    port:p5-crypt-openssl-rsa \
                    port:p5-digest-sha \
                    port:procmail

master_sites        http://archive.monkeysphere.info/debian/pool/monkeysphere/m/monkeysphere/
distname            ${name}_${version}
extract.suffix      .orig.tar.gz
worksrcdir          ${name}-${version}
checksums           md5 f0e5fe66a9affd951e601ea5d6188972

use_configure       no

post-build {
    # update paths to SYS*DIRs
    exec sed -i .tmp -e "s|/etc/monkeysphere|${prefix}/etc/monkeysphere|g" \
        ${worksrcpath}/src/share/defaultenv \
        ${worksrcpath}/src/transitions/0.23 \
        ${worksrcpath}/man/man1/monkeysphere.1 \
        ${worksrcpath}/man/man8/monkeysphere-authentication.8 \
        ${worksrcpath}/man/man8/monkeysphere-host.8 \
        ${worksrcpath}/etc/monkeysphere-authentication.conf
    exec sed -i .tmp -e "s|/var/lib/monkeysphere|${prefix}/var/db/monkeysphere|g" \
        ${worksrcpath}/src/transitions/0.23 \
        ${worksrcpath}/man/man1/monkeysphere.1 \
        ${worksrcpath}/man/man8/monkeysphere-authentication.8 \
        ${worksrcpath}/man/man8/monkeysphere-host.8 \
        ${worksrcpath}/src/monkeysphere-host \
        ${worksrcpath}/src/monkeysphere-authentication \
        ${worksrcpath}/doc/getting-started-admin.mdwn
    exec sed -i .tmp -e "s|/usr/share/monkeysphere|${prefix}/share/monkeysphere|g" \
        ${worksrcpath}/src/monkeysphere-host \
        ${worksrcpath}/src/monkeysphere-authentication \
        ${worksrcpath}/src/monkeysphere

    # fix perl shebang line to point to macports perl install
    exec sed -i .tmp -e "s|^#!/usr/bin/perl -T$|#!/opt/local/bin/perl -T|" \
        ${worksrcpath}/src/share/keytrans \
        ${worksrcpath}/src/share/checkperms

    # remove leftover sed cruft
    exec find ${worksrcpath} -name *.tmp -delete
}

destroot.destdir    DESTDIR=${destroot}${prefix}
destroot.args       PREFIX=

# variant to use the port version of bash, which may be much newer
# than the one provided by the system
variant port-bash description {use port version of Bash} {
    depends_run-append port:bash
}