# -*- 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.8.2
    revision            0
    conflicts           ncdu1

    checksums           rmd160  c5ee5901db13b4b2b44619acfb1dd98a9c79da11 \
                        sha256  022fa765d35a79797acdc80c831707df43c9a3ba60d1ae3e6ea4cc1b7a2c013d \
                        size    72200

    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}
