Merge branch 'windows' into windows+cc
[ardour.git] / tools / linux_packaging / stage2.run
index 09da78f78b6d8f30245ce6029d8759e37c1ee425..e98810e8208f783dceed6ecf76d9fd4356c86d52 100755 (executable)
@@ -15,9 +15,12 @@ PGM_VENDOR="Ardour"
 PGM_EXEC_FILE="ardour3"
 
 INSTALL_DEST_BASE="/opt"
+USER_BIN_DIR="/usr/local/bin"
 
 PGM_NAME_LOWER=$(echo $PGM_NAME | tr '[:upper:]' '[:lower:]')
 
+USER_NAME=$(logname)
+
 #### Global Variables ####
 HAS_XDG="T"
 
@@ -59,7 +62,7 @@ SystemInstall ()
 
        if which yum > /dev/null;
        then
-               sudo yum -y install $1
+               ${SUPER} yum -y install $1
                rtrn=$?
 
                if [ $rtrn -ne 0 ];
@@ -72,7 +75,7 @@ SystemInstall ()
 
        elif which apt-get > /dev/null;
        then
-               sudo apt-get -y install $1
+               ${SUPER} apt-get -y install $1
                rtrn=$?
 
                if [ $rtrn -ne 0 ];
@@ -99,26 +102,96 @@ SystemInstall ()
 #                                 Main
 ########################################################################
 
+# If you double click a script, some systems don't get the PWD correct.
+# Force it to be correct
+PKG_PATH=$(dirname "$(readlink -f "$0")")
+cd "${PKG_PATH}"
+
 echo ""
 echo "Welcome to the ${PGM_NAME} installer"
 echo ""
+echo "${PGM_NAME} will be installed for user ${USER_NAME} in ${INSTALL_DEST_BASE}"
+echo ""
 
-##############
-# Check sudo
-##############
+###############################
+# Check for install destination
+###############################
 
-if ! sudo date;
+if [ ! -d ${INSTALL_DEST_BASE} ];
 then
        echo ""
-       echo "!!! ERROR !!!"
-       echo ""
-       echo "Either you don't know the root password or the user is not allowed to sudo"
-       echo "Please correct this and run the installer again (hint: use visudo to edit sudoers file)"
+       echo "!!! ERROR !!! - Installation location ${INSTALL_DEST_BASE} does not exist!"
+       echo "Installation will not complete."
        echo ""
        read -p "Press ENTER to exit installer:" BLAH
        exit 1
 fi
 
+#############################
+# Check for root privileges
+#############################
+
+SUPER=""
+NORM_USER=""
+
+if [ "$(id -u)" != "0" ]; then
+
+       if ! which sudo > /dev/null;
+       then
+               echo ""
+               echo "Sudo installed failed, attempting to install using su"
+               echo "Please enter root password below"
+               echo ""
+
+               if ! su -c "./.stage2.run";
+               then
+                       echo ""
+                       echo "!!! ERROR !!!"
+                       echo ""
+                       echo "This installer requires root privileges. It is currently not"
+                       echo "running as root AND an attempt to use su failed."
+                       echo ""
+                       echo "Please correct this by installing and configuring sudo or running"
+                       echo "the installer as root (su -c)."
+                       echo ""
+                       read -p "Press ENTER to exit installer:" BLAH
+                       exit 1
+               fi
+               exit
+       fi
+
+       if ! sudo date;
+       then
+               echo ""
+               echo "Attempting to install using su"
+               echo "Please enter root password below"
+               echo ""
+
+               if ! su -c "./.stage2.run";
+               then
+                       echo ""
+                       echo "!!! ERROR !!!"
+                       echo ""
+                       echo "This installer requires root privileges. It is currently not"
+                       echo "running as root AND an attempt to use both sudo and su failed."
+                       echo ""
+                       echo "Please correct this by installing and configuring sudo or running"
+                       echo "the installer as root (su -c)."
+                       echo ""
+                       read -p "Press ENTER to exit installer:" BLAH
+                       exit 1
+               fi
+               exit
+       fi
+       SUPER="sudo"
+       
+       # The quoting reqired for the su sanityCheck method does not work when used without
+       # su. Using sh -c in the normal case gets around that, but is a bit of a hack.
+       NORM_USER="sh -c"
+else
+       NORM_USER="su -l $USER_NAME -c" 
+fi
+
 ############################
 # Determine processor type
 ############################
