# $Id: Portfile 86786 2011-11-04 05:20:35Z boeyms@macports.org $

PortSystem 1.0

name        docbook-xml-4.2
version     [strsed ${name} {s/docbook-xml-//}]
description Version ${version} of the DocBook XML DTDs
long_description \
    Version ${version} of the DocBook XML DTDs, which provide a structured,\
    semantic markup format for books and documentation, especially for\
    computer hardware and software.
categories  textproc
license     MIT Permissive
platforms   darwin
maintainers nomaintainer
supported_archs noarch
distname    ${name}

homepage    http://www.docbook.org/xml/${version}/
master_sites    http://www.oasis-open.org/docbook/xml/${version}/
checksums   md5 73fe50dfe74ca631c1602f558ed8961f \
            sha1 5e3a35663cd028c5c5fbb959c3858fec2d7f8b9e \
            rmd160 3ba17bf96ab2ab8fe6dc9ff82da8e22aaf9ce5e0
worksrcdir  ${distname}

depends_run port:xmlcatmgr

use_zip     yes

extract.mkdir   yes

use_configure   no
build       {}

set install_dir    ${prefix}/share/xml/docbook/${version}

destroot {
    set destroot_dir    ${destroot}${install_dir}
    set destroot_files  [readdir ${worksrcpath}]
    xinstall -m 755 -d ${destroot_dir}
    foreach file ${destroot_files} {
        copy ${worksrcpath}/${file} ${destroot_dir}
    }
}

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 ${install_dir}/catalog.xml}]} {
        system "xmlcatmgr add nextCatalog ${install_dir}/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 ${install_dir}/catalog.xml\".
######################################################################"
}

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

livecheck.type  none
