# -*- 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.1.1 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  e4af0f43f2105e5d5ed3a1fa7a311ae641bf36d4 \
                    sha256  d1fdde3174bcf1d68f7a8dca070341acec28b78ef92ad2dd18b8d49959e96779 \
                    size    441624

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  4fdecc650ab839de2a2b6919784f3000f15554e4 \
                    sha256  8b43f9f4b3cb504109cae58b7b8edbadb62bd3fbb1e796fe17ea426a7195b41f \
                    size    183384

    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  da7c63d8d6aff73c06cdc8be1665e26d520341f1 \
                    sha256  9b03a0c877d8004bc8b077d6aa8419257300a23c7d72f9d8fe268a0a3bb859f2 \
                    size    80191

    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  d9971d2caae1b68206204c309fcd380d682523de \
                    sha256  ab42e92ebac8909b40341d8fb0795bf4c938f71d1443bcda120c6ca8894d002a \
                    size    16190

    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  a5051830faeae6a67a88b43c6a7c7d3a316be722 \
                    sha256  c2dca249f23eac2ad20b2aaef4773a38489c49799cce1a16cd227138e9112862 \
                    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  4c723637a007f3ff0a157fe0e80e56f117b9e164 \
                    sha256  c47472839a98a02171f992becf7f067a114e64be1fa647b4054f7813a1997afb \
                    size    12048

    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  290315e0bac888f226c99cf01b6111bc54dfc0cd \
                    sha256  3b473ba6d7e7eeda907609343ac7d895182f8fff40de17d3bcc78999f2550aff \
                    size    12204

    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  954332b66c371c155c00fe341fd9c06e53b8ca73 \
                    sha256  305ff044228fe757f3a3ad5d7e1baba802a7a2eb0cd45ebf33c952e72945994a \
                    size    12111

    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  8ceaf87819b7513483d53ca8682ff52524543ecc \
                    sha256  c0e0e9779df9d581d85ed058f39f6ab473a39945bce209bec767b47115bc1e7b \
                    size    25128

    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  a46d3aa4e77e40b7e69bc2ddbcfdb8dc86b7186f \
                    sha256  9801b9f418ddf71e0572f934559557763c256fa27ab88f6303609a35a6944891 \
                    size    12320

    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  fbf751fe85fd7a94fb177cdb4f5fc5e2fdd3132e \
                    sha256  b5147c8ab8d2daf2b33e45d973f1422e4d64fe8ae1a664e78d861d861028d35a \
                    size    12043
}

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  ae5ab9e7307f941e227517c4e96031dfbc6bcd19 \
                    sha256  733aa1f6f97ec7122820a67c1cda82ecb012bcf4c85ae62c44860b03c7045ccd \
                    size    12133

    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  fde4b9a055c70571cd18de1771bf9abd2eacd2bd \
                    sha256  167eca0226261d9ecff3d71b50153c9a88ad57e7981a68e04ebad2f6bc0e9dde \
                    size    12469

    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  0ef8703a57313cedb35bca53ab95c09609813474 \
                    sha256  fb9a0813cc4a4d5b514b6c5d137463b133a32e79f930b61e77875df080550567 \
                    size    16763

    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  d7552f7661a594cbc15d571b87501ed01fd49bdd \
                    sha256  52da6a9f89ee698a9d157c88fe2648e57b0073ed4bac18c13e9ce22259e4378c \
                    size    15510

    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  85083edec5cf6b62949efc23cd3b4400d6948ef1 \
                    sha256  3477ff18b26133f67678f1ad50055a5de8081f5b0ece08b4f768ae325e2748b2 \
                    size    12116

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