# Save old config files:
if [ ! -L etc/X11/tdm ]; then
  if [ -d etc/X11/tdm ]; then
    mkdir -p etc/tde/tdm
    cp -a etc/X11/tdm/* etc/tde/tdm
    rm -rf etc/X11/tdm
    ( cd etc/X11 ; ln -sf /etc/tde/tdm tdm )
  fi
elif [ ! -e etc/X11/tdm ]; then
  mkdir -p etc/X11
  ( cd etc/X11 ; ln -sf /etc/tde/tdm tdm )
fi

#!/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/tde/tdm/tdmrc.new
config etc/tde/tdm/backgroundrc.new

# Update the desktop database:
if [ -x usr/bin/update-desktop-database ]; then
  chroot . /usr/bin/update-desktop-database usr/share/applications > /dev/null 2>&1
fi

# Update hicolor theme cache:
if [ -d usr/share/icons/hicolor ]; then
  if [ -x /usr/bin/gtk-update-icon-cache ]; then
    chroot . /usr/bin/gtk-update-icon-cache -f -t usr/share/icons/hicolor 1> /dev/null 2> /dev/null
  fi
fi

# Update the mime database:
if [ -x usr/bin/update-mime-database ]; then
  chroot . /usr/bin/update-mime-database usr/share/mime >/dev/null 2>&1
fi
( cd usr/lib64/trinity/plugins/integration ; rm -rf libqtkde.so.0 )
( cd usr/lib64/trinity/plugins/integration ; ln -sf libqtkde.so.0.0.0 libqtkde.so.0 )
( cd usr/lib64/trinity/plugins/integration ; rm -rf libqtkde.so )
( cd usr/lib64/trinity/plugins/integration ; ln -sf libqtkde.so.0 libqtkde.so )
( cd usr/lib64 ; rm -rf libkonq.so.4 )
( cd usr/lib64 ; ln -sf libkonq.so.4.2.0 libkonq.so.4 )
( cd usr/lib64 ; rm -rf libkonq.so )
( cd usr/lib64 ; ln -sf libkonq.so.4 libkonq.so )
( cd usr/lib64 ; rm -rf libtdefontinst.so.0 )
( cd usr/lib64 ; ln -sf libtdefontinst.so.0.0.0 libtdefontinst.so.0 )
( cd usr/lib64 ; rm -rf libtdefontinst.so )
( cd usr/lib64 ; ln -sf libtdefontinst.so.0 libtdefontinst.so )
( cd usr/lib64 ; rm -rf libtdecorations.so.1 )
( cd usr/lib64 ; ln -sf libtdecorations.so.1.0.0 libtdecorations.so.1 )
( cd usr/lib64 ; rm -rf libtdecorations.so )
( cd usr/lib64 ; ln -sf libtdecorations.so.1 libtdecorations.so )
( cd usr/lib64 ; rm -rf libkateutils.so.0 )
( cd usr/lib64 ; ln -sf libkateutils.so.0.0.0 libkateutils.so.0 )
( cd usr/lib64 ; rm -rf libkateutils.so )
( cd usr/lib64 ; ln -sf libkateutils.so.0 libkateutils.so )
( cd usr/lib64 ; rm -rf libkateinterfaces.so.0 )
( cd usr/lib64 ; ln -sf libkateinterfaces.so.0.0.0 libkateinterfaces.so.0 )
( cd usr/lib64 ; rm -rf libkateinterfaces.so )
( cd usr/lib64 ; ln -sf libkateinterfaces.so.0 libkateinterfaces.so )
( cd usr/lib64 ; rm -rf libkonqsidebarplugin.so.1 )
( cd usr/lib64 ; ln -sf libkonqsidebarplugin.so.1.2.0 libkonqsidebarplugin.so.1 )
( cd usr/lib64 ; rm -rf libkonqsidebarplugin.so )
( cd usr/lib64 ; ln -sf libkonqsidebarplugin.so.1 libkonqsidebarplugin.so )
( cd usr/lib64 ; rm -rf libkickermain.so.1 )
( cd usr/lib64 ; ln -sf libkickermain.so.1.0.0 libkickermain.so.1 )
( cd usr/lib64 ; rm -rf libkickermain.so )
( cd usr/lib64 ; ln -sf libkickermain.so.1 libkickermain.so )
( cd usr/lib64 ; rm -rf libtaskmanager.so.1 )
( cd usr/lib64 ; ln -sf libtaskmanager.so.1.0.0 libtaskmanager.so.1 )
( cd usr/lib64 ; rm -rf libtaskmanager.so )
( cd usr/lib64 ; ln -sf libtaskmanager.so.1 libtaskmanager.so )
( cd usr/lib64 ; rm -rf libtaskbar.so.1 )
( cd usr/lib64 ; ln -sf libtaskbar.so.1.2.0 libtaskbar.so.1 )
( cd usr/lib64 ; rm -rf libtaskbar.so )
( cd usr/lib64 ; ln -sf libtaskbar.so.1 libtaskbar.so )
( cd usr/lib64 ; rm -rf libkickoffsearch_interfaces.so.0 )
( cd usr/lib64 ; ln -sf libkickoffsearch_interfaces.so.0.0.0 libkickoffsearch_interfaces.so.0 )
( cd usr/lib64 ; rm -rf libkickoffsearch_interfaces.so )
( cd usr/lib64 ; ln -sf libkickoffsearch_interfaces.so.0 libkickoffsearch_interfaces.so )
( cd usr/lib64 ; rm -rf libkasbar.so.1 )
( cd usr/lib64 ; ln -sf libkasbar.so.1.0.0 libkasbar.so.1 )
( cd usr/lib64 ; rm -rf libkasbar.so )
( cd usr/lib64 ; ln -sf libkasbar.so.1 libkasbar.so )
( cd usr/lib64 ; rm -rf libksplashthemes.so.0 )
( cd usr/lib64 ; ln -sf libksplashthemes.so.0.0.0 libksplashthemes.so.0 )
( cd usr/lib64 ; rm -rf libksplashthemes.so )
( cd usr/lib64 ; ln -sf libksplashthemes.so.0 libksplashthemes.so )
( cd usr/lib64 ; rm -rf libkhotkeys_shared.so.1 )
( cd usr/lib64 ; ln -sf libkhotkeys_shared.so.1.0.0 libkhotkeys_shared.so.1 )
( cd usr/lib64 ; rm -rf libkhotkeys_shared.so )
( cd usr/lib64 ; ln -sf libkhotkeys_shared.so.1 libkhotkeys_shared.so )
( cd usr/lib64 ; rm -rf libksgrd.so.1 )
( cd usr/lib64 ; ln -sf libksgrd.so.1.2.0 libksgrd.so.1 )
( cd usr/lib64 ; rm -rf libksgrd.so )
( cd usr/lib64 ; ln -sf libksgrd.so.1 libksgrd.so )
( cd usr/share/config ; rm -rf tdm )
( cd usr/share/config ; ln -sf ../../../etc/tde/tdm tdm )
