# -*- 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                ncdu
categories          sysutils
maintainers         {snc @nerdling} {judaew @judaew} openmaintainer
license             MIT

description         NCurses Disk Usage
long_description    ncdu is an ncurses version of the famous old 'du' unix \
                    command. It provides a fast and easy interface to your \
                    harddrive. Where is your disk space going? Why is your \
                    home directory that large? ncdu can answer those questions \
                    for you in just a matter of seconds!
platforms           darwin freebsd
homepage            https://dev.yorhel.nl/ncdu
master_sites        https://dev.yorhel.nl/download/

depends_lib         port:ncurses

subport ncdu1 {
    version             1.20
    revision            0
    conflicts           ncdu

    checksums           rmd160  e0895e433ff924202dfec865a2a091208ef1e586 \
                        sha256  5fe2bb841abe72374bb242dbb93293c4ae053078432d896a7481b2ff10be9572 \
                        size    150835

    livecheck.url       ${homepage}/changes
}

if {${subport} eq ${name}} {
    version             2.9.1
    revision            0
    conflicts           ncdu1

    checksums           rmd160  7334d6e3cc6eadd6dc861a707965545930d3f547 \
                        sha256  bfd1094e1400ee89cfd59200eab940f025ccdc0c238067105c984a3c4857bf7e \
                        size    74334

    depends_build-append \
                        port:zig
    depends_lib         port:zstd

    use_configure       no

    # Build manually using `zig cc`. The standard build with the patch that adds
    # the --search-prefix option doesn't work. See:
    # https://trac.macports.org/ticket/66044
    build.cmd           ${prefix}/bin/zig cc
    build.args          -I${prefix}/include -L${prefix}/lib -lncursesw -lzstd
    build.target        -o ncdu src/main.zig

    destroot {
        xinstall -m 0755 ${worksrcpath}/${name} \
            ${destroot}${prefix}/bin

        xinstall -m 0644 ${worksrcpath}/${name}.1 \
            ${destroot}${prefix}/share/man/man1
    }

    livecheck.url       ${homepage}/changes2
}

test.run            yes
test.cmd            ./ncdu --version

livecheck.regex     ${name}-(\\d\\.\\d+(?:\\.\\d+)*)${extract.suffix}
