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

name                py-awscli
version             1.19.49
revision            0

categories          python devel
platforms           darwin
supported_archs     noarch
license             Apache-2
maintainers         {outlook.de:judaew @judaew} openmaintainer

description         Universal Command Line Environment for Amazon Web Services.
long_description    {*}${description}

homepage            https://aws.amazon.com/cli/

checksums           rmd160  28a7ee15a628e0efd788a4e011abdc363117aa4f \
                    sha256  4a2137b76ea0891c0d3091c6a5e4b310ed271635d2f9b9ace2947274e1964322 \
                    size    1409206

python.versions     27 36 37 38 39

if {${name} ne ${subport}} {
    depends_build-append \
                        port:py${python.version}-setuptools

    depends_lib-append \
                        port:py${python.version}-botocore \
                        port:py${python.version}-colorama \
                        port:py${python.version}-docutils \
                        port:py${python.version}-rsa \
                        port:py${python.version}-s3transfer \
                        port:py${python.version}-yaml

    depends_run-append  port:awscli_select

    select.group        awscli
    select.file         ${worksrcpath}/py${python.version}-awscli

    post-extract {
        copy -force ${filespath}/awscli ${worksrcpath}/py${python.version}-awscli
    }

    post-patch {
        reinplace \
            "s,@PYTHON_BRANCH@,${python.branch},g" \
             ${worksrcpath}/${subport}
    }

    post-destroot {
        delete ${destroot}${prefix}/bin/aws.cmd-${python.branch}
    }

    default_variants +bash_completion

    variant bash_completion {
        post-destroot {
            set bash_compl_path ${prefix}/share/bash-completion/completions
            xinstall -d ${destroot}${bash_compl_path}
            xinstall -m 0644 ${worksrcpath}/bin/aws_bash_completer \
                ${destroot}${bash_compl_path}/aws
        }
    }

    variant zsh_completion {
        post-destroot {
            set zsh_compl_path ${prefix}/share/zsh/site-functions
            xinstall -d ${destroot}${zsh_compl_path}
            xinstall -m 0644 ${worksrcpath}/bin/aws_zsh_completer.sh \
                ${filespath}/_aws \
                ${destroot}${zsh_compl_path}
        }
    }

    notes "
To make the Python ${python.branch} version of AWS CLI the one that is run when\
you execute the commands without a version suffix, e.g. 'aws', run:

port select --set ${select.group} [file tail ${select.file}]
"

    livecheck.type      none
}