@@ -141,9 +214,82 @@ case `uname -m` in
                ;;
 esac
 
+####################
+# Check disk space
+####################
+
+# We have to check the current folder and the INSTALL_DEST_BASE just
+# in case they are on different devices
+echo "Checking for required disk space"
+
+if [ ! -e .${PGM_NAME}_${ARCH}-*.size ]; then
+       echo ""
+       echo "!!! ERROR !!! Can't locate .size file for ${ARCH} bundle."
+       echo "This package is broken or does not support ${ARCH}."
+       echo ""
+       read -p "Press ENTER to exit installer:" BLAH
+       exit 1
+else
+       REQUIRED_BYTES=$(cat .${PGM_NAME}_${ARCH}-*.size)
+
+       #Installer needs 2x the space since the bundle is unpacked locally and then copied
+       REQUIRED_BYTES=$(($REQUIRED_BYTES + $REQUIRED_BYTES))
+
+       #Check space in current folder
+       FREE_BYTES=$(df -P -B 1 "${PKG_PATH}" | grep / | awk '{print $4}')
+
+       if [ ${FREE_BYTES} -le ${REQUIRED_BYTES} ] ; then
+               echo ""
+               echo "!!! ERROR !!! - Insufficient disk space in ${PKG_PATH}"
+               echo "Install requires ${REQUIRED_BYTES} bytes and"
+               echo "there is only ${FREE_BYTES} bytes of free space"
+               echo ""
+               read -p "Press ENTER to exit installer:" BLAH
+               exit 1
+       fi
+
+       #Check space in INSTALL_DEST_BASE
+       FREE_BYTES=$(df -P -B 1 ${INSTALL_DEST_BASE} | grep / | awk '{print $4}')
+
+       if [ ${FREE_BYTES} -le ${REQUIRED_BYTES} ] ; then
+               echo ""
+               echo "!!! ERROR !!! - Insufficient disk space in ${INSTALL_DEST_BASE}"
+               echo "Install requires ${REQUIRED_BYTES} bytes and"
+               echo "there is only ${FREE_BYTES} bytes of free space"
+               echo ""
+               read -p "Press ENTER to exit installer:" BLAH
+               exit 1
+       fi
+fi
+
+FILESYSTEM_TYPE=$(df -P -T "${PKG_PATH}" | grep / | awk '{print $2}')
+echo "Bundle is on ${FILESYSTEM_TYPE} filesystem"
+
+#####################
+# Unpack the bundle
+#####################
+
 # untar the correct bundle for us to install
 echo "Unpacking bundle for $ARCH"
-tar -xjf ${PGM_NAME}_${ARCH}-*.tar.bz2
+
+if [ ! -e ${PGM_NAME}_${ARCH}-*.tar.bz2 ]; then
+       echo ""
+       echo "!!! ERROR !!! Can't locate ${ARCH} bundle file."
+       echo ""
+       read -p "Press ENTER to exit installer:" BLAH
+       exit 1
+fi
+
+if ! tar -xjf ${PGM_NAME}_${ARCH}-*.tar.bz2; then
+       echo ""
+       echo "!!! ERROR !!! Can't unpack ${ARCH} bundle file."
+       echo ""
+       read -p "Press ENTER to exit installer:" BLAH
+       exit 1
+else
+       echo "Bundle unpacked"
+fi
+
 BUNDLE_DIR=$(basename `find -maxdepth 1 -type d -name "${PGM_NAME}_${ARCH}-*"`)
 
 
@@ -151,6 +297,19 @@ BUNDLE_DIR=$(basename `find -maxdepth 1 -type d -name "${PGM_NAME}_${ARCH}-*"`)
 # Check for xdg utils
 #######################
 
+#load the file that contains the translated names of the users directories
+if [ -e /home/${USER_NAME}/.config/user-dirs.dirs ]; then
+       . /home/${USER_NAME}/.config/user-dirs.dirs
+fi
+
+if [ "$(id -u)" != "0" ]; then
+       USER_DESKTOP_DIR=${XDG_DESKTOP_DIR:-$HOME/Desktop}
+else
+       #running as root with su makes this more difficult
+       DESKTOP_FOLDER=$(echo ${XDG_DESKTOP_DIR:-$HOME/Desktop} | awk -F/ '{print $NF}')
+       USER_DESKTOP_DIR="/home/${USER_NAME}/${DESKTOP_FOLDER}"
+fi
+
 XDG_MENU_VER=$(xdg-desktop-menu --version 2> /dev/null)
 if [ -z "$XDG_MENU_VER" ];
 then
