# -*- 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

name                wordpress
version             5.5.12
revision            0

categories          www
license             GPL-2+
maintainers         nomaintainer
platforms           any
supported_archs     noarch

description         a state-of-the-art semantic personal publishing platform
long_description    WordPress is {*}${description} with a focus on aesthetics,\
                    web standards, and usability.

homepage            https://${name}.org/
master_sites        ${homepage}

checksums           rmd160  314bcfc3cf67dfc50858220c8edfd6da538338ae \
                    sha256  15f0877b8b3a048f57f8558ef5a622ee29eb304d12bc0c252e5cac189f6dc6c7 \
                    size    13032557

worksrcdir          ${name}

use_configure       no
build               {}

# The php variants deliberately do not conflict
#
# min req is currently: 5.6
#   » https://wordpress.org/news/2019/04/minimum-php-version-update/
foreach v "56 70 71 72 73 74" {
    variant php${v} description "Use php${v}" "
        depends_run-append  port:php${v} \
                            port:php${v}-gd \
                            port:php${v}-mbstring \
                            port:php${v}-mcrypt \
                            port:php${v}-mysql \
                            port:php${v}-zip
    "
}

if {![variant_isset php56] && ![variant_isset php70] &&
    ![variant_isset php71] && ![variant_isset php72] &&
    ![variant_isset php73] && ![variant_isset php74]} {
    default_variants +php74
}

destroot {
    file copy ${worksrcpath} ${destroot}${prefix}/www/${name}
}

set conf_file "httpd-${name}.conf"

notes "
If your webserver is already running with php and mysql, connect on\
http://localhost/${name}/ to finish the install. Temporarily allow\
the webserver write access so it can create wp-config.php (or do it yourself)

    \$ sudo chmod 1777 ${prefix}/www/${name}
    \$ sudo chmod 755 ${prefix}/www/${name}

If Apache is not set, set an alias to the ${name} dir and some access like:

-- ${prefix}/apache2/conf/extra/${conf_file}
Alias /${name}/ \"${prefix}/www/${name}/\"
<Directory \"${prefix}/www/${name}\">
    Options -Indexes +FollowSymLinks
    AllowOverride None
    #Require host localhost
    #Require ip 127.0.0.1
    Require all granted
</Directory>
--

And then include it in httpd.conf, like:

    # ${name}
    Include etc/apache2/extra/${conf_file}\n—
"

livecheck.type      regex
livecheck.url       ${homepage}download/
livecheck.regex     "Download WordPress (\\d+(?:\\.\\d+)*)"
