# -*- 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.1
revision            0

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  ce213e4098b010889457deb4b433582a54038c0b \
                    sha256  3240c7959c5347c8ed347e3c4201c0337bf4240d5cf09d68889e58eeaba30e17 \
                    size    940364

use_xz              yes

configure.args-append \
                    --program-prefix=g \
                    --disable-silent-rules \
                    --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/
"
