# -*- 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
PortGroup           golang 1.0

go.setup            github.com/anchore/syft 1.57.0 v
go.offline_build    no
go.toolchain_min    1.26.8
revision            0

description         \
    A CLI tool and library for generating a Software Bill of \
    Materials (SBOM) from container images and filesystems

long_description    \
    {*}${description}. Syft supports dozens of packaging \
    ecosystems, multiple image sources, and output formats \
    including CycloneDX, SPDX, and Syft JSON. Exceptional for \
    vulnerability detection when used with a scanner like Grype.

categories          security sysutils
installs_libs       no
license             Apache-2
maintainers         {sub-pop.net:link @subpop} \
                    openmaintainer

checksums           rmd160  b8517b37170b33f581e89111545c5f86c6e06a14 \
                    sha256  04f03d36dd080677127ca4b00eb3189d4447d5f9a26e7746f3011c66edf7a8a5 \
                    size    7731889

build.args-append   -ldflags \"-X main.version=${version} \
                               -X main.gitCommit=macports-release \
                               -X main.buildDate=${source_date_epoch}\" \
                    -o ./dist/${name}

build.post_args-append \
                    ./cmd/${name}

post-build {
    foreach shell {bash fish zsh} {
        system -W ${worksrcpath} "./dist/${name} completion ${shell} > syft.${shell}"
    }
}

destroot {
    xinstall -m 755 ${worksrcpath}/dist/${name} ${destroot}${prefix}/bin
    foreach {shell completion_path} [list \
        bash    share/bash-completion/completions/${name} \
        fish    share/fish/vendor_completions.d/${name}.fish \
        zsh     share/zsh/site-functions/_${name} \
    ] {
        xinstall -d ${destroot}${prefix}/[file dirname ${completion_path}]
        xinstall -m 644 ${worksrcpath}/${name}.${shell} ${destroot}${prefix}/${completion_path}
    }
}
