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

name                    inetutils
version                 1.9.4
revision                11
categories              net
license                 GPL-3+
maintainers             {mps @Schamschula} openmaintainer
description             Inetutils is a collection of common network programs, including \
                        ftp, telnet, rsh, rlogin, tftp and the corresponding daemons.
long_description        ${description} Other tools include hostname, ifconfig, logger, \
                        ping, ping6, rcp, rexec, talk, traceroute and whois. Additional \
                        daemons include inetd, rexecd, syslogd and uucpd.
platforms               darwin
homepage                https://www.gnu.org/software/${name}/
master_sites            gnu:${name}
use_xz                  yes

checksums           rmd160  0c144d9ac0b5c07beca1e634fc5b2c5bae15917d \
                    sha256  849d96f136effdef69548a940e3e0ec0624fc0c81265296987986a0dd36ded37

depends_lib             port:readline

patchfiles              telnet_telnet.c.patch \
                        patch-ping-Makefile.in.diff \
                        patch-src-Makefile.in.diff

configure.args          --infodir=${prefix}/share/info \
                        --mandir=${prefix}/share/man \
                        --disable-servers

variant client description {Enable all clients (with g prefix)} {
    post-patch {
        # grsh has a hard reference to ${prefix}/bin/rlogin
        reinplace -locale C "s|/rlogin|/grlogin|g" ${worksrcpath}/paths
        reinplace -locale C "s|/rsh|/grsh|g" ${worksrcpath}/paths
    }

    configure.args-append   --program-prefix=g
    configure.args-delete   --disable-hostname \
                            --disable-ifconfig \
                            --disable-ping \
                            --disable-ping6 \
                            --disable-talk \
                            --disable-tftp \
                            --disable-traceroute \
                            --disable-logger \
                            --disable-whois

    post-destroot {
        file attributes ${destroot}${prefix}/bin/grcp -permissions +s
        file attributes ${destroot}${prefix}/bin/grlogin -permissions +s
        file attributes ${destroot}${prefix}/bin/grsh -permissions +s
    }

    notes "All clients are now installed with the \"g\" prefix."
}

variant server description {Enable server daemons} {
    configure.args-delete    --disable-servers
}

default_variants +client