# $Id: Portfile 104648 2013-03-30 18:06:55Z devans@macports.org $
# -*- 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            docbook-xsl
version         1.78.1
categories      textproc
license         MIT Permissive
description     The docbook xsl stylesheets
long_description \
    The DocBook XSL stylesheets are the official stylesheets for transforming\
    DocBook XML documents into other document formats via XSLT.
platforms       darwin
maintainers     nomaintainer
master_sites    sourceforge:docbook
homepage        http://docbook.sourceforge.net/
depends_run     port:xmlcatmgr

use_bzip2       yes

distfiles-append \
                [suffix ${name}-doc-${version}]

checksums       [suffix $distname] \
                sha1    1d668c845bb43c65115d1a1d9542f623801cfb6f \
                rmd160  1f29e74eaab655673ced47b7a011c35c4d1e5187 \
                [suffix $name-doc-$version] \
                sha1    bf69dc152a9f983a1af197d9041b8c4dc894dd5d \
                rmd160  78f6b1bc4ca2de024addd4ab9092dc929fd4d3aa

supported_archs noarch
use_configure   no
build           {}
set srcxslpaths "assembly catalog.xml common eclipse epub epub3 extensions fo \
                highlighting html htmlhelp images javahelp lib manpages params \
                profiling roundtrip slides template tools webhelp website \
                xhtml xhtml-1_1 xhtml5 \
                VERSION VERSION.xsl"
set srcdocpaths "AUTHORS BUGS README RELEASE-NOTES.html RELEASE-NOTES.txt \
                TODO VERSION NEWS COPYING doc"
set instxsldir  "share/xsl/${name}"
set instdocdir  "share/doc/${name}"

destroot {
    foreach pathname "${instxsldir} ${instdocdir}" {
        xinstall -m 755 -d ${destroot}${prefix}/${pathname}
    }
    foreach pathname ${srcxslpaths} {
        copy ${worksrcpath}/${pathname} ${destroot}${prefix}/${instxsldir}
    }
    foreach pathname ${srcdocpaths} {
        copy ${worksrcpath}/${pathname} ${destroot}${prefix}/${instdocdir}
    }
}
post-activate {
    # xmlcatmgr as installed by MacPorts defaults to using
    # ${prefix}/etc/xml/docbook (for XML) and ${prefix}/etc/xml/docbook (for
    # SGML) if no catalog is specified, but we'll specify the path just in case
    # users have another installation of xmlcatmgr and happen to have it before
    # ${prefix}/bin in their PATH.
    set catalog.xml ${prefix}/etc/xml/catalog

    # Make the directory if it doesn't exist
    if {![file exists ${prefix}/etc/xml]} {
        xinstall -m 755 -d ${prefix}/etc/xml
    }

    # Create the catalog file if it doesn't exist
    if {![file exists ${catalog.xml}]} {
        system "xmlcatmgr create -c ${catalog.xml}"
    }

    # Add the nextCatalog entry to the catalog if it doesn't exist
    if {[catch {exec xmlcatmgr lookup ${prefix}/${instxsldir}/catalog.xml}]} {
        system "xmlcatmgr add nextCatalog ${prefix}/${instxsldir}/catalog.xml"
    }
}

if {${registry.format} == "receipt_flat"} {
    notes \
"######################################################################
# As the flat registry format does not support post-deactivate hooks,
# you will need to ensure that you manually remove the catalog
# entry for this port when you uninstall it.  To do so, run
# \"xmlcatmgr remove nextCatalog ${prefix}/${instxsldir}/catalog.xml\".
######################################################################"
}

# This will remove the catalog entry for this port.
post-deactivate {
    system "xmlcatmgr remove nextCatalog ${prefix}/${instxsldir}/catalog.xml"
}

livecheck.url       http://docbook.sourceforge.net/release/xsl/
livecheck.regex "=\"(\\d+(?:\\.\\d+)*)"
