# -*- 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.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  263b7d0ac56786e89bb9e94f6178c235ef98a7e1 \
                    sha256  d88617101b514f77ac9117452db2754dac446d8dc5a958210dbfc3279b34472e \
                    size    441366


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  ce7438107b6024a98ffe1a3caaba2f61b67838a4 \
                        sha256  5db56945da6df727ea3b8b6115e9a974956090c1bdd1a3d027cebf6424e2361c \
                        size    183351

    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  faaa47987fbdac8553f851b1152a17fe3a3f806f \
                        sha256  0416b84f2a129163ce169bcf46908dd085a1cf53fb52199c2e771b68a757da8c \
                        size    80192

    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  9d4c2a47c173773c90b8717e7ea12890b0f9135f \
                        sha256  c063cbe5fe4294d96cda29983c3fa0fb0efe4a8cd4822c550df8cfd118166e78 \
                        size    16206

    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  ddffc8e95221bd7e92128e2d3c6aba9f2cd84a6d \
                        sha256  ce5b818aa1598a8a69e6cc2cffe916c81f66e4cc110e667fe67c8a737d94075b \
                        size    14391

    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  2f9d4dab9803321ff64460762d0fd3717b872b41 \
                        sha256  fe79f44917147f0ffc303f6bb0bf04c4e024eec4d5d56dab0c8e9b82aebc53ee \
                        size    12038

    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  b0128906c89d37697f18bd5ef0626059f17dd089 \
                        sha256  0ae5180c1d77ef5d949faa94f3852d832531fc54d12ff133ac16c1a1c4f61041 \
                        size    12207

    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  b13af0cf31a435f5a438201de4fb2bd17fb0eaf1 \
                        sha256  d0c5e3d8d72224eb6d20d922c8e96cd31b183a062074a1d215e3b815e141108d \
                        size    12116

    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  859b4c2bc048e45cc82813cb8aa665ad78528799 \
                        sha256  f064f1e1913bde3d1e223cbd71235c934fb3990a6cb2c9a896d80d226707cdba \
                        size    25118

    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  f56b3fdc2df321774120ac93adbfea2ed6b66d42 \
                        sha256  967691b41e7ad794d5a79865dc1dd36cac26187736ef3c8137ffaf2a94e6d31f \
                        size    12328

    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  6c03352cded234db7a303ba8e968be7b9166a55a \
                        sha256  e0d07e23d8093045bb67608fe2a67d09a96ee66c8df8d3d53dca47a890897a08 \
                        size    12044
}

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  15414f7f7c208694fc68287d191665452fc6e1c2 \
                        sha256  7babed259dfbe77efd4f380175493c9a7d5c7109b8faffa863194e28b1a77c35 \
                        size    12114

    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  841c037b265649822b1e166161368c5fb3622e5c \
                        sha256  0dee515a48b49b6a464d9db391a8e212a6c40b071b908130f66309a5cef6326f \
                        size    12476

    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  17cd4ad9db7a3322974d1d8649a44b4c6f4c8ade \
                        sha256  5f997e03c34b7f1f6c9af1e7722b6b536d5a662a1ee05b01e4bb631fa753e148 \
                        size    16775

    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  212ee1ede8c3d33777bdee12fb8f82d0686ad799 \
                        sha256  b7ba2c3d2cc46630ed8ad7df1252aa5a1cf619c412bfe1ae68a7443e760c3f54 \
                        size    15491

    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  5d3f78d4727c88a1c1fed9f0a364c593fb243807 \
                        sha256  584761f650c57a5838ff7ab0d48692331cfa6023021fe9c58ebad6eb7ba7edb3 \
                        size    12112

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