# -*- 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-ansible-core
version             2.18.1
distname            ansible_core-${version}
revision            0
license             GPL-3+

categories-append   sysutils
supported_archs     noarch
platforms           {darwin any}

maintainers         {adfernandes @adfernandes} {gmail.com:pedro.salgado @steenzout} openmaintainer

homepage            https://github.com/ansible/ansible
description         SSH-based configuration management and deployment system

checksums           rmd160  61fb99987fb8f6aac69a2c170f471b6b5658bef5 \
                    sha256  14cac1f92bbdae881cb0616eddeb17925e8cb507e486087975e724533d9de74f \
                    size    3069965

long_description \
    Ansible is a radically simple model-driven configuration \
    management, multi-node deployment, and remote task execution \
    system.  Ansible works over SSH and does not require any software \
    or daemons to be installed on remote nodes.  Extension modules can \
    be written in any language and are transferred to managed machines \
    automatically.

python.versions     39 310 311 312 313

if {${name} ne ${subport}} {
    patch {
        # This fixes ansible_core 2.18.1 to be compatible with the setuptools >75.6.0
        # This linke should be removed or modified in the future when py-ansible-core is updated
        reinplace -q "s#, <= 75.6.0##g" pyproject.toml

        fs-traverse f ${worksrcpath} {
            if {[file isfile ${f}] && [regexp {\.(py|yml|yaml)$} ${f} match]} {
                reinplace -q "s#/etc/ansible#${prefix}/etc/ansible#g" ${f}
                reinplace -q "s#/usr/share/ansible#${prefix}/share/ansible#g" ${f}
            }
        }
    }
    depends_lib-append  port:py${python.version}-six \
                        port:py${python.version}-paramiko \
                        port:py${python.version}-httplib2 \
                        port:py${python.version}-jinja2 \
                        port:py${python.version}-yaml \
                        port:py${python.version}-setuptools \
                        port:py${python.version}-cryptography \
                        port:py${python.version}-packaging \
                        port:py${python.version}-resolvelib \
                        port:ansible_select
    select.group    ansible
    select.file     ${filespath}/py${python.version}-ansible
    build.env-append    ANSIBLE_SKIP_CONFLICT_CHECK=1
    destroot.env-append ANSIBLE_SKIP_CONFLICT_CHECK=1

    # since ansible-connection was removed in 2.18.1, any symlinks to
    # it should be removed on upgrade
    post-destroot {
        if {[file exists ${prefix}/bin/ansible-connection-${python.version}]} {
            file delete ${prefix}/bin/ansible-connection-${python.version}
        }
    }

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

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