( cd usr/lib ; rm -rf libgnc-core-utils.so )
( cd usr/lib ; ln -sf libgnc-core-utils.so.0.0.0 libgnc-core-utils.so )
( cd usr/lib ; rm -rf libgnc-backend-file-utils.so.0 )
( cd usr/lib ; ln -sf libgnc-backend-file-utils.so.0.0.0 libgnc-backend-file-utils.so.0 )
( cd usr/lib/gnucash ; rm -rf libgncmod-qif.so )
( cd usr/lib/gnucash ; ln -sf libgncmod-qif.so.0.0.0 libgncmod-qif.so )
( cd usr/lib/gnucash ; rm -rf libgncmod-qif.so.0 )
( cd usr/lib/gnucash ; ln -sf libgncmod-qif.so.0.0.0 libgncmod-qif.so.0 )
( cd usr/lib ; rm -rf libgnc-qof.so.1 )
( cd usr/lib ; ln -sf libgnc-qof.so.1.0.4 libgnc-qof.so.1 )
( cd usr/lib ; rm -rf libgnc-gnome.so )
( cd usr/lib ; ln -sf libgnc-gnome.so.0.0.0 libgnc-gnome.so )
( cd usr/lib ; rm -rf libgnc-business-ledger.so.0 )
( cd usr/lib ; ln -sf libgnc-business-ledger.so.0.0.0 libgnc-business-ledger.so.0 )
( cd usr/lib ; rm -rf libgnc-module.so.0 )
( cd usr/lib ; ln -sf libgnc-module.so.0.0.0 libgnc-module.so.0 )
( cd usr/lib ; rm -rf libgnc-module.so )
( cd usr/lib ; ln -sf libgnc-module.so.0.0.0 libgnc-module.so )
( cd usr/lib ; rm -rf libgnc-gnome.so.0 )
( cd usr/lib ; ln -sf libgnc-gnome.so.0.0.0 libgnc-gnome.so.0 )
( cd usr/lib ; rm -rf libgnc-core-utils.so.0 )
( cd usr/lib ; ln -sf libgnc-core-utils.so.0.0.0 libgnc-core-utils.so.0 )
( cd usr/lib ; rm -rf libgnc-backend-file-utils.so )
( cd usr/lib ; ln -sf libgnc-backend-file-utils.so.0.0.0 libgnc-backend-file-utils.so )
( cd usr/lib ; rm -rf libgnc-qof.so )
( cd usr/lib ; ln -sf libgnc-qof.so.1.0.4 libgnc-qof.so )
( cd usr/lib ; rm -rf libgnc-business-ledger.so )
( cd usr/lib ; ln -sf libgnc-business-ledger.so.0.0.0 libgnc-business-ledger.so )
( cd usr/share/gnucash ; rm -rf gnome )
( cd usr/share/gnucash ; ln -sf ../gnome gnome )

if [ -x usr/bin/gconftool-2 ]; then
GCONF_CONFIG_SOURCE="$(usr/bin/gconftool-2 --get-default-source)" usr/bin/gconftool-2 --makefile-install-rule etc/gconf/schemas/apps_gnucash_dialog_business_common.schemas >/dev/null 2>&1
GCONF_CONFIG_SOURCE="$(usr/bin/gconftool-2 --get-default-source)" usr/bin/gconftool-2 --makefile-install-rule etc/gconf/schemas/apps_gnucash_dialog_commodities.schemas >/dev/null 2>&1
GCONF_CONFIG_SOURCE="$(usr/bin/gconftool-2 --get-default-source)" usr/bin/gconftool-2 --makefile-install-rule etc/gconf/schemas/apps_gnucash_dialog_common.schemas >/dev/null 2>&1
GCONF_CONFIG_SOURCE="$(usr/bin/gconftool-2 --get-default-source)" usr/bin/gconftool-2 --makefile-install-rule etc/gconf/schemas/apps_gnucash_dialog_hbci.schemas >/dev/null 2>&1
GCONF_CONFIG_SOURCE="$(usr/bin/gconftool-2 --get-default-source)" usr/bin/gconftool-2 --makefile-install-rule etc/gconf/schemas/apps_gnucash_dialog_prices.schemas >/dev/null 2>&1
GCONF_CONFIG_SOURCE="$(usr/bin/gconftool-2 --get-default-source)" usr/bin/gconftool-2 --makefile-install-rule etc/gconf/schemas/apps_gnucash_dialog_print_checks.schemas >/dev/null 2>&1
GCONF_CONFIG_SOURCE="$(usr/bin/gconftool-2 --get-default-source)" usr/bin/gconftool-2 --makefile-install-rule etc/gconf/schemas/apps_gnucash_dialog_reconcile.schemas >/dev/null 2>&1
GCONF_CONFIG_SOURCE="$(usr/bin/gconftool-2 --get-default-source)" usr/bin/gconftool-2 --makefile-install-rule etc/gconf/schemas/apps_gnucash_dialog_scheduled_transctions.schemas >/dev/null 2>&1
GCONF_CONFIG_SOURCE="$(usr/bin/gconftool-2 --get-default-source)" usr/bin/gconftool-2 --makefile-install-rule etc/gconf/schemas/apps_gnucash_dialog_totd.schemas >/dev/null 2>&1
GCONF_CONFIG_SOURCE="$(usr/bin/gconftool-2 --get-default-source)" usr/bin/gconftool-2 --makefile-install-rule etc/gconf/schemas/apps_gnucash_general.schemas >/dev/null 2>&1
GCONF_CONFIG_SOURCE="$(usr/bin/gconftool-2 --get-default-source)" usr/bin/gconftool-2 --makefile-install-rule etc/gconf/schemas/apps_gnucash_history.schemas >/dev/null 2>&1
GCONF_CONFIG_SOURCE="$(usr/bin/gconftool-2 --get-default-source)" usr/bin/gconftool-2 --makefile-install-rule etc/gconf/schemas/apps_gnucash_import_generic_matcher.schemas >/dev/null 2>&1
GCONF_CONFIG_SOURCE="$(usr/bin/gconftool-2 --get-default-source)" usr/bin/gconftool-2 --makefile-install-rule etc/gconf/schemas/apps_gnucash_warnings.schemas >/dev/null 2>&1
GCONF_CONFIG_SOURCE="$(usr/bin/gconftool-2 --get-default-source)" usr/bin/gconftool-2 --makefile-install-rule etc/gconf/schemas/apps_gnucash_window_pages_account_tree.schemas >/dev/null 2>&1
GCONF_CONFIG_SOURCE="$(usr/bin/gconftool-2 --get-default-source)" usr/bin/gconftool-2 --makefile-install-rule etc/gconf/schemas/apps_gnucash_window_pages_register.schemas >/dev/null 2>&1
fi
ldconfig ;

function install_file() {
  # $1 = File to process

  FILE="$(dirname "$1")/$(basename "$1" .new)"
  if [ ! -e "$FILE" ]
  then
    mv "$FILE.new" "$FILE"
  elif [ "$(cat "$FILE" | md5sum)" != "$(cat "$FILE.new" | md5sum)" ]
  then
    #     |--------|--------------------------------------------------|
    echo "WARNING: $FILE has been customised."
    echo "         Examine the $FILE.new file"
    echo "         and integrate any changes into the custom file."
    echo
  else
    rm -f "$FILE.new"
  fi
}

install_file etc/gnucash/config.new

if [ -x usr/bin/rarian-sk-update ]; then
  usr/bin/rarian-sk-update 1> /dev/null 2> /dev/null
fi

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

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