MINGW_INSTALL=mingw64
MINGW_XML_CATALOG=${MINGW_INSTALL}/etc/xml

post_install() {
  if [ ! -e ${MINGW_XML_CATALOG}/catalog ]; then
    ${MINGW_INSTALL}/bin/xmlcatalog.exe --noout --create ${MINGW_XML_CATALOG}/catalog
  fi

  ${MINGW_INSTALL}/bin/xmlcatalog.exe --noout --add "delegatePublic" \
    "-//OASIS//DTD DocBook MathML Module" \
    "./docbook-mathml" \
    ${MINGW_XML_CATALOG}/catalog

  ${MINGW_INSTALL}/bin/xmlcatalog.exe --noout --add "delegateSystem" \
    "http://www.oasis-open.org/docbook/xml/mathml/" \
    "./docbook-mathml" \
    ${MINGW_XML_CATALOG}/catalog

  ${MINGW_INSTALL}/bin/xmlcatalog.exe --noout --add "delegateURI" \
    "http://www.oasis-open.org/docbook/xml/mathml/" \
    "./docbook-mathml" \
    ${MINGW_XML_CATALOG}/catalog
}

post_upgrade() {
  post_remove $2
  post_install $1
}

post_remove() {
  ${MINGW_INSTALL}/bin/xmlcatalog.exe --noout --del ./docbook-mathml ${MINGW_XML_CATALOG}/catalog
  ${MINGW_INSTALL}/bin/xmlcatalog.exe --noout --del "-//OASIS//DTD DocBook MathML Module V1.1CR1//EN" ${MINGW_XML_CATALOG}/catalog
  ${MINGW_INSTALL}/bin/xmlcatalog.exe --noout --del "http://www.oasis-open.org/docbook/xml/mathml/1.1CR1/dbmathml.dtd" ${MINGW_XML_CATALOG}/catalog
}
