MINGW_INSTALL=/mingw32

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

  ${MINGW_INSTALL}/bin/xmlcatalog --noout --add public "-//W3C//DTD MathML 2.0//EN" "../../share/xml/w3c/mathml2/mathml2.dtd" ${MINGW_INSTALL}/etc/xml/catalog
  ${MINGW_INSTALL}/bin/xmlcatalog --noout --add public "-//W3C//DTD MathML//EN" "../../share/xml/w3c/mathml2/mathml2.dtd" ${MINGW_INSTALL}/etc/xml/catalog
  ${MINGW_INSTALL}/bin/xmlcatalog --noout --add system "http://www.w3.org/TR/MathML2/dtd/mathml2.dtd" "../../share/xml/w3c/mathml2/mathml2.dtd" ${MINGW_INSTALL}/etc/xml/catalog
}

post_remove() {
  ${MINGW_INSTALL}/bin/xmlcatalog --noout --del "-//W3C//DTD MathML 2.0//EN" ${MINGW_INSTALL}/etc/xml/catalog
  ${MINGW_INSTALL}/bin/xmlcatalog --noout --del "-//W3C//DTD MathML//EN" ${MINGW_INSTALL}/etc/xml/catalog
  ${MINGW_INSTALL}/bin/xmlcatalog --noout --del "http://www.w3.org/TR/MathML2/dtd/mathml2.dtd" ${MINGW_INSTALL}/etc/xml/catalog
}


post_upgrade() {
  if [ $(vercmp $2 4.5) -ge 0 ]; then
    post_remove
  fi
  post_install
}
