remove cruft from packaging scripts
[ardour.git] / tools / linux_packaging / stage2.run.in
index 4b6cb728af712a82822c47c11fcf0609a76db349..113e5c64cd48737fe855f368bc4c877a6653c249 100755 (executable)
@@ -31,6 +31,7 @@ USER_NAME=$(logname)
 
 #### Global Variables ####
 HAS_XDG="T"
+MULTABI_BUNDLE=""
 
 ########################
 # Function Definitions
@@ -229,42 +230,42 @@ case `uname -m` in
                ;;
 esac
 
-#############################
-# Determine C11 stdlibc++ ABI
-#############################
+###################
+# Determine gcc ABI
+###################
 
-if %REPLACE_GCC5%; then
-       # Ardour was compiled with gcc5, warn on gcc4 systems
-       if ! ${NORM_USER} "${PKG_PATH}/.gcc-glibmm-abi-check --gcc5 > /dev/null"; then
-               echo ""
-               echo "WARNING: GCC4/5 libstdc++ ABI Mismatch"
-               echo ""
-               echo "Ardour was compiled with gcc5, your system uses an older version of the"
-               echo "standard c++ library. Plugins on your system may not load or plugin-UIs"
-               echo "may cause crashes."
-               echo ""
-               ANSWER=$(VaildateYesNoQuestion "Continue anyway?")
-               if test "n" = $ANSWER; then
-                       exit 1
-               fi
+if test -n "$MULTABI_BUNDLE"; then
+       if ! "${PKG_PATH}/.gcc-glibmm-abi-check" --fail --gcc5; then
+               ABI=-gcc4
+       else
+               ABI=-gcc5
        fi
-else
-       # Ardour was compiled with gcc4, warn on gcc5 systems
-       if ! ${NORM_USER} "${PKG_PATH}/.gcc-glibmm-abi-check --gcc4 > /dev/null"; then
-               echo ""
-               echo "WARNING: GCC4/5 libstdc++ ABI Mismatch"
-               echo ""
-               echo "Ardour was compiled with gcc4, your system uses a newer version of the"
-               echo "standard c++ library. Plugins on your system may not load or plugin-UIs"
-               echo "may cause crashes."
-               echo ""
-               ANSWER=$(VaildateYesNoQuestion "Continue anyway?")
-               if test "n" = $ANSWER; then
-                       exit 1
-               fi
+  # allow to manually override
+       if test "$1" = "--gcc4"; then
+               ABI=-gcc4
        fi
+       if test "$1" = "--gcc5"; then
+               ABI=-gcc5
+       fi
+else
+       ABI=
 fi
 
+####################################
+# Check if bundle is for this system
+####################################
+
+if [ ! -e ${PGM_NAME}_${ARCH}${ABI}-*.tar ]; then
+       echo ""
+       echo "!!! ERROR !!! Can't locate ${ARCH}${ABI} bundle file."
+       echo "The installer detected the system as ${ARCH}${ABI}, but this bundle"
+       echo "does not contain the files needed for that configuration."
+       echo ""
+       read -p "Press ENTER to exit installer:" BLAH
+       exit 1
+fi
+
+
 ####################
 # Check disk space
 ####################
@@ -273,15 +274,15 @@ fi
 # in case they are on different devices
 echo "Checking for required disk space"
 
-if [ ! -e .${PGM_NAME}_${ARCH}-*.size ]; then
+if [ ! -e .${PGM_NAME}_${ARCH}${ABI}-*.size ]; then
        echo ""
-       echo "!!! ERROR !!! Can't locate .size file for ${ARCH} bundle."
-       echo "This package is broken or does not support ${ARCH}."
+       echo "!!! ERROR !!! Can't locate .size file for ${ARCH}${ABI} bundle."
+       echo "This package is broken or does not support ${ARCH}${ABI}."
        echo ""
        read -p "Press ENTER to exit installer:" BLAH
        exit 1
 else
-       REQUIRED_BYTES=$(cat .${PGM_NAME}_${ARCH}-*.size)
+       REQUIRED_BYTES=$(cat .${PGM_NAME}_${ARCH}${ABI}-*.size)
 
        #Installer needs 2x the space since the bundle is unpacked locally and then copied
        REQUIRED_BYTES=$(($REQUIRED_BYTES + $REQUIRED_BYTES))
@@ -313,27 +314,70 @@ else
        fi
 fi
 