@@ -212,34 +371,30 @@ fi
 ################################
 # Setup derived variables
 ################################
-PGM_VERSION=$(echo ${BUNDLE_DIR} | awk 'BEGIN { FS = "-" } ; { print $2 }' | awk 'BEGIN { FS = "_"} ; { print $1}')
-PGM_BUILD=$(echo ${BUNDLE_DIR} | awk 'BEGIN { FS = "-" } ; { print $2 }' | awk 'BEGIN { FS = "_"} ; { print $2}')
-PGM_FULL_NAME="${PGM_NAME}-${PGM_VERSION}_${PGM_BUILD}"
+PGM_VERSION=$(echo ${BUNDLE_DIR} | cut -d- -f2)
+PGM_BUILDTYPE=$(echo ${BUNDLE_DIR} | cut -d- -f3)
 
-ICON_NAME="${PGM_VENDOR}-${PGM_NAME}_${PGM_VERSION}"                   #no dash since it seperates vendor from program
-MENU_FILE="${PGM_VENDOR}-${PGM_NAME}_${PGM_VERSION}.desktop"   #no dash since it seperates vendor from program
-DESKTOP_LINK_FILE="${PGM_NAME}_${PGM_VERSION}.desktop"
+if [ -z ${PGM_BUILDTYPE} ];
+then
+       PGM_FULL_NAME="${PGM_NAME}-${PGM_VERSION}"
+       ICON_NAME="${PGM_VENDOR}-${PGM_NAME}_${PGM_VERSION}"                    #no dash between name and version since dash seperates vendor from program
+       MENU_FILE="${PGM_VENDOR}-${PGM_NAME}_${PGM_VERSION}.desktop"    #no dash between name and version since dash seperates vendor from program
+       DESKTOP_LINK_FILE="${PGM_NAME}_${PGM_VERSION}.desktop"
+else
+       PGM_FULL_NAME="${PGM_NAME}-${PGM_VERSION}-${PGM_BUILDTYPE}"
+       ICON_NAME="${PGM_VENDOR}-${PGM_NAME}_${PGM_VERSION}_${PGM_BUILDTYPE}"                   #no dash between name and version since dash seperates vendor from program
+       MENU_FILE="${PGM_VENDOR}-${PGM_NAME}_${PGM_VERSION}_${PGM_BUILDTYPE}.desktop"   #no dash between name and version since dash seperates vendor from program
+       DESKTOP_LINK_FILE="${PGM_NAME}_${PGM_VERSION}_${PGM_BUILDTYPE}.desktop"
+fi
 
 PGM_EXEC_PATH="${INSTALL_DEST_BASE}/${PGM_FULL_NAME}/bin/${PGM_EXEC_FILE}"
-ICON_PATH="${INSTALL_DEST_BASE}/${PGM_FULL_NAME}/etc/icons"
+ICON_PATH="${INSTALL_DEST_BASE}/${PGM_FULL_NAME}/share/icons"
 MENU_FILE_PATH="${INSTALL_DEST_BASE}/${PGM_FULL_NAME}/share"
 
-       
-
 ################################
 # Install bundle and Menu/Link
 ################################
 
-if [ ! -d ${INSTALL_DEST_BASE} ];
-then
-       echo ""
-       echo "!!! ERROR !!! - Installation location ${INSTALL_DEST_BASE} does not exist!"
-       echo "Installation will not complete."
-       echo ""
-       read -p "Press ENTER to exit installer:" BLAH
-       exit 1
-fi
-
 # uninstall any older versions
 UNINSTALLERS=$(find ${INSTALL_DEST_BASE} -maxdepth 1 -type f -name "${PGM_NAME}*.uninstall.sh")
 if [ ! -z "$UNINSTALLERS" ];
@@ -256,6 +411,7 @@ then
                        echo "Running uninstaller $i"
                        
                        ${i}
