3 ####################################
6 # Ardour/Mixbus bundle installer
9 ###################################
11 MAJOR_VERSION="%REPLACE_MAJOR_VERSION%"
15 PGM_EXEC_FILE="ardour${MAJOR_VERSION}"
19 if test -z "$INSTALL_DEST_BASE"; then
20 INSTALL_DEST_BASE="/opt"
26 USER_BIN_DIR="/usr/local/bin"
28 PGM_NAME_LOWER=$(echo $PGM_NAME | tr '[:upper:]' '[:lower:]')
32 #### Global Variables ####
35 ########################
36 # Function Definitions
37 ########################
39 VaildateYesNoQuestion ()
46 until test "y" = $INPUT_OK;
49 read -p "$1 [y/n]: " USER_INPUT
52 if [ ! -z $USER_INPUT ];
54 if [ "Y" = $USER_INPUT -o "y" = $USER_INPUT -o "n" = $USER_INPUT -o "N" = $USER_INPUT ];
61 echo $USER_INPUT | tr '[:upper:]' '[:lower:]'
68 # Determine which software install app to use and then install requested package
71 if which yum > /dev/null;
73 ${SUPER} yum -y install $1
79 echo "!!! ERROR !!! yum install failed for an unknown reason."
80 echo "Please install package $1 after this installer completes."
84 elif which apt-get > /dev/null;
86 ${SUPER} apt-get -y install $1
92 echo "!!! ERROR !!! apt-get install failed for an unknown reason."
93 echo "Please install package $1 after this installer completes."
99 echo "!!! ERROR !!! - Not able to detect which software install tool to use (yum or apt-get)."
100 echo "Please install package $1 using the system software install tool."
109 ########################################################################
111 ########################################################################
114 # If you double click a script, some systems don't get the PWD correct.
115 # Force it to be correct
116 PKG_PATH=$(dirname "$(readlink -f "$0")")
120 echo "Welcome to the ${PGM_NAME} installer"
122 echo "${PGM_NAME} will be installed for user ${USER_NAME} in ${INSTALL_DEST_BASE}"
124 #############################
125 # Check for root privileges
126 #############################
131 if [ "$(id -u)" != "0" ]; then
133 if ! which sudo > /dev/null;
136 echo "Sudo installed failed, attempting to install using su"
137 echo "Please enter root password below"
140 if ! su -s $THE_SHELL -c "./.stage2.run";
145 echo "This installer requires root privileges. It is currently not"
146 echo "running as root AND an attempt to use su failed."
148 echo "Please correct this by installing and configuring sudo or running"
149 echo "the installer as root (su -s $THE_SHELL -c)."
151 read -p "Press ENTER to exit installer:" BLAH
156 sudo -k # make sudo forget about cached credentials
162 echo "Attempting to install using su"
163 echo "Please enter root password below"
166 if ! su -s $THE_SHELL -c "./.stage2.run";
171 echo "This installer requires root privileges. It is currently not"
172 echo "running as root AND an attempt to use both sudo and su failed."
174 echo "Please correct this by installing and configuring sudo or running"
175 echo "the installer as root (su -s $THE_SHELL -c)."
177 read -p "Press ENTER to exit installer:" BLAH
184 # The quoting reqired for the su sanityCheck method does not work when used without
185 # su. Using sh -c in the normal case gets around that, but is a bit of a hack.
188 NORM_USER="su -l $USER_NAME -s $THE_SHELL -c"
191 ###############################
192 # Check for install destination
193 ###############################
195 if test -n "$CALL_MKDIR"; then
196 ${SUPER} mkdir -p "$INSTALL_DEST_BASE"
199 if [ ! -d ${INSTALL_DEST_BASE} ];
202 echo "!!! ERROR !!! - Installation location ${INSTALL_DEST_BASE} does not exist!"
203 echo "Installation will not complete."
205 read -p "Press ENTER to exit installer:" BLAH
210 ############################
211 # Determine processor type
212 ############################
215 i[3456789]86|x86|i86pc)
216 echo "Architecture is x86"
220 echo "Architecture is x86_64"
225 echo "!!! ERROR !!! - Unknown architecture `uname -m`"
227 read -p "Press ENTER to exit installer:" BLAH
236 # We have to check the current folder and the INSTALL_DEST_BASE just
237 # in case they are on different devices
238 echo "Checking for required disk space"
240 if [ ! -e .${PGM_NAME}_${ARCH}-*.size ]; then
242 echo "!!! ERROR !!! Can't locate .size file for ${ARCH} bundle."
243 echo "This package is broken or does not support ${ARCH}."
245 read -p "Press ENTER to exit installer:" BLAH
248 REQUIRED_BYTES=$(cat .${PGM_NAME}_${ARCH}-*.size)
250 #Installer needs 2x the space since the bundle is unpacked locally and then copied
251 REQUIRED_BYTES=$(($REQUIRED_BYTES + $REQUIRED_BYTES))
253 #Check space in current folder
254 FREE_BYTES=$(df -P -B 1 "${PKG_PATH}" | grep / | awk '{print $4}')
256 if [ ${FREE_BYTES} -le ${REQUIRED_BYTES} ] ; then
258 echo "!!! ERROR !!! - Insufficient disk space in ${PKG_PATH}"
259 echo "Install requires ${REQUIRED_BYTES} bytes and"
260 echo "there is only ${FREE_BYTES} bytes of free space"
262 read -p "Press ENTER to exit installer:" BLAH
266 #Check space in INSTALL_DEST_BASE
267 FREE_BYTES=$(df -P -B 1 ${INSTALL_DEST_BASE} | grep / | awk '{print $4}')
269 if [ ${FREE_BYTES} -le ${REQUIRED_BYTES} ] ; then
271 echo "!!! ERROR !!! - Insufficient disk space in ${INSTALL_DEST_BASE}"
272 echo "Install requires ${REQUIRED_BYTES} bytes and"
273 echo "there is only ${FREE_BYTES} bytes of free space"
275 read -p "Press ENTER to exit installer:" BLAH
280 FILESYSTEM_TYPE=$(df -P -T "${PKG_PATH}" | grep / | awk '{print $2}')
281 echo "Bundle is on ${FILESYSTEM_TYPE} filesystem"
283 #####################
285 #####################
287 # untar the correct bundle for us to install
288 echo "Unpacking bundle for $ARCH"
290 if [ ! -e ${PGM_NAME}_${ARCH}-*.tar.bz2 ]; then
292 echo "!!! ERROR !!! Can't locate ${ARCH} bundle file."
294 read -p "Press ENTER to exit installer:" BLAH
298 if ! tar -xjf ${PGM_NAME}_${ARCH}-*.tar.bz2; then
300 echo "!!! ERROR !!! Can't unpack ${ARCH} bundle file."
302 read -p "Press ENTER to exit installer:" BLAH
305 echo "Bundle unpacked"
308 BUNDLE_DIR=$(basename `find -maxdepth 1 -type d -name "${PGM_NAME}_${ARCH}-*"`)
311 #######################
312 # Check for xdg utils
313 #######################
315 #load the file that contains the translated names of the users directories
316 if [ -e /home/${USER_NAME}/.config/user-dirs.dirs ]; then
317 . /home/${USER_NAME}/.config/user-dirs.dirs
320 if [ "$(id -u)" != "0" ]; then
321 USER_DESKTOP_DIR=${XDG_DESKTOP_DIR:-$HOME/Desktop}
323 #running as root with su makes this more difficult
324 DESKTOP_FOLDER=$(echo ${XDG_DESKTOP_DIR:-$HOME/Desktop} | awk -F/ '{print $NF}')
325 USER_DESKTOP_DIR="/home/${USER_NAME}/${DESKTOP_FOLDER}"
328 XDG_MENU_VER=$(xdg-desktop-menu --version 2> /dev/null)
329 if [ -z "$XDG_MENU_VER" ];
331 echo "System does not have xdg-desktop-menu installed"
335 XDG_ICON_VER=$(xdg-icon-resource --version 2> /dev/null)
336 if [ -z "$XDG_ICON_VER" ];
338 echo "System does not have xdg-icon-resource installed"
342 #################################################
343 # Check if system libs are OK (libc, etc)
344 #################################################
347 echo "Checking system libs to see if they are compatible with ${PGM_NAME}."
351 LD_PATH=`pwd`/${BUNDLE_DIR}/lib
354 LDD_RESULT=$(LD_LIBRARY_PATH=${LD_PATH} ldd ${BUNDLE_DIR}/bin/${PGM_NAME_LOWER}-* 2>&1 > /dev/null)
356 if [ -n "$LDD_RESULT" ];
363 LIB_FILES=$(find ${BUNDLE_DIR}/lib -name "*.so")
365 for path in $LIB_FILES
367 LDD_RESULT=$(LD_LIBRARY_PATH=${LD_PATH} ldd $path 2>&1 > /dev/null)
368 if [ -n "$LDD_RESULT" ];
375 if test "T" = $LIB_ERROR;
378 echo "!!! ERROR !!! - Missing library detected!"
379 echo "This system does not have the correct libs to run ${PGM_NAME}."
380 echo "Installation will not complete. Please use a compatible distro."
382 read -p "Press ENTER to exit installer:" BLAH
386 ################################
387 # Setup derived variables
388 ################################
389 PGM_VERSION=$(echo ${BUNDLE_DIR} | cut -d- -f2)
390 PGM_BUILDTYPE=$(echo ${BUNDLE_DIR} | cut -d- -f3)
392 if [ -z ${PGM_BUILDTYPE} ];
394 PGM_FULL_NAME="${PGM_NAME}-${PGM_VERSION}"
395 ICON_NAME="${PGM_VENDOR}-${PGM_NAME}_${PGM_VERSION}" #no dash between name and version since dash seperates vendor from program
396 MENU_FILE="${PGM_VENDOR}-${PGM_NAME}_${PGM_VERSION}.desktop" #no dash between name and version since dash seperates vendor from program
397 DESKTOP_LINK_FILE="${PGM_NAME}_${PGM_VERSION}.desktop"
399 PGM_FULL_NAME="${PGM_NAME}-${PGM_VERSION}-${PGM_BUILDTYPE}"
400 ICON_NAME="${PGM_VENDOR}-${PGM_NAME}_${PGM_VERSION}_${PGM_BUILDTYPE}" #no dash between name and version since dash seperates vendor from program
401 MENU_FILE="${PGM_VENDOR}-${PGM_NAME}_${PGM_VERSION}_${PGM_BUILDTYPE}.desktop" #no dash between name and version since dash seperates vendor from program
402 DESKTOP_LINK_FILE="${PGM_NAME}_${PGM_VERSION}_${PGM_BUILDTYPE}.desktop"
405 PGM_EXEC_PATH="${INSTALL_DEST_BASE}/${PGM_FULL_NAME}/bin/${PGM_EXEC_FILE}"
406 ICON_PATH="${INSTALL_DEST_BASE}/${PGM_FULL_NAME}/share/icons"
407 MENU_FILE_PATH="${INSTALL_DEST_BASE}/${PGM_FULL_NAME}/share"
409 ################################
410 # Install bundle and Menu/Link
411 ################################
413 # uninstall any older versions
414 UNINSTALLERS=$(find ${INSTALL_DEST_BASE} -maxdepth 1 -type f -name "${PGM_NAME}*.uninstall.sh")
415 if [ ! -z "$UNINSTALLERS" ];
417 for i in $UNINSTALLERS; do
419 echo "Found existing ${PGM_NAME} installation."
421 ANSWER=$(VaildateYesNoQuestion "Do you want to run the uninstaller ${i} ?")
423 if test "y" = $ANSWER;
426 echo "Running uninstaller $i"
438 echo "Installing ${PGM_NAME} ${PGM_VERSION} in ${INSTALL_DEST_BASE}"
441 # Copy the new version in the install directory
442 ${SUPER} mkdir ${INSTALL_DEST_BASE}/${PGM_FULL_NAME}
443 ${SUPER} cp -Rf ${BUNDLE_DIR}/* ${INSTALL_DEST_BASE}/${PGM_FULL_NAME}/
445 # write the desktop/menu file
446 echo "[Desktop Entry]" > /tmp/${MENU_FILE}
447 echo "Encoding=UTF-8" >> /tmp/${MENU_FILE}
448 echo "Version=1.0" >> /tmp/${MENU_FILE}
449 echo "Type=Application" >> /tmp/${MENU_FILE}
450 echo "Terminal=false" >> /tmp/${MENU_FILE}
451 echo "Exec=${PGM_EXEC_PATH}" >> /tmp/${MENU_FILE}
452 if [ -z ${PGM_BUILDTYPE} ];
454 echo "Name=${PGM_NAME}-${PGM_VERSION}" >> /tmp/${MENU_FILE}
456 echo "Name=${PGM_NAME}-${PGM_VERSION}-${PGM_BUILDTYPE}" >> /tmp/${MENU_FILE}
458 echo "Icon=${ICON_NAME}" >> /tmp/${MENU_FILE}
459 echo "Comment=Digital Audio Workstation" >> /tmp/${MENU_FILE}
460 echo "Categories=AudioVideo;AudioEditing;Audio;Recorder;" >> /tmp/${MENU_FILE}
462 chmod ugo+rx /tmp/${MENU_FILE}
463 ${SUPER} mv /tmp/${MENU_FILE} ${MENU_FILE_PATH}/.
465 # install the Menu, Link, and Icon(s)
466 if [ "T" = ${HAS_XDG} ];
468 echo "Adding ${PGM_NAME} to the applications menu"
469 ${SUPER} xdg-icon-resource install --context apps --size 16 ${ICON_PATH}/${PGM_NAME_LOWER}_icon_16px.png ${ICON_NAME}
470 ${SUPER} xdg-icon-resource install --context apps --size 22 ${ICON_PATH}/${PGM_NAME_LOWER}_icon_22px.png ${ICON_NAME}
471 ${SUPER} xdg-icon-resource install --context apps --size 32 ${ICON_PATH}/${PGM_NAME_LOWER}_icon_32px.png ${ICON_NAME}
472 ${SUPER} xdg-icon-resource install --context apps --size 48 ${ICON_PATH}/${PGM_NAME_LOWER}_icon_48px.png ${ICON_NAME}
473 ${SUPER} xdg-icon-resource install --context apps --size 256 ${ICON_PATH}/${PGM_NAME_LOWER}_icon_256px.png ${ICON_NAME}
475 if [ -e ${ICON_PATH}/${PGM_NAME_LOWER}_icon.svg -a -d /usr/share/icons/hicolor/scalable/apps ];
477 ${SUPER} cp -f ${ICON_PATH}/${PGM_NAME_LOWER}_icon.svg /usr/share/icons/hicolor/scalable/apps/${ICON_NAME}.svg
480 ${SUPER} xdg-desktop-menu install ${MENU_FILE_PATH}/${MENU_FILE}
481 ${SUPER} xdg-desktop-menu forceupdate --mode system # Some systems need an extra kick
484 echo "Creating a desktop link for ${PGM_NAME} in ${USER_DESKTOP_DIR}"
485 cp ${MENU_FILE_PATH}/${MENU_FILE} ${USER_DESKTOP_DIR}/${DESKTOP_LINK_FILE}
486 chmod ugo+rwx ${USER_DESKTOP_DIR}/${DESKTOP_LINK_FILE}
489 echo "Creating a desktop link for ${PGM_NAME} in ${USER_DESKTOP_DIR}"
490 cp ${MENU_FILE_PATH}/${MENU_FILE} ${USER_DESKTOP_DIR}/${DESKTOP_LINK_FILE}
491 chmod ugo+rwx ${USER_DESKTOP_DIR}/${DESKTOP_LINK_FILE}
495 echo "Copying uninstall script to ${INSTALL_DEST_BASE}"
498 ${SUPER} cp -f ${BUNDLE_DIR}/bin/*.uninstall.sh ${INSTALL_DEST_BASE}/.
500 # Create link to the program in user bin
503 echo "Creating link ${PGM_NAME}${MAJOR_VERSION} in ${USER_BIN_DIR}"
506 if [ -d "${USER_BIN_DIR}" ]; then
507 if [ -e "${USER_BIN_DIR}/${PGM_NAME}${MAJOR_VERSION}" ]; then
508 ${SUPER} rm -f ${USER_BIN_DIR}/${PGM_NAME}${MAJOR_VERSION}
512 ${SUPER} ln -sf ${PGM_EXEC_PATH} ${PGM_NAME}${MAJOR_VERSION}
516 echo "Can not create link because ${USER_BIN_DIR} does not exist"
519 ###########################
520 # Check Jack and qjackctl
521 ###########################
524 echo "Checking to see if Jack is installed"
529 if which jackd > /dev/null; then
531 echo "Jack already present"
532 elif which jackdbus > /dev/null; then
534 echo "jackdbus was found but not jackd. Jack version compatibility check cannot be performed."
539 echo "The program Jack is missing from this system. Jack is a required component of $PGM_NAME."
542 ANSWER=$(VaildateYesNoQuestion "Install jack using system software repository?")
544 if test "y" = $ANSWER;
546 echo "Attempting to install Jack"
547 SystemInstall "jackd"
552 read -p "Press ENTER to continue:" BLAH
559 # Check to see if Jack is new enough to operate correctly.
561 if [ "t" = ${JACK_INSTALLED} ];
564 JACK_VER_STRING=$(jackd --version | grep -e "jackd.*protocol")
565 JACK_NAME=$(echo $JACK_VER_STRING | awk '{print $1}')
566 JACK_VERSION=$(echo $JACK_VER_STRING | awk '{print $3}')
567 JACK_VERSION_MAJOR=$(echo $JACK_VERSION | awk 'BEGIN{FS="."}{print $1}')
568 JACK_VERSION_MIDDLE=$(echo $JACK_VERSION | awk 'BEGIN{FS="."}{print $2}')
569 JACK_VERSION_MINOR=$(echo $JACK_VERSION | awk 'BEGIN{FS="."}{print $3}')
571 if [ "jackd" = ${JACK_NAME} ];
573 if [ ${JACK_VERSION_MAJOR} -eq 0 ];
575 if [ ${JACK_VERSION_MIDDLE} -eq 121 ];
577 if [ ${JACK_VERSION_MINOR} -ge 3 ];
581 elif [ ${JACK_VERSION_MIDDLE} -gt 121 ];
585 elif [ ${JACK_VERSION_MAJOR} -gt 0 ];
589 elif [ "jackdmp" = ${JACK_NAME} ];
591 if [ ${JACK_VERSION_MAJOR} -eq 1 ];
593 if [ ${JACK_VERSION_MIDDLE} -eq 9 ];
595 if [ ${JACK_VERSION_MINOR} -ge 8 ];
599 elif [ ${JACK_VERSION_MIDDLE} -gt 9 ];
603 elif [ ${JACK_VERSION_MAJOR} -gt 1 ];
609 if [ "t" = ${JACK_VERSION_OK} ];
612 echo "Jack Version Check OK (${JACK_VER_STRING})"
616 echo "!!! WARNING !!! - The version of Jack on this system is too old!"
617 echo "Using an old version of Jack is not recommended. Please update"
618 echo "Jack for best results."
620 echo "System Jack version:"
621 echo " ${JACK_VER_STRING}"
623 echo "Recommended minimum versions:"
624 echo " Jack1 - 0.121.3"
625 echo " Jack2 - 1.9.8"
627 read -p "Press ENTER to continue:" BLAH
631 if ! which qjackctl > /dev/null;
634 echo "The program QjackCtl is missing from this system."
635 echo "QjackCtl is an extremely useful tool for any system that runs JACK applications like $PGM_NAME."
636 echo "We recommend that you install it."
639 ANSWER=$(VaildateYesNoQuestion "Install QjackCtl using system software repository?")
641 if test "y" = $ANSWER;
643 echo "Attempting to install QjackCtl"
644 SystemInstall "qjackctl"
649 read -p "Press ENTER to continue:" BLAH
655 ########################
657 ########################
659 USER_GROUP_ADJUSTED="f"
661 if ! ${NORM_USER} "${INSTALL_DEST_BASE}/${PGM_FULL_NAME}/bin/sanityCheck -a > /dev/null";
664 echo "System failed the quick sanity check... Looking for the cause"
666 if ! ${NORM_USER} "${INSTALL_DEST_BASE}/${PGM_FULL_NAME}/bin/sanityCheck -rt > /dev/null";
669 echo "System does not allow realtime for the current user... Looking for a solution"
671 if ${NORM_USER} "${INSTALL_DEST_BASE}/${PGM_FULL_NAME}/bin/sanityCheck -hasaudiogroup > /dev/null";
673 if ${NORM_USER} "${INSTALL_DEST_BASE}/${PGM_FULL_NAME}/bin/sanityCheck -memberaudiogroup > /dev/null 2>&1";
675 ## This is an odd case. We have an audio group and are a member.
677 echo "!!! WARNING !!! - The current user can not execute realtime processes."
678 echo "This will adversely affect audio latency."
679 echo "This system has an audio group and the user is a member. If jack was"
680 echo "just installed, a simple log out/in may fix this."
682 echo "For best results, please correct this on your system."
683 echo "(Hint: check /etc/security/limits.conf or /etc/security/limits.d/)"
685 read -p "Press ENTER to continue:" BLAH
687 # Not a member of an audio group. Try to fix it.
689 if ${NORM_USER} "${INSTALL_DEST_BASE}/${PGM_FULL_NAME}/bin/sanityCheck -hasgroup audio > /dev/null && find /etc/security -type f -name "*.conf" | xargs grep -q "^@audio.*rtprio" ";
691 # add user to audio group
693 echo "Adding user ${USER_NAME} to the audio group."
694 echo "This should allow you to run realtime tasks. Please re-login for this change to take affect."
696 read -p "Press ENTER to continue:" BLAH
698 if ${SUPER} usermod -a -G audio ${USER_NAME};
700 USER_GROUP_ADJUSTED="t"
703 echo "!!! ERROR !!! - Not able to add user to the audio group (usermod failed)!"
705 echo "Please add yourself to the audio group and re-login"
707 read -p "Press ENTER to continue:" BLAH
710 elif ${NORM_USER} "${INSTALL_DEST_BASE}/${PGM_FULL_NAME}/bin/sanityCheck -hasgroup jackuser > /dev/null && find /etc/security -type f -name "*.conf" | xargs grep -q "^@jackuser.*rtprio" ";
712 # add user to jackuser group
714 echo "Adding user ${USER_NAME} to the jackuser group."
715 echo "This should allow you to run realtime tasks. Please re-login for this change to take affect."
717 read -p "Press ENTER to continue:" BLAH
719 if ${SUPER} usermod -a -G jackuser ${USER_NAME};
721 USER_GROUP_ADJUSTED="t"
724 echo "!!! ERROR !!! - Not able to add user to the jackuser group."
726 echo "Please add yourself to the audio group and re-login"
728 read -p "Press ENTER to continue:" BLAH
735 # No audio group found on this system!
737 echo "!!! WARNING !!! - The system does not seem to have an audio group (audio or jackuser)."
739 echo "We will not attempt to fix this. Please configure your system to allow"
740 echo "non-root users to execute realtime tasks."
742 read -p "Press ENTER to continue:" BLAH
746 if ! ${NORM_USER} "${INSTALL_DEST_BASE}/${PGM_FULL_NAME}/bin/sanityCheck -freqscaling > /dev/null";
749 echo "!!! WARNING !!! - Your system seems to use frequency scaling."
750 echo "This can have a serious impact on audio latency."
751 echo "For best results turn it off, e.g. by chosing the 'performance' governor."
753 read -p "Press ENTER to continue:" BLAH
756 if [ "f" = $USER_GROUP_ADJUSTED ];
758 if ! ${NORM_USER} "${INSTALL_DEST_BASE}/${PGM_FULL_NAME}/bin/sanityCheck -memlock > /dev/null";
761 echo "!!! WARNING !!! - You are not allowed to lock memory."
763 echo "We will not attempt to fix this. Please configure your system to allow"
764 echo "non-root users to execute lock memory."
766 read -p "Press ENTER to continue:" BLAH
772 ########################
774 ########################
778 rm -rf ${BUNDLE_DIR}/
781 echo "!!! Install Complete !!!"
783 if [ "t" = $USER_GROUP_ADJUSTED ];
785 echo "You will need to logout and then login again for all changes to be complete"
789 read -p "Press ENTER to exit installer:" BLAH