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

github.setup        certbot certbot 4.2.0 v
revision            0
categories          security
license             Apache-2
maintainers         {mps @Schamschula} openmaintainer
description         An ACME Let's Encrypt client that can obtain certs and extensibly \
                    update server configurations.
long_description    {*}${description}
homepage            https://certbot.eff.org/

supported_archs     noarch
platforms           {darwin any}

checksums           rmd160  001e28b28e72af3460714422912b82567010abcb \
                    sha256  fb1e56ca8a072bec49ac0c7b5390a29cbf68c2c05f712259a9b3491de041c27b \
                    size    442984

variant python39 conflicts python310 python311 python312 python313 description {Use Python 3.9} {}
variant python310 conflicts python39 python311 python312 python313 description {Use Python 3.10} {}
variant python311 conflicts python39 python310 python312 python313 description {Use Python 3.11} {}
variant python312 conflicts python39 python310 python311 python313 description {Use Python 3.12} {}
variant python313 conflicts python39 python310 python311 python312 description {Use Python 3.13} {}

if {![variant_isset python39] && ![variant_isset python310] && \
        ![variant_isset python311] && ![variant_isset python312]} {
    default_variants +python313
}

foreach pv {313 312 311 310 39} {
    if {[variant_isset python${pv}]} {
        python.default_version ${pv}
        break
    }
}

depends_lib-append  port:py${python.version}-acme \
                    port:py${python.version}-configargparse \
                    port:py${python.version}-configobj \
                    port:py${python.version}-cryptography \
                    port:py${python.version}-distro \
                    port:py${python.version}-openssl \
                    port:py${python.version}-parsedatetime \
                    port:py${python.version}-pyrfc3339 \
                    port:py${python.version}-tz

subport ${name} {
    post-patch {
        reinplace "s|/etc/|${prefix}/etc/|" ${worksrcpath}/src/certbot/compat/misc.py
        reinplace "s|/var/lib/|${prefix}/var/db/|" ${worksrcpath}/src/certbot/compat/misc.py
        reinplace "s|/var/log/|${prefix}/var/log/|" ${worksrcpath}/src/certbot/compat/misc.py
    }

    variant docs description {Build man pages} {
        depends_lib-append \
            port:py${python.version}-repoze.sphinx.autointerface \
            port:py${python.version}-sphinx \
            port:py${python.version}-sphinx_rtd_theme

        post-build {
            set env(doc_path) ${worksrcpath}/docs
            set env(python_branch) ${python.branch}
            exec sh -c {cd $doc_path && sphinx-build-$python_branch -N -b man . _build/man} >@stdout
        }

        post-destroot {
            xinstall -d ${destroot}${prefix}/share/man/man1
            xinstall -d ${destroot}${prefix}/share/man/man7
            xinstall -m 640 ${worksrcpath}/docs/_build/man/certbot.1 \
                ${destroot}${prefix}/share/man/man1/
            xinstall -m 640 ${worksrcpath}/docs/_build/man/certbot.7 \
                ${destroot}${prefix}/share/man/man7/
        }
    }
}

#
# integration with local webservers
# for use with "http-01 challenge"
#

subport ${name}-apache {
    description         The certbot Apache plugin for http-01 challenges
    long_description    The Apache plugin currently supports modern OSes based on Debian, \
                        Fedora, SUSE, Gentoo and Darwin. This automates both obtaining \
                        and installing certificates on an Apache webserver. To specify \
                        this plugin on the command line, simply include \"--apache\". \
                        https://certbot.eff.org/docs/using.html\#apache

    distname            ${name}_apache-${version}

    checksums       rmd160  ce9f94107f60dfe729003aa2a850285832fe65c1 \
                    sha256  b1588a5d278cb1182c0a18d182f5d3994701e784f28da5546fcd8bab54fcf411 \
                    size    183639

    depends_lib-append  port:mod_perl2 \
                        port:py${python.version}-python-augeas
}

