post_install() {
  echo ":: Installing SAX XML Parsers"
  perl -MXML::SAX -e "XML::SAX->add_parser(q(XML::LibXML::SAX::Parser))->save_parsers()"
  perl -MXML::SAX -e "XML::SAX->add_parser(q(XML::LibXML::SAX))->save_parsers()"
}

post_upgrade() {
  if [[ ! -f /usr/share/perl5/vendor_perl/XML/SAX/ParserDetails.ini ]]; then
    post_install
  else
    libxmlcount=`grep -c XML::LibXML::SAX /usr/share/perl5/vendor_perl/XML/SAX/ParserDetails.ini`
    if [[ $libxmlcount == 0 ]]; then
      post_install
    fi
  fi
}

pre_remove() {
  if [[ -f /usr/share/perl5/vendor_perl/XML/SAX/ParserDetails.ini ]]; then
    perl -MXML::SAX -e "XML::SAX->remove_parser(q(XML::LibXML::SAX::Parser))->save_parsers()"
    perl -MXML::SAX -e "XML::SAX->remove_parser(q(XML::LibXML::SAX))->save_parsers()"
  fi
}
