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...
}

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

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/gtk-update-icon-cache ] \
  && [ -e usr/share/icons/hicolor/icon-theme.cache ]; then
  /usr/bin/gtk-update-icon-cache usr/share/icons/hicolor >/dev/null 2>&1
fi

config etc/ardour4/./trx.menus.new
config etc/ardour4/./default_ui_config.new
config etc/ardour4/./ardour.menus.new
config etc/ardour4/./mnemonic-us.bindings.new
config etc/ardour4/./dark.colors.new
config etc/ardour4/./mixer.bindings.new
config etc/ardour4/./system_config.new
config etc/ardour4/./step_editing.bindings.new
config etc/ardour4/./clearlooks.rc.new
config etc/ardour4/./export/CD.format.new
( cd usr/lib/ardour4 ; rm -rf libardour.so.3 )
( cd usr/lib/ardour4 ; ln -sf libardour.so.3.0.0 libardour.so.3 )
( cd usr/lib/ardour4 ; rm -rf libaudiographer.so.0 )
( cd usr/lib/ardour4 ; ln -sf libaudiographer.so.0.0.0 libaudiographer.so.0 )
( cd usr/lib/ardour4 ; rm -rf libptformat.so )
( cd usr/lib/ardour4 ; ln -sf libptformat.so.0.0.0 libptformat.so )
( cd usr/lib/ardour4 ; rm -rf libardour.so )
( cd usr/lib/ardour4 ; ln -sf libardour.so.3.0.0 libardour.so )
( cd usr/lib/ardour4 ; rm -rf libgtkmm2ext.so )
( cd usr/lib/ardour4 ; ln -sf libgtkmm2ext.so.0.8.3 libgtkmm2ext.so )
( cd usr/lib/ardour4 ; rm -rf libgtkmm2ext.so.0 )
( cd usr/lib/ardour4 ; ln -sf libgtkmm2ext.so.0.8.3 libgtkmm2ext.so.0 )
( cd usr/lib/ardour4 ; rm -rf libptformat.so.0 )
( cd usr/lib/ardour4 ; ln -sf libptformat.so.0.0.0 libptformat.so.0 )
( cd usr/lib/ardour4 ; rm -rf libqmdsp.so )
( cd usr/lib/ardour4 ; ln -sf libqmdsp.so.0.0.0 libqmdsp.so )
( cd usr/lib/ardour4 ; rm -rf libevoral.so.0 )
( cd usr/lib/ardour4 ; ln -sf libevoral.so.0.0.0 libevoral.so.0 )
( cd usr/lib/ardour4/vamp ; rm -rf libardourvampplugins.so )
( cd usr/lib/ardour4/vamp ; ln -sf libardourvampplugins.so.0.0.0 libardourvampplugins.so )
( cd usr/lib/ardour4/vamp ; rm -rf libardourvampplugins.so.0 )
( cd usr/lib/ardour4/vamp ; ln -sf libardourvampplugins.so.0.0.0 libardourvampplugins.so.0 )
( cd usr/lib/ardour4 ; rm -rf libardouralsautil.so )
( cd usr/lib/ardour4 ; ln -sf libardouralsautil.so.0.0.1 libardouralsautil.so )
( cd usr/lib/ardour4 ; rm -rf libpbd.so )
( cd usr/lib/ardour4 ; ln -sf libpbd.so.4.1.0 libpbd.so )
( cd usr/lib/ardour4 ; rm -rf libcanvas.so.0 )
( cd usr/lib/ardour4 ; ln -sf libcanvas.so.0.0.0 libcanvas.so.0 )
( cd usr/lib/ardour4 ; rm -rf libmidipp.so )
( cd usr/lib/ardour4 ; ln -sf libmidipp.so.4.1.0 libmidipp.so )
( cd usr/lib/ardour4 ; rm -rf libcanvas.so )
( cd usr/lib/ardour4 ; ln -sf libcanvas.so.0.0.0 libcanvas.so )
( cd usr/lib/ardour4 ; rm -rf libaudiographer.so )
( cd usr/lib/ardour4 ; ln -sf libaudiographer.so.0.0.0 libaudiographer.so )
( cd usr/lib/ardour4 ; rm -rf libardouralsautil.so.0 )
( cd usr/lib/ardour4 ; ln -sf libardouralsautil.so.0.0.1 libardouralsautil.so.0 )
( cd usr/lib/ardour4 ; rm -rf libmidipp.so.4 )
( cd usr/lib/ardour4 ; ln -sf libmidipp.so.4.1.0 libmidipp.so.4 )
( cd usr/lib/ardour4 ; rm -rf libevoral.so )
( cd usr/lib/ardour4 ; ln -sf libevoral.so.0.0.0 libevoral.so )
( cd usr/lib/ardour4 ; rm -rf libpbd.so.4 )
( cd usr/lib/ardour4 ; ln -sf libpbd.so.4.1.0 libpbd.so.4 )
( cd usr/lib/ardour4 ; rm -rf libqmdsp.so.0 )
( cd usr/lib/ardour4 ; ln -sf libqmdsp.so.0.0.0 libqmdsp.so.0 )