-FILESYSTEM_TYPE=$(df -P -T "${PKG_PATH}" | grep / | awk '{print $2}')
-echo "Bundle is on ${FILESYSTEM_TYPE} filesystem"
+#############################
+# Determine C11 stdlibc++ ABI
+#############################
+
+if test -z "$ABI"; then
+       if %REPLACE_GCC5%; then
+               # Ardour was compiled with gcc5, warn on gcc4 systems
+               if ! "${PKG_PATH}/.gcc-glibmm-abi-check" --gcc5; then
+                       echo ""
+                       echo "WARNING: GCC4/5 libstdc++ ABI Mismatch"
+                       echo ""
+                       echo "${PGM_NAME} was compiled with gcc5, your system uses an older version of the"
+                       echo "standard c++ library. Plugins on your system may not load or plugin-UIs"
+                       echo "may cause crashes."
+                       echo ""
+                       ANSWER=$(VaildateYesNoQuestion "Continue anyway?")
+                       if test "n" = $ANSWER; then
+                               exit 1
+                       fi
+               fi
+       else
+               # Ardour was compiled with gcc4, warn on gcc5 systems
+               if ! "${PKG_PATH}/.gcc-glibmm-abi-check" --gcc4 ; then
+                       echo ""
+                       echo "WARNING: GCC4/5 libstdc++ ABI Mismatch"
+                       echo ""
+                       echo "${PGM_NAME} was compiled with gcc4, your system uses a newer version of the"
+                       echo "standard c++ library. Plugins on your system may not load or plugin-UIs"
+                       echo "may cause crashes."
+                       echo ""
+                       ANSWER=$(VaildateYesNoQuestion "Continue anyway?")
+                       if test "n" = $ANSWER; then
+                               exit 1
+                       fi
+               fi
+       fi
+fi
+
+if %REPLACE_WINE%; then
+       if test -z "`which wine`"; then
+               echo ""
+               echo "!!! ERROR !!! - 'wine' was not found."
+               echo ""
+               echo "This version of ${PGM_NAME} with Windows VST support requires wine."
+               echo "https://www.winehq.org/"
+               echo ""
+               read -p "Press ENTER to exit installer:" BLAH
+               exit 1
+       fi
+fi
 
 #####################
 # Unpack the bundle
 #####################
 
-# untar the correct bundle for us to install
-echo "Unpacking bundle for $ARCH"
+FILESYSTEM_TYPE=$(df -P -T "${PKG_PATH}" | grep / | awk '{print $2}')
+echo "Bundle is on ${FILESYSTEM_TYPE} filesystem"
 
-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
+# untar the correct bundle for us to install
+echo "Unpacking bundle for $ARCH${ABI}"
 
-if ! tar -xjf ${PGM_NAME}_${ARCH}-*.tar.bz2; then
+if ! tar -xf ${PGM_NAME}_${ARCH}${ABI}-*.tar; then
        echo ""
-       echo "!!! ERROR !!! Can't unpack ${ARCH} bundle file."
+       echo "!!! ERROR !!! Can't unpack ${ARCH}${ABI} bundle file."
        echo ""
        read -p "Press ENTER to exit installer:" BLAH
        exit 1
@@ -375,6 +419,54 @@ then
        HAS_XDG="F"
 fi
 
+#################################################
+# Set up libwine.so
+#################################################
+if %REPLACE_WINE%; then
+       echo ""
+       echo "Searching libwine.so (Windows VST support)"
+       # we need to add libwine to ardour's LD_LIBRARY_PATH
+       # libwine itself includes paths to the various system-components
+       # which may be different on each platform.
+       #
+       # There's some chicken/egg here: ardour.exe.so is linked against libwine.so
+       # at build-time. wine/wineloader assumes a windows-application (which does not use libwine
+       # directly) and does not set up the LD path to libwine itself. the application terminates
+       # (missing libs) before it even starts..
+       #
+       # wine itself does not provide means to find the location of libwine.
+       # /usr/bin/wine is usually shell-script and libwine.so can be found in
+       # various places on different distros.
+       #
+       # if this check were quick and easy.. it should be done in the startup-script, but it's not
+       # so here we go... (updating wine may require re-installing ardour)
+       #
+       # on recent Ubuntu wine does load both:
+       #   /usr/lib/i386-linux-gnu/libwine.so.1
+       # AND
+       #   /usr/lib/x86_64-linux-gnu/libwine.so.1
+       # so we need to work around this (thanks).
+       # (this hack break 64bit LinuxVST builds, but we don't do those anyway)
+
+       LIBWINE=$(
+               LD_DEBUG=files wine `pwd`/${BUNDLE_DIR}/lib/ardour-vst-scanner.exe.so 2>&1 \
+                                                | grep -e "calling init:.*libwine" \
+                                                | sed 's/^.*calling init: //' \
+                                                | grep -v x86_64-linux-gnu \
+                                                | uniq \
+                       )
+       if ! test -f "$LIBWINE"; then
+               echo ""
+               echo "!!! ERROR !!! - 'libwine.so*' was not found."
+               echo ""
+               read -p "Press ENTER to exit installer:" BLAH
+               exit 1
+       fi
+       echo "Using: $LIBWINE"
+  # this replaces/overwrites the bundled libwine
+       cp -L "$LIBWINE" `pwd`/${BUNDLE_DIR}/lib/libwine.so.1
+fi
+
 #################################################
 # Check if system libs are OK (libc, etc)
 #################################################
