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

name                    ikiwiki
perl5.branches          5.34
perl5.setup             ikiwiki 3.20190228
# reset version because perl5 portgroup incorrectly converts it
version                 3.20190228
revision                1

categories              www perl
license                 GPL-2+
description             A wiki compiler.
long_description        Ikiwiki is a wiki compiler. It converts wiki pages \
                        into HTML pages suitable for publishing on a website. \
                        Ikiwiki stores pages and history in a revision control \
                        system such as Subversion or Git. There are many other \
                        features, including support for blogging and podcasting, \
                        as well as a large array of plugins.
homepage                http://ikiwiki.info/
maintainers             nomaintainer
platforms               darwin
master_sites            http://ftp.debian.org/debian/pool/main/i/ikiwiki/
distname                ${name}_${version}.orig
worksrcdir              IkiWiki-${version}
use_xz                  yes

# Livecheck URL is for a file listing in reverse filename order. Using reverse
# chronological order is impractical because older versions are sometimes
# patched, giving them a newer timestamp than the latest release.

livecheck.url           http://ftp.debian.org/debian/pool/main/i/ikiwiki/?C=N\;O=D
livecheck.regex         "${name}_(\\d+(?:\\.\\d+)*)"

checksums               rmd160  f47968a69528aea864ad412c8508a8c5063edb9d \
                        sha256  d07a4d0da60c3e4de698a4dc54d0445547e762b37f0d433b0d664d88155dfe9e \
                        size    2672244

depends_build           path:libexec/coreutils/libstdbuf.so:coreutils \
                        port:gettext \
                        port:p${perl5.major}-ipc-run \
                        port:p${perl5.major}-perlmagick \
                        port:p${perl5.major}-xml-twig

# needed modules (see Bundle/IkiWiki.pm)
depends_lib-append      \
                        port:p${perl5.major}-cgi \
                        port:p${perl5.major}-cgi-formbuilder \
                        port:p${perl5.major}-cgi-session \
                        port:p${perl5.major}-data-dumper \
                        port:p${perl5.major}-html-parser \
                        port:p${perl5.major}-html-scrubber \
                        port:p${perl5.major}-html-template \
                        port:p${perl5.major}-mail-sendmail \
                        port:p${perl5.major}-text-markdown \
                        port:p${perl5.major}-timedate \
                        port:p${perl5.major}-uri \
                        port:p${perl5.major}-xml-simple \
                        port:p${perl5.major}-yaml-libyaml \
                        port:py310-docutils

# a couple of optional extra modules bundled from MacPorts used by plugins
# (for a complete list see Bundle/IkiWiki/Extras.pm)
# TODO
# Search::Xapian
# Text::Typography
# Text::Textile
# Net::Amazon::S3
# Text::WikiCreole
# Gravatar::URL
# Net::INET6Glue
#
# rst plugin: needs RPC/XML.pm

depends_lib-append      port:p${perl5.major}-authen-passphrase \
                        port:p${perl5.major}-crypt-ssleay \
                        port:p${perl5.major}-file-mimeinfo \
                        port:p${perl5.major}-html-tree \
                        port:p${perl5.major}-locale-gettext \
                        port:p${perl5.major}-lwpx-paranoidagent \
                        port:p${perl5.major}-net-openid-consumer \
                        port:p${perl5.major}-rpc-xml \
                        port:p${perl5.major}-sort-naturally \
                        port:p${perl5.major}-term-readline-gnu \
                        port:p${perl5.major}-text-csv \
                        port:p${perl5.major}-text-wikiformat \
                        port:p${perl5.major}-xml-feed \
                        port:p${perl5.major}-xml-writer

destroot.target         CP=gcp install
configure.args          INSTALLDIRS=vendor PREFIX=${prefix}

post-patch {
    reinplace "s|/usr/bin/perl|${perl5.bin}|g" \
        ${worksrcpath}/ikiwiki.in \
        ${worksrcpath}/IkiWiki.pm \
        ${worksrcpath}/Makefile.PL \
        ${worksrcpath}/ikiwiki-calendar.in \
        ${worksrcpath}/ikiwiki-mass-rebuild \
        ${worksrcpath}/ikiwiki-transition.in \
        ${worksrcpath}/ikiwiki-update-wikilist \
        ${worksrcpath}/ikiwiki-w3m.cgi \
        ${worksrcpath}/gitremotes \
        ${worksrcpath}/mdwn2man \
        ${worksrcpath}/pm_filter \
        ${worksrcpath}/docwiki.setup \
        ${worksrcpath}/auto.setup \
        ${worksrcpath}/auto-blog.setup
    reinplace "s|=/etc/ikiwiki|=${prefix}/etc/ikiwiki|" \
        ${worksrcpath}/Makefile.PL
    reinplace "s|/etc/ikiwiki/wikilist|${prefix}/etc/ikiwiki/wikilist|g" \
        ${worksrcpath}/ikiwiki-update-wikilist \
        ${worksrcpath}/ikiwiki-mass-rebuild
    reinplace "s|#!.*|#!${prefix}/bin/python3.10|" \
        ${worksrcpath}/plugins/proxy.py \
        ${worksrcpath}/plugins/pythondemo \
        ${worksrcpath}/plugins/rst
    reinplace "s|python3 -c|${prefix}/bin/python3.10 -c|" \
        ${worksrcpath}/t/rst.t
}

post-destroot {
    delete {*}[glob ${destroot}${prefix}/lib/perl5/*/*/perllocal.pod]
}
