# $Id: Portfile 68236 2010-05-29 19:46:36Z blb@macports.org $

PortSystem          1.0
name                mediawiki
version             1.15.4
set branch          [join [lrange [split ${version} .] 0 1] .]
categories          www php
maintainers         blb openmaintainer
description         The wiki engine used by Wikipedia
long_description \
   MediaWiki is the collaborative editing software that runs Wikipedia, the \
   free encyclopedia, and other projects. It's designed to handle a large \
   number of users and pages without imposing too rigid a structure or \
   workflow.

platforms           darwin freebsd

homepage            http://www.mediawiki.org
master_sites        http://download.wikimedia.org/mediawiki/${branch}/

checksums           md5     9c37dee8addc27b2051ee2eebc238b4d \
                    sha1    c00267663a0a05ace4bd28b53b0b3b0f08dad551 \
                    rmd160  f4879c0f9cb1b8a6f5682f9fad14010703d49c27

depends_run         port:libiconv port:jpeg port:jasper port:tiff port:lcms \
                    port:libpng port:freetype port:libxml2 port:jbigkit \
                    port:expat port:fontconfig port:ghostscript \
                    port:ImageMagick port:pkgconfig port:aspell \
                    port:php5-web

# Fix an outdated KHTML hack which affects newer WebKit
# https://bugs.webkit.org/show_bug.cgi?id=28350
patchfiles          patch-skins_common_wikibits.js.diff

use_configure       no

build               {}

set docpath ${prefix}/www/data/${name}

destroot {
   xinstall -d -m 0755 ${destroot}${docpath}
   eval file copy [glob ${worksrcpath}/*] ${destroot}${docpath}
}

post-activate {
   ui_msg "MediaWiki has now been installed into ${docpath}"
   ui_msg "Any further information on installation and configuration can"
   ui_msg "be found at"
   ui_msg "http://www.mediawiki.org/wiki/Manual:Installation_guide"
   ui_msg ""
   ui_msg "If you are upgrading, read"
   ui_msg "http://www.mediawiki.org/wiki/Manual:Upgrading"
   ui_msg ""
   if {![file exists ${docpath}/AdminSettings.php]} {
      xinstall -m 660 ${docpath}/AdminSettings.sample \
         ${docpath}/AdminSettings.php
      ui_msg "Make sure ${docpath}/AdminSettings.php has correct information"
   } else {
      ui_msg "${docpath}/AdminSettings.php has not been touched, make sure"
      ui_msg "it is correct and anything in ${docpath}/AdminSettings.sample"
      ui_msg "needed has been copied to it"
   }
}

variant mysql4 description "Deprecated variant, use just +mysql" {}
if {[variant_isset mysql4]} {
   variant_set mysql
}

variant postgresql83 description "Deprecated variant, use just +postgresql" {}
variant postgresql84 description "Deprecated variant, use just +postgresql" {}
if {[variant_isset postgresql83] || [variant_isset postgresql84]} {
   variant_set postgresql
}

variant mysql description "Use MySQL as the database backend" {
   depends_run-append   port:php5-mysql
}

variant postgresql description "Use PostGreSQL as the database backend" {
   depends_run-append   port:php5-postgresql
}

# Default to +mysql since that was previously the built-in setting
if {![variant_isset mysql] && ![variant_isset postgresql]} {
   default_variants     +mysql
}

livecheck.type      regex
livecheck.url       http://www.mediawiki.org/wiki/Download
livecheck.regex     ${name}-(\[.\\d]+)\\.tar\\.gz

