# $Id: Portfile 81135 2011-07-26 00:29:03Z jmr@macports.org $

PortSystem      1.0

name            docbook-xsl-ns
version         1.76.1
categories      textproc
license         MIT Permissive
description     DocBook XSL NS (namespaced) Stylesheets
long_description \
    This package contains a release of XSL stylesheets for \
    processing namespaced DocBook documents (DocBook 5 or \
    later). The stylesheets are the same as the concurrent \
    stylesheet release except that the templates match on \
    elements in the DocBook namespace.
platforms       darwin
supported_archs noarch
maintainers     nomaintainer
master_sites    sourceforge:project/docbook/${name}/${version}
homepage        http://docbook.sourceforge.net/
depends_run     port:xmlcatmgr

use_zip         yes

checksums       md5     38a3361334ac3d135a851bcfa77beb0e \
                sha1    8d2fa4a376f2caa018f668831279eacd03b4568e \
                rmd160  c05c6e020b19e83c1fb4350953a1e1a193919832

use_configure   no
build           {}
set srcxslpaths "catalog.xml common docsrc eclipse epub extensions fo \
                highlighting html htmlhelp images javahelp lib manpages \
                params profiling roundtrip slides template tools webhelp \
                website xhtml xhtml-1_1 VERSION"
set srcdocpaths "AUTHORS BUGS README RELEASE-NOTES.html RELEASE-NOTES.xml \
                RELEASE-NOTES.pdf RELEASE-NOTES.txt TODO VERSION NEWS COPYING"
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"
    }
}

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

livecheck.distname  ${name}