+                       ${SUPER} rm -f ${i}
                fi
        done
 fi
@@ -264,12 +420,12 @@ fi
 # install 
 
 echo ""
-echo "Installing ${PGM_NAME} ${PGM_VERSION} built from ${PGM_BUILD} in ${INSTALL_DEST_BASE}"
+echo "Installing ${PGM_NAME} ${PGM_VERSION} in ${INSTALL_DEST_BASE}"
 echo ""
 
 # Copy the new version in the install directory
-sudo mkdir ${INSTALL_DEST_BASE}/${PGM_FULL_NAME} 
-sudo cp -Rf    ${BUNDLE_DIR}/* ${INSTALL_DEST_BASE}/${PGM_FULL_NAME}/
+${SUPER} mkdir ${INSTALL_DEST_BASE}/${PGM_FULL_NAME} 
+${SUPER} cp -Rf        ${BUNDLE_DIR}/* ${INSTALL_DEST_BASE}/${PGM_FULL_NAME}/
 
 # write the desktop/menu file
 echo "[Desktop Entry]" > /tmp/${MENU_FILE}
@@ -278,46 +434,72 @@ echo "Version=1.0" >> /tmp/${MENU_FILE}
 echo "Type=Application" >> /tmp/${MENU_FILE}
 echo "Terminal=false" >> /tmp/${MENU_FILE}
 echo "Exec=${PGM_EXEC_PATH}" >> /tmp/${MENU_FILE}
-echo "Name=${PGM_NAME}-${PGM_VERSION}" >> /tmp/${MENU_FILE}
+if [ -z ${PGM_BUILDTYPE} ];
+then
+       echo "Name=${PGM_NAME}-${PGM_VERSION}" >> /tmp/${MENU_FILE}
+else
+       echo "Name=${PGM_NAME}-${PGM_VERSION}-${PGM_BUILDTYPE}" >> /tmp/${MENU_FILE}
+fi
 echo "Icon=${ICON_NAME}" >> /tmp/${MENU_FILE}
 echo "Comment=Digital Audio Workstation" >> /tmp/${MENU_FILE}
-echo "Categories=AudioVideo;Audio;Recorder;" >> /tmp/${MENU_FILE}
+echo "Categories=AudioVideo;AudioEditing;Audio;Recorder;" >> /tmp/${MENU_FILE}
 
 chmod ugo+rx /tmp/${MENU_FILE}
-sudo mv /tmp/${MENU_FILE} ${MENU_FILE_PATH}/.
+${SUPER} mv /tmp/${MENU_FILE} ${MENU_FILE_PATH}/.
 
 # install the Menu, Link, and Icon(s)
 if [ "T" = ${HAS_XDG} ];
 then
        echo "Adding ${PGM_NAME} to the applications menu"
-       sudo xdg-icon-resource install --context apps --size 16 ${ICON_PATH}/${PGM_NAME_LOWER}_icon_16px.png ${ICON_NAME}
-       sudo xdg-icon-resource install --context apps --size 22 ${ICON_PATH}/${PGM_NAME_LOWER}_icon_22px.png ${ICON_NAME}
-       sudo xdg-icon-resource install --context apps --size 32 ${ICON_PATH}/${PGM_NAME_LOWER}_icon_32px.png ${ICON_NAME}
-       sudo xdg-icon-resource install --context apps --size 48 ${ICON_PATH}/${PGM_NAME_LOWER}_icon_48px.png ${ICON_NAME}
+       ${SUPER} xdg-icon-resource install --context apps --size 16 ${ICON_PATH}/${PGM_NAME_LOWER}_icon_16px.png ${ICON_NAME}
+       ${SUPER} xdg-icon-resource install --context apps --size 22 ${ICON_PATH}/${PGM_NAME_LOWER}_icon_22px.png ${ICON_NAME}
+       ${SUPER} xdg-icon-resource install --context apps --size 32 ${ICON_PATH}/${PGM_NAME_LOWER}_icon_32px.png ${ICON_NAME}
+       ${SUPER} xdg-icon-resource install --context apps --size 48 ${ICON_PATH}/${PGM_NAME_LOWER}_icon_48px.png ${ICON_NAME}
+       ${SUPER} xdg-icon-resource install --context apps --size 256 ${ICON_PATH}/${PGM_NAME_LOWER}_icon_256px.png ${ICON_NAME}
 
        if [ -e ${ICON_PATH}/${PGM_NAME_LOWER}_icon.svg -a -d /usr/share/icons/hicolor/scalable/apps ]; 
        then
-               sudo cp -f ${ICON_PATH}/${PGM_NAME_LOWER}_icon.svg  /usr/share/icons/hicolor/scalable/apps/${ICON_NAME}.svg
+               ${SUPER} cp -f ${ICON_PATH}/${PGM_NAME_LOWER}_icon.svg  /usr/share/icons/hicolor/scalable/apps/${ICON_NAME}.svg
        fi
 
-       sudo xdg-desktop-menu install ${MENU_FILE_PATH}/${MENU_FILE}
-
+       ${SUPER} xdg-desktop-menu install ${MENU_FILE_PATH}/${MENU_FILE}
+       ${SUPER} xdg-desktop-menu forceupdate --mode system                     # Some systems need an extra kick
+       
        echo ""
-       echo "Creating a desktop link for ${PGM_NAME}"
-       cp ${MENU_FILE_PATH}/${MENU_FILE} ~/Desktop/${DESKTOP_LINK_FILE}
-       chmod ugo+rx ~/Desktop/${DESKTOP_LINK_FILE}
+       echo "Creating a desktop link for ${PGM_NAME} in ${USER_DESKTOP_DIR}"
+       cp ${MENU_FILE_PATH}/${MENU_FILE} ${USER_DESKTOP_DIR}/${DESKTOP_LINK_FILE}
+       chmod ugo+rwx ${USER_DESKTOP_DIR}/${DESKTOP_LINK_FILE}
 else
        echo ""
-       echo "Creating a desktop link for ${PGM_NAME}"
-       cp ${MENU_FILE_PATH}/${MENU_FILE} ~/Desktop/${DESKTOP_LINK_FILE}
-       chmod ugo+rx ~/Desktop/${DESKTOP_LINK_FILE}
+       echo "Creating a desktop link for ${PGM_NAME} in ${USER_DESKTOP_DIR}"
+       cp ${MENU_FILE_PATH}/${MENU_FILE} ${USER_DESKTOP_DIR}/${DESKTOP_LINK_FILE}
+       chmod ugo+rwx ${USER_DESKTOP_DIR}/${DESKTOP_LINK_FILE}
 fi
 
 echo ""
 echo "Copying uninstall script to ${INSTALL_DEST_BASE}"
 echo ""
 
-sudo cp -f ${BUNDLE_DIR}/bin/*.uninstall.sh ${INSTALL_DEST_BASE}/.
+${SUPER} cp -f ${BUNDLE_DIR}/bin/*.uninstall.sh ${INSTALL_DEST_BASE}/.
+
+# Create link to the program in user bin
+
+echo ""
+echo "Creating link ${PGM_NAME}3 in ${USER_BIN_DIR}"
+echo ""
+
+if [ -d "${USER_BIN_DIR}" ]; then
+       if [ -e "${USER_BIN_DIR}/${PGM_NAME}3" ]; then
+               ${SUPER} rm -f ${USER_BIN_DIR}/${PGM_NAME}3
+       fi
+
+       cd "${USER_BIN_DIR}"
+       ${SUPER} ln -sf ${PGM_EXEC_PATH} ${PGM_NAME}3 
+       cd "${PKG_PATH}"
+       
+else
+       echo "Can not create link because ${USER_BIN_DIR} does not exist"
+fi
 
 ###########################
 # Check Jack and qjackctl
@@ -327,6 +509,8 @@ echo ""
 echo "Checking to see if Jack is installed"
 echo ""
 
+JACK_INSTALLED="f"
+
 if ! which jackd > /dev/null;
 then
        echo ""
@@ -339,22 +523,98 @@ then
        then
                echo "Attempting to install Jack"
                SystemInstall "jackd"
-
+               
                if [ $? -ne 0 ];
                then
                        echo ""
                        read -p "Press ENTER to continue:" BLAH
+               else
+                       JACK_INSTALLED="t"
                fi
        fi
 else
-       echo "Jack OK"
+       JACK_INSTALLED="t"
+       echo "Jack already present"
 fi
 
+# Check to see if Jack is new enough to operate correctly.
+
+if [ "t" = ${JACK_INSTALLED} ];
+then
+       JACK_VERSION_OK="f"
+       JACK_VER_STRING=$(jackd --version | grep -e "jackd.*protocol")
+       JACK_NAME=$(echo $JACK_VER_STRING | awk '{print $1}')
+       JACK_VERSION=$(echo $JACK_VER_STRING | awk '{print $3}')
+       JACK_VERSION_MAJOR=$(echo $JACK_VERSION | awk 'BEGIN{FS="."}{print $1}')
+       JACK_VERSION_MIDDLE=$(echo $JACK_VERSION | awk 'BEGIN{FS="."}{print $2}')
+       JACK_VERSION_MINOR=$(echo $JACK_VERSION | awk 'BEGIN{FS="."}{print $3}')
+
+       if [ "jackd" = ${JACK_NAME} ];
+       then
+               if [ ${JACK_VERSION_MAJOR} -eq 0 ];
+               then
+                       if [ ${JACK_VERSION_MIDDLE} -eq 121 ];
+                       then
+                               if [ ${JACK_VERSION_MINOR} -ge 3 ];
+                               then
+                                       JACK_VERSION_OK="t"
+                               fi
+                       elif [ ${JACK_VERSION_MIDDLE} -gt 121 ];
+                       then
+                               JACK_VERSION_OK="t"
+                       fi
+               elif [ ${JACK_VERSION_MAJOR} -gt 0 ];
+               then
+                       JACK_VERSION_OK="t"
+               fi
+       elif [ "jackdmp" = ${JACK_NAME} ];
+       then
+               if [ ${JACK_VERSION_MAJOR} -eq 1 ];
+               then
+                       if [ ${JACK_VERSION_MIDDLE} -eq 9 ];
+                       then
+                               if [ ${JACK_VERSION_MINOR} -ge 8 ];
+                               then
+                                       JACK_VERSION_OK="t"
+                               fi
+                       elif [ ${JACK_VERSION_MIDDLE} -gt 9 ];
+                       then
+                               JACK_VERSION_OK="t"
+                       fi
+               elif [ ${JACK_VERSION_MAJOR} -gt 1 ];
+               then
+                       JACK_VERSION_OK="t"
+               fi
+       fi
+
+       if [ "t" = ${JACK_VERSION_OK} ];
+       then
+               echo ""
+               echo "Jack Version Check OK (${JACK_VER_STRING})"
+               echo ""
+       else
+               echo ""
+               echo "!!! WARNING !!! - The version of Jack on this system is too old!"
+               echo "Using an old version of Jack is not recommended. Please update"
+               echo "Jack for best results."
+               echo ""
+               echo "System Jack version:"
+               echo "   ${JACK_VER_STRING}"
+               echo ""
+               echo "Recommended minimum versions:"
+               echo "   Jack1 - 0.121.3"
+               echo "   Jack2 - 1.9.8"
+               echo ""
+               read -p "Press ENTER to continue:" BLAH
+       fi
+fi
 
 if ! which qjackctl > /dev/null;
 then
        echo ""
-       echo "The program QjackCtl is missing from this system. QjackCtl is an OPTIONAL component of $PGM_NAME."
+       echo "The program QjackCtl is missing from this system."
+       echo "QjackCtl is an extremely useful tool for any system that runs JACK applications like $PGM_NAME."
+       echo "We recommend that you install it."
        echo ""
 
        ANSWER=$(VaildateYesNoQuestion "Install QjackCtl using system software repository?")
@@ -379,19 +639,19 @@ fi
 
 USER_GROUP_ADJUSTED="f"
 
-if ! ./${BUNDLE_DIR}/bin/sanityCheck -a > /dev/null;
+if ! ${NORM_USER} "${INSTALL_DEST_BASE}/${PGM_FULL_NAME}/bin/sanityCheck -a > /dev/null";
 then
        echo ""
        echo "System failed the quick sanity check... Looking for the cause"
 
-       if ! ./${BUNDLE_DIR}/bin/sanityCheck -rt > /dev/null;
+       if ! ${NORM_USER} "${INSTALL_DEST_BASE}/${PGM_FULL_NAME}/bin/sanityCheck -rt > /dev/null";
        then
                echo ""
                echo "System does not allow realtime for the current user... Looking for a solution"            
                
-               if ./${BUNDLE_DIR}/bin/sanityCheck -hasaudiogroup > /dev/null;
+               if ${NORM_USER} "${INSTALL_DEST_BASE}/${PGM_FULL_NAME}/bin/sanityCheck -hasaudiogroup > /dev/null";
                then
-                       if ./${BUNDLE_DIR}/bin/sanityCheck -memberaudiogroup > /dev/null 2>&1;
+                       if ${NORM_USER} "${INSTALL_DEST_BASE}/${PGM_FULL_NAME}/bin/sanityCheck -memberaudiogroup > /dev/null 2>&1";
                        then
                                ## This is an odd case. We have an audio group and are a member.
                                echo ""
@@ -407,17 +667,16 @@ then
                        else
                                # Not a member of an audio group. Try to fix it.
                                
-                               if ./${BUNDLE_DIR}/bin/sanityCheck -hasgroup audio > /dev/null && find /etc/security -type f -name "*.conf" | xargs grep -q "^@audio.*rtprio";
+                               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" ";
                                then
                                        # add user to audio group
                                        echo ""
-                                       echo "Adding user `whoami` to the audio group."
+                                       echo "Adding user ${USER_NAME} to the audio group."
                                        echo "This should allow you to run realtime tasks. Please re-login for this change to take affect."
                                        echo ""
                                        read -p "Press ENTER to continue:" BLAH
 
-                                       user=`whoami`
-                                       if sudo usermod -a -G audio $user;
+                                       if ${SUPER} usermod -a -G audio ${USER_NAME};
                                        then
                                                USER_GROUP_ADJUSTED="t"
                                        else
@@ -429,17 +688,16 @@ then
                                                read -p "Press ENTER to continue:" BLAH
                                        fi
 
-                               elif ./${BUNDLE_DIR}/bin/sanityCheck -hasgroup jackuser > /dev/null && find /etc/security -type f -name "*.conf" | xargs grep -q "^@jackuser.*rtprio";
+                               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" ";
                                then
                                        # add user to jackuser group
                                        echo ""
-                                       echo "Adding user `whoami` to the jackuser group."
+                                       echo "Adding user ${USER_NAME} to the jackuser group."
                                        echo "This should allow you to run realtime tasks. Please re-login for this change to take affect."
                                        echo ""
                                        read -p "Press ENTER to continue:" BLAH
 
-                                       user=`whoami`
-                                       if sudo usermod -a -G jackuser $user;
+                                       if ${SUPER} usermod -a -G jackuser ${USER_NAME};
                                        then
                                                USER_GROUP_ADJUSTED="t"
                                        else
@@ -466,21 +724,19 @@ then
                fi
        fi
 
-       if ! ./${BUNDLE_DIR}/bin/sanityCheck -freqscaling > /dev/null;
+       if ! ${NORM_USER} "${INSTALL_DEST_BASE}/${PGM_FULL_NAME}/bin/sanityCheck -freqscaling > /dev/null";
        then
                echo ""
                echo "!!! WARNING !!! - Your system seems to use frequency scaling."
-               echo "This can have a serious impact on audio latency. You have two choices:"
-               echo "(1) turn it off, e.g. by chosing the 'performance' governor."
-               echo "(2) Use the HPET clocksource by passing \"-c h\" to JACK"
-               echo "(this second option only works on relatively recent computers)"
+               echo "This can have a serious impact on audio latency."
+               echo "For best results turn it off, e.g. by chosing the 'performance' governor."
                echo ""
                read -p "Press ENTER to continue:" BLAH
        fi
 
        if [ "f" = $USER_GROUP_ADJUSTED ];
        then
-               if ! ./${BUNDLE_DIR}/bin/sanityCheck -memlock > /dev/null;
+               if ! ${NORM_USER} "${INSTALL_DEST_BASE}/${PGM_FULL_NAME}/bin/sanityCheck -memlock > /dev/null";
                then
                        echo ""
                        echo "!!! WARNING !!! - You are not allowed to lock memory."
@@ -511,6 +767,6 @@ then
 fi
 
 echo ""
-read -p "Press ENTER to close this window:" BLAH
+read -p "Press ENTER to exit installer:" BLAH