# -*- 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 5.0.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  26852ec828f632a82acd4ad626f8a244f806b8ba \
                    sha256  4e9e4680e812037b582cef7335570074390b455d24a3e09bcaa2fdc473dbcc0a \
                    size    442736

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

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

foreach pv {313 312 311 310} {
    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  16f1fd80a85c073fc2e80f58216315b032d776f3 \
                    sha256  c438b6cb4fda2fef5868b7111d130a96233ccccf5538c292e642a04a47c9dbb6 \
                    size    184393

    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  0d382831c52f1e47dcc9520bd0248e11bbcc7b3b \
                    sha256  c8e4b86d2537a5d9de5801a6e3a8cf17fa4f12777479192d0e2978cbc6b18305 \
                    size    80831

    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  2d1f9cd913f2a4aed4b561ece30ec0f2bed4a76f \
                    sha256  84c01b06b2b0055f1b551eb3c0bc82c0a275063207cf9ea7ddc1b67129c728a4 \
                    size    16203

    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  ab92bcb9c3f6587a9a59d0d326f2991615887729 \
                    sha256  0b01118809700a4cce84e98f0410ff088d0e5bf01c0c46e6b0e49caaad9ca9c4 \
                    size    14398

    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  4de23417ecee6e42df5c4ae2d5aee36d3c41b1cd \
                    sha256  ecb0117a7034dc8a101fc2da16857db79f92903b671d929ba064c0b6f0730245 \
                    size    12219

    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  09fff9293312f9b82d9687ff30af01c60a093ae8 \
                    sha256  cc20990581bfdf280096f5a5d75ed658873ad78203107624647cca8ccb1c0c84 \
                    size    12386

    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  a1240f30a502b1aa0db050505c700bc4be192d14 \
                    sha256  6fbf877224c5cdd572bd7ccbb6efc8fb70472ed80735480583d700bd73830ef4 \
                    size    12317

    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  8dab5c6e24891eec7067b8d4df81a8b6906d8904 \
                    sha256  fc2d5bae2ca3571b14d2a34addad24cc7e0f338fb665bc3d59da76aaf121dcc1 \
                    size    25113

    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  1996167d1ba7ee21f2fb4f51a640f79868faa4bf \
                    sha256  7f673ac5cecbeeee0b81ea26945a896df5fd3004231fb3db2ee261fecfbbe34c \
                    size    12490

    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  4c411c6402396ad6ebbc988b0333657f962d11d3 \
                    sha256  6685ab3bfc7d9c03ea5d87f77652ee75e1eb890faee40c2ece44b3f490eab2a1 \
                    size    12211
}

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  b34beaa4e492573daf57a8369ae152c573605cc2 \
                    sha256  bc21f5e6ef22a1c2094a2fc2e33701cad562ae69a3b360a1c657640572ede14c \
                    size    12298

    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  ac3278e4f88ce6ed373672bb07f5a015b8259421 \
                    sha256  2ec86f7bdd914d8be4105132a59f1240b25ac466a103c25b85411f62d9b90e57 \
                    size    12675

    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  5afcf06cd911032b6205b7a2e429d3a49eb9883d \
                    sha256  c01dab063fc49a1012ff224240f5dca0bbe59c70ef6a0eeafe55dab6779ada85 \
                    size    16813

    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  a6f9260ce65284799ad6e5197514dd822a3e19be \
                    sha256  b89653b7410f783f945cd83206fa9ffbe87fa3c4b491e12fb921c239e39b1bfa \
                    size    15605

    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  9ce56f8ceaac295929a926133d470814c96063f2 \
                    sha256  291af70379318a7989a2ab57e30a03ef7f6ab46fb85d6c153c7b63e81a737f20 \
                    size    12305

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