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

name                    mosh
version                 1.2.6
revision                2
categories              net
license                 {GPL-3+ OpenSSLException}
platforms               darwin
maintainers             mit.edu:quentin
description             Mobile Shell
long_description        Mosh is a replacement for ssh that better handles \
                        high-latency, high-packet-loss, dynamically-addressed \
                        network links
homepage                http://mosh.org/
master_sites            ${homepage}

checksums               rmd160  4e06957083f9fcdd4c85b8f3b3b3407f734eed0d \
                        sha256  7e82b7fbfcc698c70f5843bb960dadb8e7bd7ac1d4d2151c9d979372ea850e85

perl5.require_variant   yes
perl5.conflict_variants yes
perl5.branches          5.24
perl5.default_branch    5.24
perl5.create_variants   ${perl5.branches}

depends_build           port:pkgconfig

depends_lib             path:lib/libssl.dylib:openssl \
                        port:ncurses \
                        port:p${perl5.major}-getopt-long \
                        port:p${perl5.major}-io-socket-ip \
                        port:protobuf-cpp \
                        port:zlib

post-patch {
    reinplace "s|#!/usr/bin/env perl|#!${prefix}/bin/perl${perl5.major}|" \
        ${worksrcpath}/scripts/mosh.pl
}

configure.args          --with-crypto-library=openssl

post-destroot {
    xinstall -d ${destroot}${prefix}/etc/bash_completion.d
    copy ${worksrcpath}/conf/bash-completion/completions/mosh \
         ${destroot}${prefix}/etc/bash_completion.d/mosh
}

livecheck.type          regex
livecheck.url           ${homepage}
livecheck.regex         "[quotemeta ${name}]-(\[0-9a-z.\]+)[quotemeta ${extract.suffix}]"