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/java/jvm.cfg.new
config etc/java/java.policy.new
config etc/java/java.security.new
config etc/java/nss.cfg.new

if [ -x usr/bin/update-desktop-database ]; then
  chroot . /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
    chroot . /usr/bin/gtk-update-icon-cache usr/share/icons/hicolor >/dev/null 2>&1
  fi
fi


( cd usr/lib ; rm -rf libjvm.so )
( cd usr/lib ; ln -sf ./java/jre/lib/i586/server/libjvm.so libjvm.so )
( cd usr/lib/java/jre/man ; rm -rf ja )
( cd usr/lib/java/jre/man ; ln -sf ja_JP.UTF-8 ja )
( cd usr/lib/java/jre/lib/security ; rm -rf nss.cfg )
( cd usr/lib/java/jre/lib/security ; ln -sf /etc/java/nss.cfg nss.cfg )
( cd usr/lib/java/jre/lib/security ; rm -rf java.policy )
( cd usr/lib/java/jre/lib/security ; ln -sf /etc/java/java.policy java.policy )
( cd usr/lib/java/jre/lib/security ; rm -rf java.security )
( cd usr/lib/java/jre/lib/security ; ln -sf /etc/java/java.security java.security )
( cd usr/lib/java/jre/lib/i386/server ; rm -rf libjsig.so )
( cd usr/lib/java/jre/lib/i386/server ; ln -sf ../libjsig.so libjsig.so )
( cd usr/lib/java/jre/lib/i386/client ; rm -rf libjsig.so )
( cd usr/lib/java/jre/lib/i386/client ; ln -sf ../libjsig.so libjsig.so )
( cd usr/lib/java ; rm -rf jre7u85_b01 )
( cd usr/lib/java ; ln -sf jre jre7u85_b01 )
