# $Id$
# Maintainer: J. Peter Mugaas <jpmugaas@suddenlink.net>
# shamelessly stolen from Archlinux

pkgname=docbook-sgml
pkgver=4.5
pkgrel=1
pkgdesc='Document type definitions for verification of SGML data files against the DocBook rule set.'
arch=('any')
url='https://www.docbook.org/sgml/'
license=('MIT')
depends=('sgml-common')
install='docbook-sgml.install'
source=("https://www.docbook.org/sgml/${pkgver}/docbook-${pkgver}.zip")
sha256sums=('8043e514e80c6c19cb146b5d37937d1305bf3abf9b0097c36df7f70f611cdf43')

build() {
  cd "$srcdir"

  local DTDDIR="usr/share/sgml/docbook-sgml-$pkgver"

  sed -i \
      -e '/ISO 8879/d' \
      -e '/gml/d' \
      docbook.cat

  # Add support for previous versions.
  cat >> docbook.cat << "EOF"

  -- Begin Single Major Version catalog changes --

PUBLIC "-//OASIS//DTD DocBook V4.4//EN" "docbook.dtd"
PUBLIC "-//OASIS//DTD DocBook V4.3//EN" "docbook.dtd"
PUBLIC "-//OASIS//DTD DocBook V4.2//EN" "docbook.dtd"
PUBLIC "-//OASIS//DTD DocBook V4.1//EN" "docbook.dtd"
PUBLIC "-//OASIS//DTD DocBook V4.0//EN" "docbook.dtd"

  -- End Single Major Version catalog changes --

EOF
}

package() {
  cd "$srcdir"

  local DTDDIR="usr/share/sgml/docbook-sgml-$pkgver"

  install -dm755 "$pkgdir/$DTDDIR"
  install -m644 docbook.cat "$pkgdir/$DTDDIR/catalog"
  install -m644 *.dtd *.mod *.dcl "$pkgdir/$DTDDIR"
}
