if [ -x /usr/bin/update-mime-database ]; then
  /usr/bin/update-mime-database usr/share/mime >/dev/null 2>&1
fi

if [ -x /usr/bin/update-desktop-database ]; then
  /usr/bin/update-desktop-database -q usr/share/applications >/dev/null 2>&1
fi

if [ -e usr/share/icons/hicolor/icon-theme.cache ]; then
  if [ -x /usr/bin/gtk-update-icon-cache ]; then
    /usr/bin/gtk-update-icon-cache -f usr/share/icons/hicolor >/dev/null 2>&1
  fi
fi

# if there's no tos.img symlink, take over with emutos.img
if [ ! -r usr/share/hatari/tos.img ]; then
  ( cd usr/share/hatari ; ln -sf emutos.img tos.img )
fi
( cd usr/share/icons/hicolor/128x128/mimetypes ; rm -rf application-vnd.fastcopy-disk-image.png )
( cd usr/share/icons/hicolor/128x128/mimetypes ; ln -sf application-x-st-disk-image.png application-vnd.fastcopy-disk-image.png )
( cd usr/share/icons/hicolor/128x128/mimetypes ; rm -rf application-vnd.msa-disk-image.png )
( cd usr/share/icons/hicolor/128x128/mimetypes ; ln -sf application-x-st-disk-image.png application-vnd.msa-disk-image.png )
( cd usr/share/icons/hicolor/128x128/mimetypes ; rm -rf application-x-stx-disk-image.png )
( cd usr/share/icons/hicolor/128x128/mimetypes ; ln -sf application-x-st-disk-image.png application-x-stx-disk-image.png )
( cd usr/share/icons/hicolor/128x128/mimetypes ; rm -rf x-st-executable.png )
( cd usr/share/icons/hicolor/128x128/mimetypes ; ln -sf application-x-st-disk-image.png x-st-executable.png )
( cd usr/share/icons/hicolor/256x256/mimetypes ; rm -rf application-vnd.fastcopy-disk-image.png )
( cd usr/share/icons/hicolor/256x256/mimetypes ; ln -sf application-x-st-disk-image.png application-vnd.fastcopy-disk-image.png )
( cd usr/share/icons/hicolor/256x256/mimetypes ; rm -rf application-vnd.msa-disk-image.png )
( cd usr/share/icons/hicolor/256x256/mimetypes ; ln -sf application-x-st-disk-image.png application-vnd.msa-disk-image.png )
( cd usr/share/icons/hicolor/256x256/mimetypes ; rm -rf application-x-stx-disk-image.png )
( cd usr/share/icons/hicolor/256x256/mimetypes ; ln -sf application-x-st-disk-image.png application-x-stx-disk-image.png )
( cd usr/share/icons/hicolor/256x256/mimetypes ; rm -rf x-st-executable.png )
( cd usr/share/icons/hicolor/256x256/mimetypes ; ln -sf application-x-st-disk-image.png x-st-executable.png )
( cd usr/share/icons/hicolor/32x32/mimetypes ; rm -rf application-vnd.fastcopy-disk-image.png )
( cd usr/share/icons/hicolor/32x32/mimetypes ; ln -sf application-x-st-disk-image.png application-vnd.fastcopy-disk-image.png )
( cd usr/share/icons/hicolor/32x32/mimetypes ; rm -rf application-vnd.msa-disk-image.png )
( cd usr/share/icons/hicolor/32x32/mimetypes ; ln -sf application-x-st-disk-image.png application-vnd.msa-disk-image.png )
( cd usr/share/icons/hicolor/32x32/mimetypes ; rm -rf application-x-stx-disk-image.png )
( cd usr/share/icons/hicolor/32x32/mimetypes ; ln -sf application-x-st-disk-image.png application-x-stx-disk-image.png )
( cd usr/share/icons/hicolor/32x32/mimetypes ; rm -rf x-st-executable.png )
( cd usr/share/icons/hicolor/32x32/mimetypes ; ln -sf application-x-st-disk-image.png x-st-executable.png )
( cd usr/share/icons/hicolor/48x48/mimetypes ; rm -rf application-vnd.fastcopy-disk-image.png )
( cd usr/share/icons/hicolor/48x48/mimetypes ; ln -sf application-x-st-disk-image.png application-vnd.fastcopy-disk-image.png )
( cd usr/share/icons/hicolor/48x48/mimetypes ; rm -rf application-vnd.msa-disk-image.png )
( cd usr/share/icons/hicolor/48x48/mimetypes ; ln -sf application-x-st-disk-image.png application-vnd.msa-disk-image.png )
( cd usr/share/icons/hicolor/48x48/mimetypes ; rm -rf application-x-stx-disk-image.png )
( cd usr/share/icons/hicolor/48x48/mimetypes ; ln -sf application-x-st-disk-image.png application-x-stx-disk-image.png )
( cd usr/share/icons/hicolor/48x48/mimetypes ; rm -rf x-st-executable.png )
( cd usr/share/icons/hicolor/48x48/mimetypes ; ln -sf application-x-st-disk-image.png x-st-executable.png )
( cd usr/share/icons/hicolor/64x64/mimetypes ; rm -rf application-vnd.fastcopy-disk-image.png )
( cd usr/share/icons/hicolor/64x64/mimetypes ; ln -sf application-x-st-disk-image.png application-vnd.fastcopy-disk-image.png )
( cd usr/share/icons/hicolor/64x64/mimetypes ; rm -rf application-vnd.msa-disk-image.png )
( cd usr/share/icons/hicolor/64x64/mimetypes ; ln -sf application-x-st-disk-image.png application-vnd.msa-disk-image.png )
( cd usr/share/icons/hicolor/64x64/mimetypes ; rm -rf application-x-stx-disk-image.png )
( cd usr/share/icons/hicolor/64x64/mimetypes ; ln -sf application-x-st-disk-image.png application-x-stx-disk-image.png )
( cd usr/share/icons/hicolor/64x64/mimetypes ; rm -rf x-st-executable.png )
( cd usr/share/icons/hicolor/64x64/mimetypes ; ln -sf application-x-st-disk-image.png x-st-executable.png )
( cd usr/share/icons/hicolor/scalable/mimetypes ; rm -rf application-vnd.fastcopy-disk-image.svg )
( cd usr/share/icons/hicolor/scalable/mimetypes ; ln -sf application-x-st-disk-image.svg application-vnd.fastcopy-disk-image.svg )
( cd usr/share/icons/hicolor/scalable/mimetypes ; rm -rf application-vnd.msa-disk-image.svg )
( cd usr/share/icons/hicolor/scalable/mimetypes ; ln -sf application-x-st-disk-image.svg application-vnd.msa-disk-image.svg )
( cd usr/share/icons/hicolor/scalable/mimetypes ; rm -rf application-x-stx-disk-image.svg )
( cd usr/share/icons/hicolor/scalable/mimetypes ; ln -sf application-x-st-disk-image.svg application-x-stx-disk-image.svg )
( cd usr/share/icons/hicolor/scalable/mimetypes ; rm -rf x-st-executable.svg )
( cd usr/share/icons/hicolor/scalable/mimetypes ; ln -sf application-x-st-disk-image.svg x-st-executable.svg )
