more packaging name fixes
[ardour.git] / tools / linux_packaging / stage2.run
index eee82deab8b0e3c77710e2eb34353260e4714250..3541cf02c247ea053994851f8f711464ab28c60d 100755 (executable)
@@ -15,6 +15,7 @@ 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:]')
 
@@ -138,31 +139,49 @@ if [ "$(id -u)" != "0" ]; then
        if ! which sudo > /dev/null;
        then
                echo ""
-               echo "!!! ERROR !!!"
+               echo "Sudo installed failed, attempting to install using su"
+               echo "Please enter root password below"
                echo ""
-               echo "This installer requires root privileges. It is currently not"
-               echo "running as root AND the program sudo is missing from this system."
-               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
+
+               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 "!!! ERROR !!!"
-               echo ""
-               echo "This installer requires root privileges. It is currently not"
-               echo "running as root AND an attempt to use sudo failed."
-               echo ""
-               echo "Please correct this by installing and configuring sudo or running"
-               echo "the installer as root (su -c)."
+               echo "Attempting to install using su"
+               echo "Please enter root password below"
                echo ""
-               read -p "Press ENTER to exit installer:" BLAH
-               exit 1
+
+               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"
        
@@ -222,7 +241,7 @@ else
        if [ ${FREE_BYTES} -le ${REQUIRED_BYTES} ] ; then
                echo ""
                echo "!!! ERROR !!! - Insufficient disk space in ${PKG_PATH}"
-               echo "Install requires ${REQUIRED_BYTES} bytes and
+               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
@@ -235,7 +254,7 @@ else
        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 "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
@@ -243,6 +262,9 @@ else
        fi
 fi
 
+FILESYSTEM_TYPE=$(df -P -T "${PKG_PATH}" | grep / | awk '{print $2}')
+echo "Bundle is on ${FILESYSTEM_TYPE} filesystem"
+
 #####################
 # Unpack the bundle
 #####################
@@ -258,7 +280,16 @@ if [ ! -e ${PGM_NAME}_${ARCH}-*.tar.bz2 ]; then
        exit 1
 fi
 
-tar -xjf ${PGM_NAME}_${ARCH}-*.tar.bz2
+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}-*"`)
 
 
@@ -340,25 +371,25 @@ 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_VERSION=$(echo ${BUNDLE_DIR} | awk 'BEGIN { FS = "-" } ; { print $2 }')
+PGM_BUILD=$(echo ${BUNDLE_DIR} | awk 'BEGIN { FS = "-" } ; { print $}')
 PGM_BUILDTYPE=$(echo ${BUNDLE_DIR} | awk 'BEGIN { FS = "-" } ; { print $3 }')
 
 if [ -z ${PGM_BUILDTYPE} ];
 then
-       PGM_FULL_NAME="${PGM_NAME}-${PGM_VERSION}_${PGM_BUILD}"
+       PGM_FULL_NAME="${PGM_NAME}-${PGM_VERSION}-${PGM_BUILD}"
        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_BUILD}-${PGM_BUILDTYPE}"
+       PGM_FULL_NAME="${PGM_NAME}-${PGM_VERSION}-${PGM_BUILD}-${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"
 
 ################################
@@ -425,6 +456,7 @@ then
        ${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
@@ -451,6 +483,25 @@ echo ""
 
 ${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
 ###########################
@@ -459,6 +510,8 @@ echo ""
 echo "Checking to see if Jack is installed"
 echo ""
 
+JACK_INSTALLED="f"
+
 if ! which jackd > /dev/null;
 then
        echo ""
@@ -471,17 +524,91 @@ 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 recommened. Please update"
+               echo "Jack for best results."
+               echo ""
+               echo "System Jack version:"
+               echo "   ${JACK_VER_STRING}"
+               echo ""
+               echo "Recommened 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
@@ -602,10 +729,8 @@ then
        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