3 ####################################
6 # Ardour/Mixbus bundle installer
9 ###################################
15 PGM_EXEC_FILE="ardour3"
17 INSTALL_DEST_BASE="/opt"
19 PGM_NAME_LOWER=$(echo $PGM_NAME | tr '[:upper:]' '[:lower:]')
23 #### Global Variables ####
26 ########################
27 # Function Definitions
28 ########################
30 VaildateYesNoQuestion ()
37 until test "y" = $INPUT_OK;
40 read -p "$1 [y/n]: " USER_INPUT
43 if [ ! -z $USER_INPUT ];
45 if [ "Y" = $USER_INPUT -o "y" = $USER_INPUT -o "n" = $USER_INPUT -o "N" = $USER_INPUT ];
52 echo $USER_INPUT | tr '[:upper:]' '[:lower:]'
59 # Determine which software install app to use and then install requested package
62 if which yum > /dev/null;
64 ${SUPER} yum -y install $1
70 echo "!!! ERROR !!! yum install failed for an unknown reason."
71 echo "Please install package $1 after this installer completes."
75 elif which apt-get > /dev/null;
77 ${SUPER} apt-get -y install $1
83 echo "!!! ERROR !!! apt-get install failed for an unknown reason."
84 echo "Please install package $1 after this installer completes."
90 echo "!!! ERROR !!! - Not able to detect which software install tool to use (yum or apt-get)."
91 echo "Please install package $1 using the system software install tool."
100 ########################################################################
102 ########################################################################
104 # If you double click a script, some systems don't get the PWD correct.
105 # Force it to be correct
106 PKG_PATH=$(dirname "$(readlink -f "$0")")
110 echo "Welcome to the ${PGM_NAME} installer"
112 echo "${PGM_NAME} will be installed for user ${USER_NAME} in ${INSTALL_DEST_BASE}"
115 ###############################
116 # Check for install destination
117 ###############################
119 if [ ! -d ${INSTALL_DEST_BASE} ];
122 echo "!!! ERROR !!! - Installation location ${INSTALL_DEST_BASE} does not exist!"
123 echo "Installation will not complete."
125 read -p "Press ENTER to exit installer:" BLAH
129 #############################
130 # Check for root privileges
131 #############################
136 if [ "$(id -u)" != "0" ]; then
138 if ! which sudo > /dev/null;
143 echo "This installer requires root privileges. It is currently not"
144 echo "running as root AND the program sudo is missing from this system."
146 echo "Please correct this by installing and configuring sudo or running"
147 echo "the installer as root (su -c)."
149 read -p "Press ENTER to exit installer:" BLAH
158 echo "This installer requires root privileges. It is currently not"
159 echo "running as root AND an attempt to use sudo failed."
161 echo "Please correct this by installing and configuring sudo or running"
162 echo "the installer as root (su -c)."
164 read -p "Press ENTER to exit installer:" BLAH
169 # The quoting reqired for the su sanityCheck method does not work when used without
170 # su. Using sh -c in the normal case gets around that, but is a bit of a hack.
173 NORM_USER="su -l $USER_NAME -c"
176 ############################
177 # Determine processor type
178 ############################
181 i[3456789]86|x86|i86pc)
182 echo "Architecture is x86"
186 echo "Architecture is x86_64"
191 echo "!!! ERROR !!! - Unknown architecture `uname -m`"
193 read -p "Press ENTER to exit installer:" BLAH
202 # We have to check the current folder and the INSTALL_DEST_BASE just
203 # in case they are on different devices
204 echo "Checking for required disk space"
206 if [ ! -e .${PGM_NAME}_${ARCH}-*.size ]; then
208 echo "!!! ERROR !!! Can't locate .size file for ${ARCH} bundle."
209 echo "This package is broken or does not support ${ARCH}."
211 read -p "Press ENTER to exit installer:" BLAH
214 REQUIRED_BYTES=$(cat .${PGM_NAME}_${ARCH}-*.size)
216 #Installer needs 2x the space since the bundle is unpacked locally and then copied
217 REQUIRED_BYTES=$(($REQUIRED_BYTES + $REQUIRED_BYTES))
219 #Check space in current folder
220 FREE_BYTES=$(df -P -B 1 "${PKG_PATH}" | grep / | awk '{print $4}')
222 if [ ${FREE_BYTES} -le ${REQUIRED_BYTES} ] ; then
224 echo "!!! ERROR !!! - Insufficient disk space in ${PKG_PATH}"
225 echo "Install requires ${REQUIRED_BYTES} bytes and
226 echo "there is only ${FREE_BYTES} bytes of free space"
228 read -p "Press ENTER to exit installer:" BLAH
232 #Check space in INSTALL_DEST_BASE
233 FREE_BYTES=$(df -P -B 1 ${INSTALL_DEST_BASE} | grep / | awk '{print $4}')
235 if [ ${FREE_BYTES} -le ${REQUIRED_BYTES} ] ; then
237 echo "!!! ERROR !!! - Insufficient disk space in ${INSTALL_DEST_BASE}"
238 echo "Install requires ${REQUIRED_BYTES} bytes and
239 echo "there is only ${FREE_BYTES} bytes of free space"
241 read -p "Press ENTER to exit installer:" BLAH
246 #####################
248 #####################
250 # untar the correct bundle for us to install
251 echo "Unpacking bundle for $ARCH"
253 if [ ! -e ${PGM_NAME}_${ARCH}-*.tar.bz2 ]; then
255 echo "!!! ERROR !!! Can't locate ${ARCH} bundle file."
257 read -p "Press ENTER to exit installer:" BLAH
261 tar -xjf ${PGM_NAME}_${ARCH}-*.tar.bz2
262 BUNDLE_DIR=$(basename `find -maxdepth 1 -type d -name "${PGM_NAME}_${ARCH}-*"`)
265 #######################
266 # Check for xdg utils
267 #######################
269 #load the file that contains the translated names of the users directories
270 if [ -e /home/${USER_NAME}/.config/user-dirs.dirs ]; then
271 . /home/${USER_NAME}/.config/user-dirs.dirs
274 if [ "$(id -u)" != "0" ]; then
275 USER_DESKTOP_DIR=${XDG_DESKTOP_DIR:-$HOME/Desktop}
277 #running as root with su makes this more difficult
278 DESKTOP_FOLDER=$(echo ${XDG_DESKTOP_DIR:-$HOME/Desktop} | awk -F/ '{print $NF}')
279 USER_DESKTOP_DIR="/home/${USER_NAME}/${DESKTOP_FOLDER}"
282 XDG_MENU_VER=$(xdg-desktop-menu --version 2> /dev/null)
283 if [ -z "$XDG_MENU_VER" ];
285 echo "System does not have xdg-desktop-menu installed"
289 XDG_ICON_VER=$(xdg-icon-resource --version 2> /dev/null)
290 if [ -z "$XDG_ICON_VER" ];
292 echo "System does not have xdg-icon-resource installed"
296 #################################################
297 # Check if system libs are OK (libc, etc)
298 #################################################
301 echo "Checking system libs to see if they are compatible with ${PGM_NAME}."
305 LD_PATH=`pwd`/${BUNDLE_DIR}/lib
308 LDD_RESULT=$(LD_LIBRARY_PATH=${LD_PATH} ldd ${BUNDLE_DIR}/bin/${PGM_NAME_LOWER}-* 2>&1 > /dev/null)
310 if [ -n "$LDD_RESULT" ];
317 LIB_FILES=$(find ${BUNDLE_DIR}/lib -name "*.so")
319 for path in $LIB_FILES
321 LDD_RESULT=$(LD_LIBRARY_PATH=${LD_PATH} ldd $path 2>&1 > /dev/null)
322 if [ -n "$LDD_RESULT" ];
329 if test "T" = $LIB_ERROR;
332 echo "!!! ERROR !!! - Missing library detected!"
333 echo "This system does not have the correct libs to run ${PGM_NAME}."
334 echo "Installation will not complete. Please use a compatible distro."
336 read -p "Press ENTER to exit installer:" BLAH
340 ################################
341 # Setup derived variables
342 ################################
343 PGM_VERSION=$(echo ${BUNDLE_DIR} | awk 'BEGIN { FS = "-" } ; { print $2 }' | awk 'BEGIN { FS = "_"} ; { print $1}')
344 PGM_BUILD=$(echo ${BUNDLE_DIR} | awk 'BEGIN { FS = "-" } ; { print $2 }' | awk 'BEGIN { FS = "_"} ; { print $2}')
345 PGM_BUILDTYPE=$(echo ${BUNDLE_DIR} | awk 'BEGIN { FS = "-" } ; { print $3 }')
347 if [ -z ${PGM_BUILDTYPE} ];
349 PGM_FULL_NAME="${PGM_NAME}-${PGM_VERSION}_${PGM_BUILD}"
350 ICON_NAME="${PGM_VENDOR}-${PGM_NAME}_${PGM_VERSION}" #no dash between name and version since dash seperates vendor from program
351 MENU_FILE="${PGM_VENDOR}-${PGM_NAME}_${PGM_VERSION}.desktop" #no dash between name and version since dash seperates vendor from program
352 DESKTOP_LINK_FILE="${PGM_NAME}_${PGM_VERSION}.desktop"
354 PGM_FULL_NAME="${PGM_NAME}-${PGM_VERSION}_${PGM_BUILD}-${PGM_BUILDTYPE}"
355 ICON_NAME="${PGM_VENDOR}-${PGM_NAME}_${PGM_VERSION}_${PGM_BUILDTYPE}" #no dash between name and version since dash seperates vendor from program
356 MENU_FILE="${PGM_VENDOR}-${PGM_NAME}_${PGM_VERSION}_${PGM_BUILDTYPE}.desktop" #no dash between name and version since dash seperates vendor from program
357 DESKTOP_LINK_FILE="${PGM_NAME}_${PGM_VERSION}_${PGM_BUILDTYPE}.desktop"
360 PGM_EXEC_PATH="${INSTALL_DEST_BASE}/${PGM_FULL_NAME}/bin/${PGM_EXEC_FILE}"
361 ICON_PATH="${INSTALL_DEST_BASE}/${PGM_FULL_NAME}/etc/icons"
362 MENU_FILE_PATH="${INSTALL_DEST_BASE}/${PGM_FULL_NAME}/share"
364 ################################
365 # Install bundle and Menu/Link
366 ################################
368 # uninstall any older versions
369 UNINSTALLERS=$(find ${INSTALL_DEST_BASE} -maxdepth 1 -type f -name "${PGM_NAME}*.uninstall.sh")
370 if [ ! -z "$UNINSTALLERS" ];
372 for i in $UNINSTALLERS; do
374 echo "Found existing ${PGM_NAME} installation."
376 ANSWER=$(VaildateYesNoQuestion "Do you want to run the uninstaller ${i} ?")
378 if test "y" = $ANSWER;
381 echo "Running uninstaller $i"
393 echo "Installing ${PGM_NAME} ${PGM_VERSION} built from ${PGM_BUILD} in ${INSTALL_DEST_BASE}"
396 # Copy the new version in the install directory
397 ${SUPER} mkdir ${INSTALL_DEST_BASE}/${PGM_FULL_NAME}
398 ${SUPER} cp -Rf ${BUNDLE_DIR}/* ${INSTALL_DEST_BASE}/${PGM_FULL_NAME}/
400 # write the desktop/menu file
401 echo "[Desktop Entry]" > /tmp/${MENU_FILE}
402 echo "Encoding=UTF-8" >> /tmp/${MENU_FILE}
403 echo "Version=1.0" >> /tmp/${MENU_FILE}
404 echo "Type=Application" >> /tmp/${MENU_FILE}
405 echo "Terminal=false" >> /tmp/${MENU_FILE}
406 echo "Exec=${PGM_EXEC_PATH}" >> /tmp/${MENU_FILE}
407 if [ -z ${PGM_BUILDTYPE} ];
409 echo "Name=${PGM_NAME}-${PGM_VERSION}" >> /tmp/${MENU_FILE}
411 echo "Name=${PGM_NAME}-${PGM_VERSION}-${PGM_BUILDTYPE}" >> /tmp/${MENU_FILE}
413 echo "Icon=${ICON_NAME}" >> /tmp/${MENU_FILE}
414 echo "Comment=Digital Audio Workstation" >> /tmp/${MENU_FILE}
415 echo "Categories=AudioVideo;AudioEditing;Audio;Recorder;" >> /tmp/${MENU_FILE}
417 chmod ugo+rx /tmp/${MENU_FILE}
418 ${SUPER} mv /tmp/${MENU_FILE} ${MENU_FILE_PATH}/.
420 # install the Menu, Link, and Icon(s)
421 if [ "T" = ${HAS_XDG} ];
423 echo "Adding ${PGM_NAME} to the applications menu"
424 ${SUPER} xdg-icon-resource install --context apps --size 16 ${ICON_PATH}/${PGM_NAME_LOWER}_icon_16px.png ${ICON_NAME}
425 ${SUPER} xdg-icon-resource install --context apps --size 22 ${ICON_PATH}/${PGM_NAME_LOWER}_icon_22px.png ${ICON_NAME}
426 ${SUPER} xdg-icon-resource install --context apps --size 32 ${ICON_PATH}/${PGM_NAME_LOWER}_icon_32px.png ${ICON_NAME}
427 ${SUPER} xdg-icon-resource install --context apps --size 48 ${ICON_PATH}/${PGM_NAME_LOWER}_icon_48px.png ${ICON_NAME}
429 if [ -e ${ICON_PATH}/${PGM_NAME_LOWER}_icon.svg -a -d /usr/share/icons/hicolor/scalable/apps ];
431 ${SUPER} cp -f ${ICON_PATH}/${PGM_NAME_LOWER}_icon.svg /usr/share/icons/hicolor/scalable/apps/${ICON_NAME}.svg
434 ${SUPER} xdg-desktop-menu install ${MENU_FILE_PATH}/${MENU_FILE}
435 ${SUPER} xdg-desktop-menu forceupdate --mode system # Some systems need an extra kick
438 echo "Creating a desktop link for ${PGM_NAME} in ${USER_DESKTOP_DIR}"
439 cp ${MENU_FILE_PATH}/${MENU_FILE} ${USER_DESKTOP_DIR}/${DESKTOP_LINK_FILE}
440 chmod ugo+rwx ${USER_DESKTOP_DIR}/${DESKTOP_LINK_FILE}
443 echo "Creating a desktop link for ${PGM_NAME} in ${USER_DESKTOP_DIR}"
444 cp ${MENU_FILE_PATH}/${MENU_FILE} ${USER_DESKTOP_DIR}/${DESKTOP_LINK_FILE}
445 chmod ugo+rwx ${USER_DESKTOP_DIR}/${DESKTOP_LINK_FILE}
449 echo "Copying uninstall script to ${INSTALL_DEST_BASE}"
452 ${SUPER} cp -f ${BUNDLE_DIR}/bin/*.uninstall.sh ${INSTALL_DEST_BASE}/.
454 ###########################
455 # Check Jack and qjackctl
456 ###########################
459 echo "Checking to see if Jack is installed"
462 if ! which jackd > /dev/null;
465 echo "The program Jack is missing from this system. Jack is a required component of $PGM_NAME."
468 ANSWER=$(VaildateYesNoQuestion "Install jack using system software repository?")
470 if test "y" = $ANSWER;
472 echo "Attempting to install Jack"
473 SystemInstall "jackd"
478 read -p "Press ENTER to continue:" BLAH
486 if ! which qjackctl > /dev/null;
489 echo "The program QjackCtl is missing from this system."
490 echo "QjackCtl is an extremely useful tool for any system that runs JACK applications like $PGM_NAME."
491 echo "We recommend that you install it."
494 ANSWER=$(VaildateYesNoQuestion "Install QjackCtl using system software repository?")
496 if test "y" = $ANSWER;
498 echo "Attempting to install QjackCtl"
499 SystemInstall "qjackctl"
504 read -p "Press ENTER to continue:" BLAH
510 ########################
512 ########################
514 USER_GROUP_ADJUSTED="f"
516 if ! ${NORM_USER} "${INSTALL_DEST_BASE}/${PGM_FULL_NAME}/bin/sanityCheck -a > /dev/null";
519 echo "System failed the quick sanity check... Looking for the cause"
521 if ! ${NORM_USER} "${INSTALL_DEST_BASE}/${PGM_FULL_NAME}/bin/sanityCheck -rt > /dev/null";
524 echo "System does not allow realtime for the current user... Looking for a solution"
526 if ${NORM_USER} "${INSTALL_DEST_BASE}/${PGM_FULL_NAME}/bin/sanityCheck -hasaudiogroup > /dev/null";
528 if ${NORM_USER} "${INSTALL_DEST_BASE}/${PGM_FULL_NAME}/bin/sanityCheck -memberaudiogroup > /dev/null 2>&1";
530 ## This is an odd case. We have an audio group and are a member.
532 echo "!!! WARNING !!! - The current user can not execute realtime processes."
533 echo "This will adversely affect audio latency."
534 echo "This system has an audio group and the user is a member. If jack was"
535 echo "just installed, a simple log out/in may fix this."
537 echo "For best results, please correct this on your system."
538 echo "(Hint: check /etc/security/limits.conf or /etc/security/limits.d/)"
540 read -p "Press ENTER to continue:" BLAH
542 # Not a member of an audio group. Try to fix it.
544 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" ";
546 # add user to audio group
548 echo "Adding user ${USER_NAME} to the audio group."
549 echo "This should allow you to run realtime tasks. Please re-login for this change to take affect."
551 read -p "Press ENTER to continue:" BLAH
553 if ${SUPER} usermod -a -G audio ${USER_NAME};
555 USER_GROUP_ADJUSTED="t"
558 echo "!!! ERROR !!! - Not able to add user to the audio group (usermod failed)!"
560 echo "Please add yourself to the audio group and re-login"
562 read -p "Press ENTER to continue:" BLAH
565 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" ";
567 # add user to jackuser group
569 echo "Adding user ${USER_NAME} to the jackuser group."
570 echo "This should allow you to run realtime tasks. Please re-login for this change to take affect."
572 read -p "Press ENTER to continue:" BLAH
574 if ${SUPER} usermod -a -G jackuser ${USER_NAME};
576 USER_GROUP_ADJUSTED="t"
579 echo "!!! ERROR !!! - Not able to add user to the jackuser group."
581 echo "Please add yourself to the audio group and re-login"
583 read -p "Press ENTER to continue:" BLAH
590 # No audio group found on this system!
592 echo "!!! WARNING !!! - The system does not seem to have an audio group (audio or jackuser)."
594 echo "We will not attempt to fix this. Please configure your system to allow"
595 echo "non-root users to execute realtime tasks."
597 read -p "Press ENTER to continue:" BLAH
601 if ! ${NORM_USER} "${INSTALL_DEST_BASE}/${PGM_FULL_NAME}/bin/sanityCheck -freqscaling > /dev/null";
604 echo "!!! WARNING !!! - Your system seems to use frequency scaling."
605 echo "This can have a serious impact on audio latency. You have two choices:"
606 echo "(1) turn it off, e.g. by chosing the 'performance' governor."
607 echo "(2) Use the HPET clocksource by passing \"-c h\" to JACK"
608 echo "(this second option only works on relatively recent computers)"
610 read -p "Press ENTER to continue:" BLAH
613 if [ "f" = $USER_GROUP_ADJUSTED ];
615 if ! ${NORM_USER} "${INSTALL_DEST_BASE}/${PGM_FULL_NAME}/bin/sanityCheck -memlock > /dev/null";
618 echo "!!! WARNING !!! - You are not allowed to lock memory."
620 echo "We will not attempt to fix this. Please configure your system to allow"
621 echo "non-root users to execute lock memory."
623 read -p "Press ENTER to continue:" BLAH
629 ########################
631 ########################
635 rm -rf ${BUNDLE_DIR}/
638 echo "!!! Install Complete !!!"
640 if [ "t" = $USER_GROUP_ADJUSTED ];
642 echo "You will need to logout and then login again for all changes to be complete"
646 read -p "Press ENTER to exit installer:" BLAH