@@ -439,7 +531,7 @@ else
 fi
 
 PGM_EXEC_PATH="${INSTALL_DEST_BASE}/${PGM_FULL_NAME}/bin/${PGM_EXEC_FILE}"
-ICON_PATH="${INSTALL_DEST_BASE}/${PGM_FULL_NAME}/share/icons"
+ICON_PATH="${INSTALL_DEST_BASE}/${PGM_FULL_NAME}/share/resources"
 MENU_FILE_PATH="${INSTALL_DEST_BASE}/${PGM_FULL_NAME}/share"
 
 ################################
@@ -447,7 +539,7 @@ MENU_FILE_PATH="${INSTALL_DEST_BASE}/${PGM_FULL_NAME}/share"
 ################################
 
 # uninstall any older versions
-UNINSTALLERS=$(find ${INSTALL_DEST_BASE} -maxdepth 1 -type f -name "${PGM_NAME}*.uninstall.sh")
+UNINSTALLERS=$(find ${INSTALL_DEST_BASE} -maxdepth 1 -type f -name "${PGM_NAME}-*.uninstall.sh")
 if [ ! -z "$UNINSTALLERS" ];
 then
        for i in $UNINSTALLERS; do
@@ -502,15 +594,15 @@ ${SUPER} mv /tmp/${MENU_FILE} ${MENU_FILE_PATH}/.
 if [ "T" = ${HAS_XDG} ];
 then
        echo "Adding ${PGM_NAME} to the applications menu"
-       ${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}
+       ${SUPER} xdg-icon-resource install --context apps --size 16 ${ICON_PATH}/${PGM_NAME}-icon_16px.png ${ICON_NAME}
+       ${SUPER} xdg-icon-resource install --context apps --size 22 ${ICON_PATH}/${PGM_NAME}-icon_22px.png ${ICON_NAME}
+       ${SUPER} xdg-icon-resource install --context apps --size 32 ${ICON_PATH}/${PGM_NAME}-icon_32px.png ${ICON_NAME}
+       ${SUPER} xdg-icon-resource install --context apps --size 48 ${ICON_PATH}/${PGM_NAME}-icon_48px.png ${ICON_NAME}
+       ${SUPER} xdg-icon-resource install --context apps --size 256 ${ICON_PATH}/${PGM_NAME}-icon_256px.png ${ICON_NAME}
 
-       if [ -e ${ICON_PATH}/${PGM_NAME_LOWER}_icon.svg -a -d /usr/share/icons/hicolor/scalable/apps ]; 
+       if [ -e ${ICON_PATH}/${PGM_NAME}_icon.svg -a -d /usr/share/icons/hicolor/scalable/apps ];
        then
-               ${SUPER} 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}_icon.svg  /usr/share/icons/hicolor/scalable/apps/${ICON_NAME}.svg
        fi
 
        ${SUPER} xdg-desktop-menu install ${MENU_FILE_PATH}/${MENU_FILE}
@@ -518,13 +610,13 @@ then
        
        echo ""
        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}
+       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} 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}
+       cp ${MENU_FILE_PATH}/${MENU_FILE} "${USER_DESKTOP_DIR}/${DESKTOP_LINK_FILE}"
+       chmod ugo+rwx "${USER_DESKTOP_DIR}/${DESKTOP_LINK_FILE}"
 fi
 
 echo ""
@@ -572,7 +664,10 @@ elif which jackdbus > /dev/null; then
        JACK_INSTALLED="i"
 else
        echo ""
-       echo "The program Jack is missing from this system. Jack is a required component of $PGM_NAME."
+       echo "The program Jack is missing from this system."
+       echo ""
+       echo "Jack is a very useful utility to allow you to interconnect $PGM_NAME and other audio/MIDI applications."
+       echo "You can use $PGM_NAME without it, but you may find it useful to have around."
        echo ""
 
        ANSWER=$(VaildateYesNoQuestion "Install jack using system software repository?")
@@ -784,7 +879,7 @@ then
                echo ""
                echo "!!! WARNING !!! - Your system seems to use frequency scaling."
                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 "For best results turn it off, e.g. by choosing the 'performance' governor."
                echo ""
                read -p "Press ENTER to continue:" BLAH
        fi