# -*- 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                gpatch
version             2.8
revision            1

categories          devel
license             GPL-3+
maintainers         {@aeiouaeiouaeiouaeiouaeiouaeiou outlook.com:aeioudev} openmaintainer

description         GNU patch, for applying diffs to files
long_description    Patch takes a patch file containing a difference listing \
                    produced by the diff program and applies those differences \
                    to one or more original files, producing patched versions.

homepage            https://www.gnu.org/software/patch/
master_sites        gnu:patch

distname            patch-${version}

checksums           rmd160  9b6b7b73dcdf85376d95367f5839ca1563405d72 \
                    sha256  7f51814e85e780b39704c9b90d264ba3515377994ea18a2fabd5d213e5a862bc \
                    size    1097157

use_bzip2           yes

configure.args-append \
                    --program-prefix=g \
                    --disable-year2038

post-destroot {
    xinstall -m 755 -d ${destroot}${prefix}/libexec/gnubin
    foreach binary [glob -tails -directory ${destroot}${prefix}/bin g*] {
        ln -s ${prefix}/bin/${binary} \
        ${destroot}${prefix}/libexec/gnubin/[string range $binary 1 end]
    }
    xinstall -m 755 -d ${destroot}${prefix}/libexec/gnubin/man/man1
    foreach manpage [glob -tails -directory ${destroot}${prefix}/share/man/man1 g*] {
        ln -s ${prefix}/share/man/man1/${manpage}.gz \
        ${destroot}${prefix}/libexec/gnubin/man/man1/[string range $manpage 1 end].gz
    }
}

notes "
The patch tool provided by this port is prefixed with the character 'g'
by default making it available as 'gpatch'.

If you want to use 'patch' and other GNU coreutils by default, add this
directory to the front of your PATH environment variable:
    ${prefix}/libexec/gnubin/
"
