NAME="docbook-xsl-nons"
DESC="Contains XSL stylesheets"
VERSION="1.79.2"
FILES=(
  "https://github.com/docbook/xslt10-stylesheets/releases/download/release/$VERSION/docbook-xsl-nons-$VERSION.tar.bz2"
  "https://www.linuxfromscratch.org/patches/blfs/12.0/docbook-xsl-nons-$VERSION-stack_fix-1.patch"
)
HASHES=(
  "2666d1488d6ced1551d15f31d7ed8c38"
  "a92c39715c54949ba9369add1809527b8f155b7e2a2b2e30cb4b39ee715f2e30"
)
DEPENDS=("libxml2" "docbook-xml")

PACKAGE() {
  tar xf $NAME-$VERSION.tar.bz2
  cd $NAME-$VERSION

  patch -Np1 -i ../docbook-xsl-nons-$VERSION-stack_fix-1.patch
  install -v -m755 -d $ROOTDIR/usr/share/xml/docbook/xsl-stylesheets-nons-$VERSION

  cp -v -R VERSION assembly common eclipse epub epub3 extensions fo        \
         highlighting html htmlhelp images javahelp lib manpages params  \
         profiling roundtrip slides template tests tools webhelp website \
         xhtml xhtml-1_1 xhtml5                                          \
         $ROOTDIR/usr/share/xml/docbook/xsl-stylesheets-nons-$VERSION
  ln -s VERSION $ROOTDIR/usr/share/xml/docbook/xsl-stylesheets-nons-$VERSION/VERSION.xsl
  install -v -m644 -D README \
                    $ROOTDIR/usr/share/doc/docbook-xsl-nons-$VERSION/README.txt 
  install -v -m644    RELEASE-NOTES* NEWS* \
                    $ROOTDIR/usr/share/doc/docbook-xsl-nons-$VERSION

  cd .. && rm -rf $NAME-$VERSION
}

INSTALL(){
  if [ ! -d /etc/xml ]; then install -v -m755 -d /etc/xml; fi &&
  if [ ! -f /etc/xml/catalog ]; then
  xmlcatalog --noout --create /etc/xml/catalog
  fi &&
  
  xmlcatalog --noout --add "rewriteSystem"            "https://cdn.docbook.org/release/xsl-nons/1.79.2"            "/usr/share/xml/docbook/xsl-stylesheets-nons-1.79.2"     /etc/xml/catalog &&
  
  xmlcatalog --noout --add "rewriteURI"            "https://cdn.docbook.org/release/xsl-nons/1.79.2"            "/usr/share/xml/docbook/xsl-stylesheets-nons-1.79.2"     /etc/xml/catalog &&
  
  xmlcatalog --noout --add "rewriteSystem"            "https://cdn.docbook.org/release/xsl-nons/current"            "/usr/share/xml/docbook/xsl-stylesheets-nons-1.79.2"     /etc/xml/catalog &&
  
  xmlcatalog --noout --add "rewriteURI"            "https://cdn.docbook.org/release/xsl-nons/current"            "/usr/share/xml/docbook/xsl-stylesheets-nons-1.79.2"     /etc/xml/catalog &&
  
  xmlcatalog --noout --add "rewriteSystem"            "http://docbook.sourceforge.net/release/xsl/current"            "/usr/share/xml/docbook/xsl-stylesheets-nons-1.79.2"     /etc/xml/catalog &&
  
  xmlcatalog --noout --add "rewriteURI"            "http://docbook.sourceforge.net/release/xsl/current"            "/usr/share/xml/docbook/xsl-stylesheets-nons-1.79.2"     /etc/xml/catalog
}
