# Give all binaries in the package realtime capabilities when they
# link to Jack2 (thanks to SBO's Johannes Schoepfer and Arik Miller):
if [ -x /sbin/setcap ]; then
  SCBINS=( "supernova"
"scsynth"
"sclang"
"scide" )
  for EXE in "${SCBINS[@]}" ; do
    if [ -n "$(readelf -d usr/bin/$EXE | grep libjack.so)" ]; then
      /sbin/setcap cap_ipc_lock,cap_sys_nice=ep "usr/bin/$EXE"
    fi
  done
fi

# 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/lib ; rm -rf libscsynth.so )
( cd usr/lib ; ln -sf libscsynth.so.1 libscsynth.so )
( cd usr/lib ; rm -rf libscsynth.so.1 )
( cd usr/lib ; ln -sf libscsynth.so.1.0.0 libscsynth.so.1 )
