#!/bin/sh

config() {
  NEW="$1"
  OLD="`dirname $NEW`/`basename $NEW .new`"
  # If there's no config file by that name, mv it over:
  if [ ! -r $OLD ]; then
    mv $NEW $OLD
  elif [ "`cat $OLD | md5sum`" = "`cat $NEW | md5sum`" ]; then # toss the redundant copy
    rm $NEW
  fi
  # Otherwise, we leave the .new copy for the admin to consider...
}

config etc/mplayer/codecs.conf.new
config etc/mplayer/dvb-menu.conf.new
config etc/mplayer/mplayer.conf.new
config etc/mplayer/input.conf.new
config etc/mplayer/menu.conf.new


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

if [ -x /usr/bin/update-desktop-database ]; then
  /usr/bin/update-desktop-database &> /dev/null
fi

if [ -x /usr/bin/gtk-update-icon-cache ]; then
  /usr/bin/gtk-update-icon-cache  -f -q /usr/share/icons/hicolor &> /dev/null
fi

( cd usr/man/pl/man1 ; rm -rf mencoder.1 )
( cd usr/man/pl/man1 ; ln -sf mplayer.1 mencoder.1 )
( cd usr/man/hu/man1 ; rm -rf mencoder.1 )
( cd usr/man/hu/man1 ; ln -sf mplayer.1 mencoder.1 )
( cd usr/man/it/man1 ; rm -rf mencoder.1 )
( cd usr/man/it/man1 ; ln -sf mplayer.1 mencoder.1 )
( cd usr/man/cs/man1 ; rm -rf mencoder.1 )
( cd usr/man/cs/man1 ; ln -sf mplayer.1 mencoder.1 )
( cd usr/man/de/man1 ; rm -rf mencoder.1 )
( cd usr/man/de/man1 ; ln -sf mplayer.1 mencoder.1 )
( cd usr/man/zh_CN/man1 ; rm -rf mencoder.1 )
( cd usr/man/zh_CN/man1 ; ln -sf mplayer.1 mencoder.1 )
( cd usr/man/man1 ; rm -rf mencoder.1 )
( cd usr/man/man1 ; ln -sf mplayer.1 mencoder.1 )
( cd usr/man/ru/man1 ; rm -rf mencoder.1 )
( cd usr/man/ru/man1 ; ln -sf mplayer.1 mencoder.1 )
( cd usr/man/es/man1 ; rm -rf mencoder.1 )
( cd usr/man/es/man1 ; ln -sf mplayer.1 mencoder.1 )
( cd usr/man/fr/man1 ; rm -rf mencoder.1 )
( cd usr/man/fr/man1 ; ln -sf mplayer.1 mencoder.1 )
( cd usr/bin ; rm -rf gmplayer )
( cd usr/bin ; ln -sf mplayer gmplayer )
( cd usr/share/mplayer ; rm -rf subfont.ttf )
( cd usr/share/mplayer ; ln -sf /usr/share/fonts/TTF/DejaVuSans.ttf subfont.ttf )
