# -*- 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.20.0
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  ba272f91b4677ada3c1b6bd72c7e247e0fc245cc \
                    sha256  cd73faf28a056c933bc1eee8f66ab597e7ec7309d42c8a6e5d6e4294c4a78b54 \
                    size    3315281

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     310 311 312 313 314

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}]
"
}
