# -*- 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.2.0 v
revision                0
categories              sysutils
license                 MIT
platforms               {darwin >= 19}
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  6acb0696c223cdaa4776f7b15d3f18bc7a87746a \
                        sha256  676cd6bd039c25fe649a35ea86977706c0818442624da87c7f4285257cc7aa12 \
                        size    710406

# 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}
}
