Don't compress linux bundle, compress installer (with xz)
[ardour.git] / tools / linux_packaging / stage2.run.in
index 4894875ab572f566a4a8db9a0a2a24bb829c2105..c59bf95c86993d07689a1e51358970e94f7af803 100755 (executable)
@@ -12,7 +12,7 @@ MAJOR_VERSION="%REPLACE_MAJOR_VERSION%"
 
 PGM_NAME="%REPLACE_PGM%"
 PGM_VENDOR="%REPLACE_VENDOR%"
-PGM_EXEC_FILE="ardour${MAJOR_VERSION}"
+PGM_EXEC_FILE="%REPLACE_EXE%${MAJOR_VERSION}"
 
 THE_SHELL="/bin/sh"
 
@@ -277,17 +277,66 @@ 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 %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 "${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 ! ${NORM_USER} "${PKG_PATH}/.gcc-glibmm-abi-check --gcc4 > /dev/null"; 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
+
+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
 #####################
 
+FILESYSTEM_TYPE=$(df -P -T "${PKG_PATH}" | grep / | awk '{print $2}')
+echo "Bundle is on ${FILESYSTEM_TYPE} filesystem"
+
 # untar the correct bundle for us to install
 echo "Unpacking bundle for $ARCH"
 
-if [ ! -e ${PGM_NAME}_${ARCH}-*.tar.bz2 ]; then
+if [ ! -e ${PGM_NAME}_${ARCH}-*.tar ]; then
        echo ""
        echo "!!! ERROR !!! Can't locate ${ARCH} bundle file."
        echo ""
@@ -295,7 +344,7 @@ if [ ! -e ${PGM_NAME}_${ARCH}-*.tar.bz2 ]; then
        exit 1
 fi
 
-if ! tar -xjf ${PGM_NAME}_${ARCH}-*.tar.bz2; then
+if ! tar -xf ${PGM_NAME}_${ARCH}-*.tar; then
        echo ""
        echo "!!! ERROR !!! Can't unpack ${ARCH} bundle file."
        echo ""
@@ -339,6 +388,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)
 #################################################
@@ -351,7 +448,7 @@ LIB_ERROR="F"
 LD_PATH=`pwd`/${BUNDLE_DIR}/lib
 
 # check the main App
-LDD_RESULT=$(LD_LIBRARY_PATH=${LD_PATH} ldd ${BUNDLE_DIR}/bin/${PGM_NAME_LOWER}-* 2>&1 > /dev/null)
+LDD_RESULT=$(LD_LIBRARY_PATH=${LD_PATH} ldd ${BUNDLE_DIR}/bin/${PGM_NAME_LOWER}-* 2>&1 > /dev/null | grep -v "no version information")
 
 if [ -n "$LDD_RESULT" ];
 then
@@ -364,7 +461,7 @@ LIB_FILES=$(find ${BUNDLE_DIR}/lib -name "*.so")
 
 for path in $LIB_FILES
 do
-       LDD_RESULT=$(LD_LIBRARY_PATH=${LD_PATH} ldd $path 2>&1 > /dev/null)
+       LDD_RESULT=$(LD_LIBRARY_PATH=${LD_PATH} ldd $path 2>&1 > /dev/null | grep -v "no version information")
        if [ -n "$LDD_RESULT" ];
        then
                echo "$LDD_RESULT"
@@ -403,7 +500,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"
 
 ################################
@@ -411,7 +508,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
@@ -466,15 +563,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}
@@ -748,7 +845,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