# -*- 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                gnutar
version             1.35
revision            0

categories          archivers
maintainers         nomaintainer
license             GPL-3+
description         GNU version of the tar archiving utility
long_description    the gnutar program creates, adds files to, or extracts files from   \
                    an archive file in gnutar format, called a tarfile. A tarfile is    \
                    often a magnetic tape, but can be a floppy diskette or any regular  \
                    disk file.

homepage            https://www.gnu.org/software/tar/
master_sites        gnu:tar
distname            tar-${version}
use_xz              yes

checksums           rmd160  0422e1e15d720bea2626d0436c66bc0f095524b6 \
                    sha256  4d62ff37342ec7aed748535323930c7cf94acf71c3591882b26a7ea50f3edc16 \
                    size    2317208

platforms           darwin

# remove this in next update
patchfiles          patch-Makefile.patch \
                    patch-revert-63567.patch

depends_lib         port:gettext \
                    port:libiconv

depends_build       bin:makeinfo:texinfo \
                    port:help2man

use_autoreconf      yes
autoreconf.args     -fvi

configure.env-append FORCE_UNSAFE_CONFIGURE=1
configure.args      --disable-silent-rules \
                    --program-prefix=gnu \
                    --disable-year2038

test.run            yes
test.target         check

post-destroot {
    xinstall -v -m 0755 -d ${destroot}${prefix}/share/doc/${name}
    xinstall -v -m 0644 -W ${worksrcpath} ABOUT-NLS AUTHORS COPYING ChangeLog \
        ChangeLog.1 INSTALL NEWS README THANKS TODO \
        ${destroot}${prefix}/share/doc/${name}
    foreach f [glob ${destroot}${prefix}/share/info/tar.info*] {
        reinplace "s|(tar)|(gnutar)|g" $f
        reinplace -E "s/\[\[:<:\]\]tar\\.info\[\[:>:\]\]/gnutar.info/g" $f
        move ${f} [string map {tar.info gnutar.info} ${f}]
    }

    xinstall -m 0755 -d ${destroot}${prefix}/libexec/gnubin
    ln -sf ${prefix}/bin/gnutar ${destroot}${prefix}/libexec/gnubin/tar
    ln -sf ${prefix}/bin/gnutar ${destroot}${prefix}/bin/gtar

    xinstall -m 0755 -d ${destroot}${prefix}/libexec/gnubin/man/man1
    ln -sf ${prefix}/share/man/man1/gnutar.1.gz ${destroot}${prefix}/libexec/gnubin/man/man1/tar.1.gz
}

notes "
    The tool provided by GNU Tar are prefixed with the character 'g' by default to distinguish them from the BSD commands.
    For example, tar becomes gtar.

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

livecheck.type      regex
livecheck.url       https://ftp.gnu.org/gnu/tar/?C=M&O=D
livecheck.regex     tar-(\[0-9\.\]+\[0-9\])\\.