subport ${name}-nginx {
    description         The certbot Nginx plugin for http-01 challenges
    long_description    The Nginx plugin should work for most configurations. We \
                        recommend backing up Nginx configurations before using it (though \
                        you can also revert changes to configurations with \
                        \"certbot --nginx rollback\"). You can use it by providing the \
                        \"--nginx\" flag on the commandline. \
                        https://certbot.eff.org/docs/using.html\#nginx

    distname            ${name}_nginx-${version}

    checksums       rmd160  a95fbdf4b6df7ccf0be8f1ea90661c545ad75cd5 \
                    sha256  83ef0a9b16616b908905fb61fabbe49cebfc4c33cda1983347ed3ab570b4abf6 \
                    size    80178

    depends_lib-append  port:py${python.version}-parsing

    patchfiles          patch-certbot-nginx-certbot_nginx-constants.py.diff

    post-patch {
        reinplace "s|%PREFIX%|${prefix}|" \
        ${worksrcpath}/src/certbot_nginx/_internal/constants.py
    }
}

#
# integration with dns-servers
# for use with "dns-01 challenge"
#

subport ${name}-dns-cloudflare {
    description         The certbot dns_cloudflare plugin for dns-01 challenges
    long_description    The dns_cloudflare plugin automates the process of completing a \
                        dns-01 challenge (DNS01) by creating, and subsequently removing, \
                        TXT records using the Cloudflare API. \
                        https://certbot-dns-cloudflare.readthedocs.io/

    distname            ${name}_dns_cloudflare-${version}

    checksums       rmd160  6e5e2c091d45b2c57621f05ffb83eee83b1c7156 \
                    sha256  010b9c9d8f33988c4e87c40155b57ffc16157c14e4f92f9f839bed0423bd04d3 \
                    size    16210

    depends_lib-append  port:py${python.version}-cloudflare2
}

subport ${name}-dns-digitalocean {
    description         The certbot dns_digitalocean plugin for dns-01 challenges
    long_description    The dns_digitalocean plugin automates the process of completing \
                        a dns-01 challenge (DNS01) by creating, and subsequently \
                        removing, TXT records using the DigitalOcean API. \
                        https://certbot-dns-digitalocean.readthedocs.io/

    distname            ${name}_dns_digitalocean-${version}

    checksums       rmd160  cb6c2a6d04f24de68ed1de65fa929d20ef89b950 \
                    sha256  a92c9d40353f08d4093de5861f454d9657e5e1480026fc081a31263bf8a029ef \
                    size    14397

    depends_lib-append  port:py${python.version}-digitalocean
}

subport ${name}-dns-dnsimple {
    description         The certbot dns_dnsimple plugin for dns-01 challenges
    long_description    The dns_dnsimple plugin automates the process of completing a \
                        dns-01 challenge (DNS01) by creating, and subsequently removing, \
                        TXT records using the DNSimple API. \
                        https://certbot-dns-dnsimple.readthedocs.io/

    distname            ${name}_dns_dnsimple-${version}

    checksums       rmd160  8a3ce7573a7ccfce516b9b4673ecd5874294fc74 \
                    sha256  a41172cba48250c321b4365d0952a01c6d1ab72d755e30c9498fa661db1f398f \
                    size    12045

    depends_lib-append  port:py${python.version}-dns-lexicon
}

subport ${name}-dns-dnsmadeeasy {
    description         The certbotdns_dnsmadeeasy  plugin for dns-01 challenges
    long_description    The dns_dnsmadeeasy plugin automates the process of completing a \
                        dns-01 challenge (DNS01) by creating, and subsequently removing, \
                        TXT records using the DNS Made Easy API. \
                        https://certbot-dns-dnsmadeeasy.readthedocs.io/

    distname            ${name}_dns_dnsmadeeasy-${version}

    checksums       rmd160  9c89b4f39f37a6a30ae512f78f09ef734faac474 \
                    sha256  101cad8775bb2a34072210a3e4d206fbfee4dff7100b01ae8fada275f58107a4 \
                    size    12202

    depends_lib-append  port:py${python.version}-dns-lexicon
}

subport ${name}-dns-gehirn {
    description         The certbot gehirn plugin for dns-01 challenges
    long_description    The dns_gehirn plugin automates the process of completing a \
                        dns-01 challenge (DNS01) by creating, and subsequently removing, \
                        TXT records using the Gehirn Infrastracture Service DNS API. \
                        https://certbot-dns-gehirn.readthedocs.io/

    distname            ${name}_dns_gehirn-${version}

    checksums       rmd160  9ea60405f86084abe5e9b0d3e065ebac75147a46 \
                    sha256  ae9678049e5b39d714a178240b567a52702c19495c7074c2884a49a91aac2dc5 \
                    size    12112

    depends_lib-append  port:py${python.version}-dns-lexicon
}

subport ${name}-dns-google {
    description         The certbot google plugin for dns-01 challenges
    long_description    The dns_google plugin automates the process of completing a \
                        dns-01 challenge (DNS01) by creating, and subsequently removing, \
                        TXT records using the Google Cloud DNS API. \
                        https://certbot-dns-google.readthedocs.io/

    distname            ${name}_dns_google-${version}

    checksums       rmd160  7f91c0b0e51e662c000b3567f9221b27efe83656 \
                    sha256  7e0ee4712ede9ea0b4222b9bca2713aad47bc975d8ff2c58012245f31d4c915f \
                    size    25132

    depends_lib-append  port:py${python.version}-google-api-python-client \
                        port:py${python.version}-google-auth
}

subport ${name}-dns-linode {
    description         The certbot linode plugin for dns-01 challenges
    long_description    The dns_linode plugin automates the process of completing a \
                        dns-01 challenge (DNS01) by creating, and subsequently removing, \
                        TXT records using the Linode API. \
                        https://certbot-dns-linode.readthedocs.io/

    distname            ${name}_dns_linode-${version}

    checksums       rmd160  f0a19e39d45f6cacaae10d96ed33c8eb892f3b4e \
                    sha256  74a7f3cee605bdfe236112648dbd6bc23ea587fdad8f112d5383cd4ddd2417f2 \
                    size    12322

    depends_lib-append  port:py${python.version}-dns-lexicon
}

subport ${name}-dns-luadns {
    description         The certbot luadns plugin for dns-01 challenges
    long_description    The dns_luadns plugin automates the process of completing a \
                        dns-01 challenge (DNS01) by creating, and subsequently removing, \
                        TXT records using the LuaDNS API. \
                        https://certbot-dns-luadns.readthedocs.io/

    distname            ${name}_dns_luadns-${version}

    checksums       rmd160  48eda378fedd266a670f4907cb5d819a5c8da5fc \
                    sha256  4d82997d65e752dc4d469eb88f08f6dc94f9645f18b653e858f7c506f6695c78 \
                    size    12070
}

subport ${name}-dns-nsone {
    description         The certbot nsone plugin for dns-01 challenges
    long_description    The dns_nsone plugin automates the process of completing a \
                        dns-01 challenge (DNS01) by creating, and subsequently removing, \
                        TXT records using the NS1 API. \
                        https://certbot-dns-nsone.readthedocs.io/

    distname            ${name}_dns_nsone-${version}

    checksums       rmd160  52894622da8b75f3dfaab5871b11e63ffd9d6ad1 \
                    sha256  fc21244e6fbd7b57a3d782499cf105de27a8045dde456be20cfcc2849a6a3e54 \
                    size    12111

    depends_lib-append  port:py${python.version}-dns-lexicon
}

subport ${name}-dns-ovh {
    description         The certbot ovh plugin for dns-01 challenges
    long_description    The dns_ovh plugin automates the process of completing a \
                        dns-01 challenge (DNS01) by creating, and subsequently removing, \
                        TXT records using the OVH API. \
                        https://certbot-dns-ovh.readthedocs.io/

    distname            ${name}_dns_ovh-${version}

    checksums       rmd160  826db64a82a9999adc479937f1e3065b229aa1a9 \
                    sha256  0168f064ad7a73bf97615c9d11788b006d229ea600fac84b564f7e5cd7cec8c3 \
                    size    12477

    depends_lib-append  port:py${python.version}-dns-lexicon
}

subport ${name}-dns-rfc2136 {
    description         The certbot rfc2136 plugin for dns-01 challenges
    long_description    The dns_rfc2136 plugin automates the process of completing a \
                        dns-01 challenge (DNS01) by creating, and subsequently removing, \
                        TXT records using RFC 2136 Dynamic Updates. \
                        https://certbot-dns-rfc2136.readthedocs.io/

    distname            ${name}_dns_rfc2136-${version}

    checksums       rmd160  4ceec812c139b7bb4cda2e2629b0bc618e8f7f67 \
                    sha256  6044ead6386be61895faee28225df4b20be0868057404f369ef92dcfbaeb73a6 \
                    size    16777

    depends_lib-append  port:py${python.version}-dnspython
}

subport ${name}-dns-route53 {
    description         The certbot route53 plugin for dns-01 challenges
    long_description    The dns_route53 plugin automates the process of completing a \
                        dns-01 challenge (DNS01) by creating, and subsequently removing, \
                        TXT records using the Amazon Web Services Route 53 API. \
                        https://certbot-dns-route53.readthedocs.io/

    distname            ${name}_dns_route53-${version}

    checksums       rmd160  e2cc6214b4733e0201c83ce3a9f6f2a7aa5ded4d \
                    sha256  fc0e59ad7e0f04c373e6e412da4d90fc6f5eec7317eb94e0b785367830e6daea \
                    size    15490

    depends_lib-append  port:py${python.version}-boto3
}

subport ${name}-dns-sakuracloud {
    description         The certbot sakuracloud plugin for dns-01 challenges
    long_description    The dns_sakuracloud plugin automates the process of completing a \
                        dns-01 challenge (DNS01) by creating, and subsequently removing, \
                        TXT records using the Sakura Cloud DNS API. \
                        https://certbot-dns-sakuracloud.readthedocs.io/

    distname            ${name}_dns_sakuracloud-${version}

    checksums       rmd160  250d0257753aa1cb802c1715edd34ddc1d04841d \
                    sha256  f858be1b397d53b5789dd39a85ea819d8fea8beea3f0714bb1e80aa2ea2e629f \
                    size    12108

    depends_lib-append  port:py${python.version}-dns-lexicon
}
