# -*- 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/majd/ipatool 2.3.1 v
revision                0
categories              sysutils
license                 MIT
platforms               {darwin >= 21}
installs_libs           no
maintainers             {@TheRealKeto gmail.com:therealketo} openmaintainer

description             CLI for searching and downloading iOS app packages from the App Store
long_description        {*}${description}.

checksums               rmd160  3adc2270aafd50890ce70020e1347ada2579ffda \
                        sha256  2fe03975acd6eb184c3cc6e0bb5d49f973c39aa518d36279685f442c23e87956 \
                        size    723049

# Vendored libraries cause failure, fetch them at build time
go.offline_build        no

build.args-append       -ldflags \"-X ${go.package}/v2/cmd.version=${version}\"

post-build {
    # Generate shell completions for supported shells
    foreach shell {zsh bash fish} {
        system -W ${worksrcpath} "./${name} completion ${shell} > ${name}.${shell}"
    }
}

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

    set zsh_comp_path ${destroot}${prefix}/share/zsh/site-functions
    xinstall -d ${zsh_comp_path}
    xinstall -m 0644 ${worksrcpath}/${name}.zsh ${zsh_comp_path}/_${name}

    set bash_comp_path ${destroot}${prefix}/share/bash-completion/completions
    xinstall -d ${bash_comp_path}
    xinstall -m 0644 ${worksrcpath}/${name}.bash ${bash_comp_path}/${name}

    set fish_comp_path ${destroot}${prefix}/share/fish/vendor_completions.d
    xinstall -d ${fish_comp_path}
    xinstall -m 0644 ${worksrcpath}/${name}.fish ${fish_comp_path}
}
