3 ####################################
6 # Ardour/Mixbus bundle installer
9 ###################################
15 PGM_EXEC_FILE="ardour3"
17 INSTALL_DEST_BASE="/opt"
18 USER_BIN_DIR="/usr/local/bin"
20 PGM_NAME_LOWER=$(echo $PGM_NAME | tr '[:upper:]' '[:lower:]')
24 #### Global Variables ####
27 ########################
28 # Function Definitions
29 ########################
31 VaildateYesNoQuestion ()
38 until test "y" = $INPUT_OK;
41 read -p "$1 [y/n]: " USER_INPUT
44 if [ ! -z $USER_INPUT ];
46 if [ "Y" = $USER_INPUT -o "y" = $USER_INPUT -o "n" = $USER_INPUT -o "N" = $USER_INPUT ];
53 echo $USER_INPUT | tr '[:upper:]' '[:lower:]'
60 # Determine which software install app to use and then install requested package
63 if which yum > /dev/null;
65 ${SUPER} yum -y install $1
71 echo "!!! ERROR !!! yum install failed for an unknown reason."
72 echo "Please install package $1 after this installer completes."
76 elif which apt-get > /dev/null;
78 ${SUPER} apt-get -y install $1
84 echo "!!! ERROR !!! apt-get install failed for an unknown reason."
85 echo "Please install package $1 after this installer completes."
91 echo "!!! ERROR !!! - Not able to detect which software install tool to use (yum or apt-get)."
92 echo "Please install package $1 using the system software install tool."
101 ########################################################################
103 ########################################################################
105 # If you double click a script, some systems don't get the PWD correct.
106 # Force it to be correct
107 PKG_PATH=$(dirname "$(readlink -f "$0")")
111 echo "Welcome to the ${PGM_NAME} installer"
113 echo "${PGM_NAME} will be installed for user ${USER_NAME} in ${INSTALL_DEST_BASE}"
116 ###############################
117 # Check for install destination
118 ###############################
120 if [ ! -d ${INSTALL_DEST_BASE} ];
123 echo "!!! ERROR !!! - Installation location ${INSTALL_DEST_BASE} does not exist!"
124 echo "Installation will not complete."
126 read -p "Press ENTER to exit installer:" BLAH
130 #############################
131 # Check for root privileges
132 #############################
137 if [ "$(id -u)" != "0" ]; then
139 if ! which sudo > /dev/null;
142 echo "Sudo installed failed, attempting to install using su"
143 echo "Please enter root password below"
146 if ! su -c "./.stage2.run";
151 echo "This installer requires root privileges. It is currently not"
152 echo "running as root AND an attempt to use su failed."
154 echo "Please correct this by installing and configuring sudo or running"
155 echo "the installer as root (su -c)."
157 read -p "Press ENTER to exit installer:" BLAH
166 echo "Attempting to install using su"
167 echo "Please enter root password below"
170 if ! su -c "./.stage2.run";
175 echo "This installer requires root privileges. It is currently not"
176 echo "running as root AND an attempt to use both sudo and su failed."
178 echo "Please correct this by installing and configuring sudo or running"
179 echo "the installer as root (su -c)."
181 read -p "Press ENTER to exit installer:" BLAH
188 # The quoting reqired for the su sanityCheck method does not work when used without
189 # su. Using sh -c in the normal case gets around that, but is a bit of a hack.
192 NORM_USER="su -l $USER_NAME -c"
195 ############################
196 # Determine processor type
197 ############################
200 i[3456789]86|x86|i86pc)
201 echo "Architecture is x86"
205 echo "Architecture is x86_64"
210 echo "!!! ERROR !!! - Unknown architecture `uname -m`"
212 read -p "Press ENTER to exit installer:" BLAH
221 # We have to check the current folder and the INSTALL_DEST_BASE just
222 # in case they are on different devices
223 echo "Checking for required disk space"
225 if [ ! -e .${PGM_NAME}_${ARCH}-*.size ]; then
227 echo "!!! ERROR !!! Can't locate .size file for ${ARCH} bundle."
228 echo "This package is broken or does not support ${ARCH}."
230 read -p "Press ENTER to exit installer:" BLAH
233 REQUIRED_BYTES=$(cat .${PGM_NAME}_${ARCH}-*.size)
235 #Installer needs 2x the space since the bundle is unpacked locally and then copied
236 REQUIRED_BYTES=$(($REQUIRED_BYTES + $REQUIRED_BYTES))
238 #Check space in current folder
239 FREE_BYTES=$(df -P -B 1 "${PKG_PATH}" | grep / | awk '{print $4}')
241 if [ ${FREE_BYTES} -le ${REQUIRED_BYTES} ] ; then
243 echo "!!! ERROR !!! - Insufficient disk space in ${PKG_PATH}"
244 echo "Install requires ${REQUIRED_BYTES} bytes and"
245 echo "there is only ${FREE_BYTES} bytes of free space"
247 read -p "Press ENTER to exit installer:" BLAH
251 #Check space in INSTALL_DEST_BASE
252 FREE_BYTES=$(df -P -B 1 ${INSTALL_DEST_BASE} | grep / | awk '{print $4}')
254 if [ ${FREE_BYTES} -le ${REQUIRED_BYTES} ] ; then
256 echo "!!! ERROR !!! - Insufficient disk space in ${INSTALL_DEST_BASE}"
257 echo "Install requires ${REQUIRED_BYTES} bytes and"
258 echo "there is only ${FREE_BYTES} bytes of free space"
260 read -p "Press ENTER to exit installer:" BLAH
265 #####################
267 #####################
269 # untar the correct bundle for us to install
270 echo "Unpacking bundle for $ARCH"
272 if [ ! -e ${PGM_NAME}_${ARCH}-*.tar.bz2 ]; then
274 echo "!!! ERROR !!! Can't locate ${ARCH} bundle file."
276 read -p "Press ENTER to exit installer:" BLAH
280 tar -xjf ${PGM_NAME}_${ARCH}-*.tar.bz2
281 BUNDLE_DIR=$(basename `find -maxdepth 1 -type d -name "${PGM_NAME}_${ARCH}-*"`)
284 #######################
285 # Check for xdg utils
286 #######################
288 #load the file that contains the translated names of the users directories
289 if [ -e /home/${USER_NAME}/.config/user-dirs.dirs ]; then
290 . /home/${USER_NAME}/.config/user-dirs.dirs
293 if [ "$(id -u)" != "0" ]; then
294 USER_DESKTOP_DIR=${XDG_DESKTOP_DIR:-$HOME/Desktop}
296 #running as root with su makes this more difficult
297 DESKTOP_FOLDER=$(echo ${XDG_DESKTOP_DIR:-$HOME/Desktop} | awk -F/ '{print $NF}')
298 USER_DESKTOP_DIR="/home/${USER_NAME}/${DESKTOP_FOLDER}"
301 XDG_MENU_VER=$(xdg-desktop-menu --version 2> /dev/null)
302 if [ -z "$XDG_MENU_VER" ];
304 echo "System does not have xdg-desktop-menu installed"
308 XDG_ICON_VER=$(xdg-icon-resource --version 2> /dev/null)
309 if [ -z "$XDG_ICON_VER" ];
311 echo "System does not have xdg-icon-resource installed"
315 #################################################
316 # Check if system libs are OK (libc, etc)
317 #################################################
320 echo "Checking system libs to see if they are compatible with ${PGM_NAME}."
324 LD_PATH=`pwd`/${BUNDLE_DIR}/lib
327 LDD_RESULT=$(LD_LIBRARY_PATH=${LD_PATH} ldd ${BUNDLE_DIR}/bin/${PGM_NAME_LOWER}-* 2>&1 > /dev/null)
329 if [ -n "$LDD_RESULT" ];
336 LIB_FILES=$(find ${BUNDLE_DIR}/lib -name "*.so")
338 for path in $LIB_FILES
340 LDD_RESULT=$(LD_LIBRARY_PATH=${LD_PATH} ldd $path 2>&1 > /dev/null)
341 if [ -n "$LDD_RESULT" ];
348 if test "T" = $LIB_ERROR;
351 echo "!!! ERROR !!! - Missing library detected!"
352 echo "This system does not have the correct libs to run ${PGM_NAME}."
353 echo "Installation will not complete. Please use a compatible distro."
355 read -p "Press ENTER to exit installer:" BLAH
359 ################################
360 # Setup derived variables
361 ################################
362 PGM_VERSION=$(echo ${BUNDLE_DIR} | awk 'BEGIN { FS = "-" } ; { print $2 }' | awk 'BEGIN { FS = "_"} ; { print $1}')
363 PGM_BUILD=$(echo ${BUNDLE_DIR} | awk 'BEGIN { FS = "-" } ; { print $2 }' | awk 'BEGIN { FS = "_"} ; { print $2}')
364 PGM_BUILDTYPE=$(echo ${BUNDLE_DIR} | awk 'BEGIN { FS = "-" } ; { print $3 }')
366 if [ -z ${PGM_BUILDTYPE} ];
368 PGM_FULL_NAME="${PGM_NAME}-${PGM_VERSION}_${PGM_BUILD}"
369 ICON_NAME="${PGM_VENDOR}-${PGM_NAME}_${PGM_VERSION}" #no dash between name and version since dash seperates vendor from program
370 MENU_FILE="${PGM_VENDOR}-${PGM_NAME}_${PGM_VERSION}.desktop" #no dash between name and version since dash seperates vendor from program
371 DESKTOP_LINK_FILE="${PGM_NAME}_${PGM_VERSION}.desktop"
373 PGM_FULL_NAME="${PGM_NAME}-${PGM_VERSION}_${PGM_BUILD}-${PGM_BUILDTYPE}"
374 ICON_NAME="${PGM_VENDOR}-${PGM_NAME}_${PGM_VERSION}_${PGM_BUILDTYPE}" #no dash between name and version since dash seperates vendor from program
375 MENU_FILE="${PGM_VENDOR}-${PGM_NAME}_${PGM_VERSION}_${PGM_BUILDTYPE}.desktop" #no dash between name and version since dash seperates vendor from program
376 DESKTOP_LINK_FILE="${PGM_NAME}_${PGM_VERSION}_${PGM_BUILDTYPE}.desktop"
379 PGM_EXEC_PATH="${INSTALL_DEST_BASE}/${PGM_FULL_NAME}/bin/${PGM_EXEC_FILE}"
380 ICON_PATH="${INSTALL_DEST_BASE}/${PGM_FULL_NAME}/etc/icons"
381 MENU_FILE_PATH="${INSTALL_DEST_BASE}/${PGM_FULL_NAME}/share"
383 ################################
384 # Install bundle and Menu/Link
385 ################################
387 # uninstall any older versions
388 UNINSTALLERS=$(find ${INSTALL_DEST_BASE} -maxdepth 1 -type f -name "${PGM_NAME}*.uninstall.sh")
389 if [ ! -z "$UNINSTALLERS" ];
391 for i in $UNINSTALLERS; do
393 echo "Found existing ${PGM_NAME} installation."
395 ANSWER=$(VaildateYesNoQuestion "Do you want to run the uninstaller ${i} ?")
397 if test "y" = $ANSWER;
400 echo "Running uninstaller $i"
412 echo "Installing ${PGM_NAME} ${PGM_VERSION} built from ${PGM_BUILD} in ${INSTALL_DEST_BASE}"
415 # Copy the new version in the install directory
416 ${SUPER} mkdir ${INSTALL_DEST_BASE}/${PGM_FULL_NAME}
417 ${SUPER} cp -Rf ${BUNDLE_DIR}/* ${INSTALL_DEST_BASE}/${PGM_FULL_NAME}/
419 # write the desktop/menu file
420 echo "[Desktop Entry]" > /tmp/${MENU_FILE}
421 echo "Encoding=UTF-8" >> /tmp/${MENU_FILE}
422 echo "Version=1.0" >> /tmp/${MENU_FILE}
423 echo "Type=Application" >> /tmp/${MENU_FILE}
424 echo "Terminal=false" >> /tmp/${MENU_FILE}
425 echo "Exec=${PGM_EXEC_PATH}" >> /tmp/${MENU_FILE}
426 if [ -z ${PGM_BUILDTYPE} ];
428 echo "Name=${PGM_NAME}-${PGM_VERSION}" >> /tmp/${MENU_FILE}
430 echo "Name=${PGM_NAME}-${PGM_VERSION}-${PGM_BUILDTYPE}" >> /tmp/${MENU_FILE}
432 echo "Icon=${ICON_NAME}" >> /tmp/${MENU_FILE}
433 echo "Comment=Digital Audio Workstation" >> /tmp/${MENU_FILE}
434 echo "Categories=AudioVideo;AudioEditing;Audio;Recorder;" >> /tmp/${MENU_FILE}
436 chmod ugo+rx /tmp/${MENU_FILE}
437 ${SUPER} mv /tmp/${MENU_FILE} ${MENU_FILE_PATH}/.
439 # install the Menu, Link, and Icon(s)
440 if [ "T" = ${HAS_XDG} ];
442 echo "Adding ${PGM_NAME} to the applications menu"
443 ${SUPER} xdg-icon-resource install --context apps --size 16 ${ICON_PATH}/${PGM_NAME_LOWER}_icon_16px.png ${ICON_NAME}
444 ${SUPER} xdg-icon-resource install --context apps --size 22 ${ICON_PATH}/${PGM_NAME_LOWER}_icon_22px.png ${ICON_NAME}
445 ${SUPER} xdg-icon-resource install --context apps --size 32 ${ICON_PATH}/${PGM_NAME_LOWER}_icon_32px.png ${ICON_NAME}
446 ${SUPER} xdg-icon-resource install --context apps --size 48 ${ICON_PATH}/${PGM_NAME_LOWER}_icon_48px.png ${ICON_NAME}
448 if [ -e ${ICON_PATH}/${PGM_NAME_LOWER}_icon.svg -a -d /usr/share/icons/hicolor/scalable/apps ];
450 ${SUPER} cp -f ${ICON_PATH}/${PGM_NAME_LOWER}_icon.svg /usr/share/icons/hicolor/scalable/apps/${ICON_NAME}.svg
453 ${SUPER} xdg-desktop-menu install ${MENU_FILE_PATH}/${MENU_FILE}
454 ${SUPER} xdg-desktop-menu forceupdate --mode system # Some systems need an extra kick
457 echo "Creating a desktop link for ${PGM_NAME} in ${USER_DESKTOP_DIR}"
458 cp ${MENU_FILE_PATH}/${MENU_FILE} ${USER_DESKTOP_DIR}/${DESKTOP_LINK_FILE}
459 chmod ugo+rwx ${USER_DESKTOP_DIR}/${DESKTOP_LINK_FILE}
462 echo "Creating a desktop link for ${PGM_NAME} in ${USER_DESKTOP_DIR}"
463 cp ${MENU_FILE_PATH}/${MENU_FILE} ${USER_DESKTOP_DIR}/${DESKTOP_LINK_FILE}
464 chmod ugo+rwx ${USER_DESKTOP_DIR}/${DESKTOP_LINK_FILE}
468 echo "Copying uninstall script to ${INSTALL_DEST_BASE}"
471 ${SUPER} cp -f ${BUNDLE_DIR}/bin/*.uninstall.sh ${INSTALL_DEST_BASE}/.
473 # Create link to the program in user bin
476 echo "Creating link ${PGM_NAME}3 in ${USER_BIN_DIR}"
479 if [ -d "${USER_BIN_DIR}" ]; then
480 if [ -e "${USER_BIN_DIR}/${PGM_NAME}3" ]; then
481 ${SUPER} rm -f ${USER_BIN_DIR}/${PGM_NAME}3
485 ${SUPER} ln -sf ${PGM_EXEC_PATH} ${PGM_NAME}3
489 echo "Can not create link because ${USER_BIN_DIR} does not exist"
492 ###########################
493 # Check Jack and qjackctl
494 ###########################
497 echo "Checking to see if Jack is installed"
500 if ! which jackd > /dev/null;
503 echo "The program Jack is missing from this system. Jack is a required component of $PGM_NAME."
506 ANSWER=$(VaildateYesNoQuestion "Install jack using system software repository?")
508 if test "y" = $ANSWER;
510 echo "Attempting to install Jack"
511 SystemInstall "jackd"
516 read -p "Press ENTER to continue:" BLAH
524 if ! which qjackctl > /dev/null;
527 echo "The program QjackCtl is missing from this system."
528 echo "QjackCtl is an extremely useful tool for any system that runs JACK applications like $PGM_NAME."
529 echo "We recommend that you install it."
532 ANSWER=$(VaildateYesNoQuestion "Install QjackCtl using system software repository?")
534 if test "y" = $ANSWER;
536 echo "Attempting to install QjackCtl"
537 SystemInstall "qjackctl"
542 read -p "Press ENTER to continue:" BLAH
548 ########################
550 ########################
552 USER_GROUP_ADJUSTED="f"
554 if ! ${NORM_USER} "${INSTALL_DEST_BASE}/${PGM_FULL_NAME}/bin/sanityCheck -a > /dev/null";
557 echo "System failed the quick sanity check... Looking for the cause"
559 if ! ${NORM_USER} "${INSTALL_DEST_BASE}/${PGM_FULL_NAME}/bin/sanityCheck -rt > /dev/null";
562 echo "System does not allow realtime for the current user... Looking for a solution"
564 if ${NORM_USER} "${INSTALL_DEST_BASE}/${PGM_FULL_NAME}/bin/sanityCheck -hasaudiogroup > /dev/null";
566 if ${NORM_USER} "${INSTALL_DEST_BASE}/${PGM_FULL_NAME}/bin/sanityCheck -memberaudiogroup > /dev/null 2>&1";
568 ## This is an odd case. We have an audio group and are a member.
570 echo "!!! WARNING !!! - The current user can not execute realtime processes."
571 echo "This will adversely affect audio latency."
572 echo "This system has an audio group and the user is a member. If jack was"
573 echo "just installed, a simple log out/in may fix this."
575 echo "For best results, please correct this on your system."
576 echo "(Hint: check /etc/security/limits.conf or /etc/security/limits.d/)"
578 read -p "Press ENTER to continue:" BLAH
580 # Not a member of an audio group. Try to fix it.
582 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" ";
584 # add user to audio group
586 echo "Adding user ${USER_NAME} to the audio group."
587 echo "This should allow you to run realtime tasks. Please re-login for this change to take affect."
589 read -p "Press ENTER to continue:" BLAH
591 if ${SUPER} usermod -a -G audio ${USER_NAME};
593 USER_GROUP_ADJUSTED="t"
596 echo "!!! ERROR !!! - Not able to add user to the audio group (usermod failed)!"
598 echo "Please add yourself to the audio group and re-login"
600 read -p "Press ENTER to continue:" BLAH
603 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" ";
605 # add user to jackuser group
607 echo "Adding user ${USER_NAME} to the jackuser group."
608 echo "This should allow you to run realtime tasks. Please re-login for this change to take affect."
610 read -p "Press ENTER to continue:" BLAH
612 if ${SUPER} usermod -a -G jackuser ${USER_NAME};
614 USER_GROUP_ADJUSTED="t"
617 echo "!!! ERROR !!! - Not able to add user to the jackuser group."
619 echo "Please add yourself to the audio group and re-login"
621 read -p "Press ENTER to continue:" BLAH
628 # No audio group found on this system!
630 echo "!!! WARNING !!! - The system does not seem to have an audio group (audio or jackuser)."
632 echo "We will not attempt to fix this. Please configure your system to allow"
633 echo "non-root users to execute realtime tasks."
635 read -p "Press ENTER to continue:" BLAH
639 if ! ${NORM_USER} "${INSTALL_DEST_BASE}/${PGM_FULL_NAME}/bin/sanityCheck -freqscaling > /dev/null";
642 echo "!!! WARNING !!! - Your system seems to use frequency scaling."
643 echo "This can have a serious impact on audio latency. You have two choices:"
644 echo "(1) turn it off, e.g. by chosing the 'performance' governor."
645 echo "(2) Use the HPET clocksource by passing \"-c h\" to JACK"
646 echo "(this second option only works on relatively recent computers)"
648 read -p "Press ENTER to continue:" BLAH
651 if [ "f" = $USER_GROUP_ADJUSTED ];
653 if ! ${NORM_USER} "${INSTALL_DEST_BASE}/${PGM_FULL_NAME}/bin/sanityCheck -memlock > /dev/null";
656 echo "!!! WARNING !!! - You are not allowed to lock memory."
658 echo "We will not attempt to fix this. Please configure your system to allow"
659 echo "non-root users to execute lock memory."
661 read -p "Press ENTER to continue:" BLAH
667 ########################
669 ########################
673 rm -rf ${BUNDLE_DIR}/
676 echo "!!! Install Complete !!!"
678 if [ "t" = $USER_GROUP_ADJUSTED ];
680 echo "You will need to logout and then login again for all changes to be complete"
684 read -p "Press ENTER to exit installer:" BLAH