# -*- 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.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  351b463cc10f8d1374db7aaf2419527f0498e1bc \
                    sha256  a867bfbb5126516c12d4c8a93909ef1e4d5309fc4e9f5b97b2d987b0ffd4bbe3 \
                    size    439556


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}/certbot/compat/misc.py
        reinplace "s|/var/lib/|${prefix}/var/db/|" ${worksrcpath}/certbot/compat/misc.py
        reinplace "s|/var/log/|${prefix}/var/log/|" ${worksrcpath}/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  4871eb76fd235458562c9d583d2fb173e3ef8d15 \
                        sha256  507f9a336bd95c25548f449d8307eead6f875186a13049de173d6833371910a2 \
                        size    183105

    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  f448df253a33d1a0bdc7aa7cf37d13703fa46728 \
                        sha256  4478c3e13e04b49f95675d83adaacdcf1356f8fac0824e236f893f2f5a1d991c \
                        size    79653

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

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

    post-patch {
        reinplace "s|%PREFIX%|${prefix}|" \
        ${worksrcpath}/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  d70301bbee9e4bfbd3c8dac3cc39d177fe231b1c \
                        sha256  3cc9752b1fbca8e16de8ccd23675d345505a529737855398db655b3413e711f8 \
                        size    16391

    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  a25bd894a0af9c938e72e61cc637b8cffc567d55 \
                        sha256  00ce5b7c6fdcf360ab65558ec0e9c9a7247ddeb7ac8355bca3f5ca43496b0b87 \
                        size    14571

    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  b7b4aa34526c50ca2932f42a5d2e530045010906 \
                        sha256  3dbe24c0cd5ada5c833d6de174c7ced9fd2a215547d18ad569ee4fe45aafb41b \
                        size    11885

    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  7a80b91a4df8aef77d26b98ea0925c0f854b171b \
                        sha256  bd42dc87844d764c80e27221b81371670ccce65e564119fe1c99fafe7b0b441e \
                        size    12069

    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  2b355b4a14404308da33f4d17b76f086c5ddd123 \
                        sha256  554c35ab3582b37d3fa628cd0c8186f0801b2925bf21fcb08c9db502b276471f \
                        size    11966

    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  35036b146e59a359a0b9fc2a85c6969b93134f70 \
                        sha256  07f78292c7e9b76552a9eed5152c46b285acf3231338850195e895eb3a62a6d3 \
                        size    25242

    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  5ad8034ac43d406e569793c2933067bbf4dd2129 \
                        sha256  a8487117a2c57606e9e554bf967058c598f6f559fdddd13a4c763c97416c999b \
                        size    12181

    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  26134f6b60cc5d1ec9ea84f2592b5666d01f9ec3 \
                        sha256  2fb5bcd8eeada94f9ad9a5a213d0d90480071a5b5411c326e279fa352bc42ea6 \
                        size    11888
}

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  b3c91b13ed30594b2986a2d5a98ffd3f1c2286a1 \
                        sha256  c0bdd769e88147e7b45371c4892c68404a014aa9c4aa48a505f011a94b5e18eb \
                        size    11966

    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  318cfeddbd9911e5edb462aa23c24748123728f7 \
                        sha256  54b1637572d2ac5bbe78bddc180966ad9c7d90bb6baf820c4e7da4c02e6f21ab \
                        size    12324

    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  5bf1a665e259bfa620ed069378044ab145466b36 \
                        sha256  9d403198294c6e2e4bc9df6a5e82a4ed35ab3ffef534307f732e967fec3292d7 \
                        size    16948

    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  baeed14f14a8bd7588ba2848ebfe353e66ae4ba4 \
                        sha256  9b6397d5a0b3a23242346238cdf423b111b16114e59798638b47d1be9a84fc2e \
                        size    15688

    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  c273d58ed0cc4ae553dcb9d13a823af91121e2f2 \
                        sha256  b658870de64ffab5f302575f391b8b37774a1cd5d294e8dbbe6db46a794bdd36 \
                        size    11967

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