if [ "$1" = install ]
then
# backing out existing entries to avoid duplicates
sed '
/^# OpenOffice.org/d
/^application\/vnd\.oasis\.opendocument/d
/^application\/vnd\.openofficeorg/d
/^application\/vnd\.sun/d
/^application\/vnd\.stardivision/d
/^application\/vnd\.ms-word/d
/^application\/vnd\.ms-excel/d
/^application\/vnd\.ms-powerpoint/d
/^application\/x-star/d
/excel/d
/ms[-]*word/d
/powerpoint/d
' ${PKG_INSTALL_ROOT}/etc/mailcap 2>/dev/null

# now append our stuff to the temporary file
cat << END
# OpenOffice.org
application/vnd.oasis.opendocument.text; openoffice.org2.2 -view %s
application/vnd.oasis.opendocument.text-template; openoffice.org2.2 -view %s
application/vnd.oasis.opendocument.text-web; openoffice.org2.2 -view %s
application/vnd.oasis.opendocument.text-master; openoffice.org2.2 -view %s
application/vnd.sun.xml.writer; openoffice.org2.2 -view %s
application/vnd.sun.xml.writer.template; openoffice.org2.2 -view %s
application/vnd.sun.xml.writer.global; openoffice.org2.2 -view %s
application/vnd.stardivision.writer; openoffice.org2.2 -view %s
application/vnd.stardivision.writer-global; openoffice.org2.2 -view %s
application/x-starwriter; openoffice.org2.2 -view %s
application/vnd.oasis.opendocument.formula; openoffice.org2.2 -view %s
application/vnd.sun.xml.math; openoffice.org2.2 -view %s
application/vnd.stardivision.math; openoffice.org2.2 -view %s
application/x-starmath; openoffice.org2.2 -view %s
application/msword; openoffice.org2.2 -view %s
application/vnd.oasis.opendocument.spreadsheet; openoffice.org2.2 -view %s
application/vnd.oasis.opendocument.spreadsheet-template; openoffice.org2.2 -view %s
application/vnd.sun.xml.calc; openoffice.org2.2 -view %s
application/vnd.sun.xml.calc.template; openoffice.org2.2 -view %s
application/vnd.stardivision.calc; openoffice.org2.2 -view %s
application/x-starcalc; openoffice.org2.2 -view %s
application/vnd.stardivision.chart; openoffice.org2.2 -view %s
application/x-starchart; openoffice.org2.2 -view %s
application/excel; openoffice.org2.2 -view %s
application/msexcel; openoffice.org2.2 -view %s
application/vnd.ms-excel; openoffice.org2.2 -view %s
application/x-msexcel; openoffice.org2.2 -view %s
application/vnd.oasis.opendocument.presentation; openoffice.org2.2 -view %s
application/vnd.oasis.opendocument.presentation-template; openoffice.org2.2 -view %s
application/vnd.sun.xml.impress; openoffice.org2.2 -view %s
application/vnd.sun.xml.impress.template; openoffice.org2.2 -view %s
application/vnd.stardivision.impress; openoffice.org2.2 -view %s
application/x-starimpress; openoffice.org2.2 -view %s
application/powerpoint; openoffice.org2.2 -view %s
application/mspowerpoint; openoffice.org2.2 -view %s
application/vnd.ms-powerpoint; openoffice.org2.2 -view %s
application/x-mspowerpoint; openoffice.org2.2 -view %s
application/vnd.oasis.opendocument.graphics; openoffice.org2.2 -view %s
application/vnd.oasis.opendocument.graphics-template; openoffice.org2.2 -view %s
application/vnd.sun.xml.draw; openoffice.org2.2 -view %s
application/vnd.sun.xml.draw.template; openoffice.org2.2 -view %s
application/vnd.stardivision.draw; openoffice.org2.2 -view %s
application/x-stardraw; openoffice.org2.2 -view %s
application/vnd.sun.xml.base; openoffice.org2.2 -view %s
application/vnd.oasis.opendocument.database; openoffice.org2.2 -view %s
application/vnd.writerperfect; openoffice.org2.2 -view %s
application/wordperfect5.1; openoffice.org2.2 -view %s
application/x-wordperfect; openoffice.org2.2 -view %s
application/wordperfect; openoffice.org2.2 -view %s
application/wpwin; openoffice.org2.2 -view %s
application/vnd.openofficeorg.extension; unopkg gui %s
END
else
# backing all entries pointing to our binary
sed '/openoffice.org2.2/d' ${PKG_INSTALL_ROOT}/etc/mailcap 2>/dev/null
fi

