# $Id: Portfile 79665 2011-06-22 22:09:19Z tommyd@macports.org $

PortSystem 1.0
PortGroup perl5 1.0

perl5.setup             ikiwiki 3.20110608
name                    ikiwiki
categories              www perl
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, as well as a \
                        large array of plugins.
homepage                http://ikiwiki.info/
maintainers             tommyd openmaintainer
platforms               darwin
master_sites            http://ftp.debian.org/debian/pool/main/i/ikiwiki/
distname                ${name}_${version}
worksrcdir              ${name}

# 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         ">ikiwiki_(\[^<\]+)\\.tar\\.gz<"

patchfiles              patch-Makefile.PL.diff

checksums               md5     c5cce6866137f77b0c5a8eb8d6395391 \
                        sha1    0808e5f2f03bb5d604b903b96a6a897aeeb24a9e \
                        rmd160  fa3c774c148c7ef8001579a49c97c92320d18ac6

depends_build           port:coreutils

# needed modules (see Bundle/IkiWiki.pm)
depends_lib-append      port:p5-cgi-formbuilder \
                        port:p5-cgi-session \
                        port:p5-data-dumper \
                        port:p5-html-parser \
                        port:p5-html-scrubber \
                        port:p5-html-template \
                        port:p5-html-tree \
                        port:p5-mail-sendmail \
                        port:p5-text-markdown \
                        port:p5-uri \
                        port:p5-timedate \
                        port:p5-xml-simple

# a couple of optional extra modules bundled from MacPorts used by plugins
# (for a complete list see Bundle/IkiWiki/Extras.pm)
depends_lib-append      port:p5-crypt-ssleay \
                        port:p5-digest-sha1 \
                        port:p5-file-mimeinfo \
                        port:p5-locale-gettext \
                        port:p5-rpc-xml \
                        port:p5-term-readline-gnu \
                        port:p5-text-csv \
                        port:p5-text-wikiformat \
                        port:p5-xml-feed \
                        port:p5-yaml

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

set min_perl_req "10"

pre-extract {
    set perl_binary "${prefix}/bin/perl"
    if { ![file exists ${perl_binary}] } {
        # This shouldn't happen, because perl is a prereq for installing.
        ui_error "No Perl version found in ${prefix}/bin."
        return -code error "${perl_binary} is missing."
    }
 
    set min_perl_inst [lindex [split [exec ${perl_binary} -e "printf '%vd\n', $^V"] .] 1]
    if { ${min_perl_inst} < ${min_perl_req} } {
        ui_error "The current Perl version does not meet the version requirements"
        ui_error "(wanted Perl >= 5.${min_perl_req}, got Perl 5.${min_perl_inst})."
        ui_error "Consider installing Perl 5.${min_perl_req} (or higher), re-install"
        ui_error "all dependent p5-* modules and then try to install $name again."
        return -code error "Perl version does not match required version."
    }
}

post-patch {
    reinplace "s|/usr/bin/perl|${prefix}/bin/perl|g" \
        ${worksrcpath}/ikiwiki.in \
        ${worksrcpath}/IkiWiki.pm \
        ${worksrcpath}/Makefile.PL \
        ${worksrcpath}/ikiwiki-calendar.in \
        ${worksrcpath}/ikiwiki-makerepo \
        ${worksrcpath}/ikiwiki-mass-rebuild \
        ${worksrcpath}/ikiwiki-transition.in \
        ${worksrcpath}/ikiwiki-update-wikilist \
        ${worksrcpath}/ikiwiki-w3m.cgi \
        ${worksrcpath}/ikiwiki.in \
        ${worksrcpath}/gitremotes \
        ${worksrcpath}/mdwn2man \
        ${worksrcpath}/pm_filter \
        ${worksrcpath}/docwiki.setup \
        ${worksrcpath}/auto.setup \
        ${worksrcpath}/auto-blog.setup
    reinplace "s|/etc/ikiwiki/wikilist|${prefix}/etc/ikiwiki/wikilist|g" \
    ${worksrcpath}/ikiwiki-update-wikilist \
    ${worksrcpath}/ikiwiki-mass-rebuild
}
