diff --git a/cmake/apple/MacDeployQt.cmake b/cmake/apple/MacDeployQt.cmake index acd7aae8d21..d754b83c46c 100644 --- a/cmake/apple/MacDeployQt.cmake +++ b/cmake/apple/MacDeployQt.cmake @@ -11,6 +11,9 @@ set(APP "${CPACK_TEMPORARY_INSTALL_DIRECTORY}/${CPACK_PROJECT_NAME_UCASE}.app") # Toggle command echoing & verbosity # 0 = no output, 1 = error/warning, 2 = normal, 3 = debug +if(DEFINED ENV{CPACK_DEBUG}) + set(CPACK_DEBUG "$ENV{CPACK_DEBUG}") +endif() if(NOT CPACK_DEBUG) set(VERBOSITY 1) set(COMMAND_ECHO NONE) diff --git a/cmake/linux/CMakeLists.txt b/cmake/linux/CMakeLists.txt index afdb57dd297..04efa1869a6 100644 --- a/cmake/linux/CMakeLists.txt +++ b/cmake/linux/CMakeLists.txt @@ -8,8 +8,6 @@ if(WANT_CPACK_TARBALL) return() endif() -install(FILES launch_lmms.sh DESTINATION bin) - # Standard CPack options set(CPACK_GENERATOR "External" PARENT_SCOPE) set(CPACK_EXTERNAL_ENABLE_STAGING true PARENT_SCOPE) diff --git a/cmake/linux/LinuxDeploy.cmake b/cmake/linux/LinuxDeploy.cmake index 032c5267505..a7f5400ad41 100644 --- a/cmake/linux/LinuxDeploy.cmake +++ b/cmake/linux/LinuxDeploy.cmake @@ -32,6 +32,9 @@ endif() # Toggle command echoing & verbosity # 0 = no output, 1 = error/warning, 2 = normal, 3 = debug +if(DEFINED ENV{CPACK_DEBUG}) + set(CPACK_DEBUG "$ENV{CPACK_DEBUG}") +endif() if(NOT CPACK_DEBUG) set(VERBOSITY 1) set(APPIMAGETOOL_VERBOSITY "") @@ -120,6 +123,10 @@ set(ENV{DISABLE_COPYRIGHT_FILES_DEPLOYMENT} 1) # Patch desktop file file(APPEND "${DESKTOP_FILE}" "X-AppImage-Version=${CPACK_PROJECT_VERSION}\n") +# Custom scripts to run immediately before lmms is executed +file(COPY "${CPACK_SOURCE_DIR}/cmake/linux/apprun-hooks" DESTINATION "${APP}") +file(REMOVE "${APP}/apprun-hooks/README.md") + # Prefer a hard-copy of .DirIcon over appimagetool's symlinking # 256x256 default for Cinnamon Desktop https://forums.linuxmint.com/viewtopic.php?p=2585952 file(COPY "${APP}/usr/share/icons/hicolor/256x256/apps/${lmms}.png" DESTINATION "${APP}") @@ -158,7 +165,6 @@ message(STATUS "Calling ${LINUXDEPLOY_BIN} --appdir \"${APP}\" ... [... librarie execute_process(COMMAND "${LINUXDEPLOY_BIN}" --appdir "${APP}" --desktop-file "${DESKTOP_FILE}" - --custom-apprun "${CPACK_SOURCE_DIR}/cmake/linux/launch_lmms.sh" --plugin qt ${LIBRARIES} --verbosity ${VERBOSITY} diff --git a/cmake/linux/apprun-hooks/README.md b/cmake/linux/apprun-hooks/README.md new file mode 100644 index 00000000000..2bac9f1cb8b --- /dev/null +++ b/cmake/linux/apprun-hooks/README.md @@ -0,0 +1,11 @@ +# AppRun Hooks + +Scripts placed in this directory will automatically be bundled into AppImages +(e.g. `LMMS.AppDir/apprun-hooks`) and executed immediately before lmms. + +Quoting: + +> "Sometimes it's important to perform actions before running the actual app. Some plugins might have to set e.g., +> environment variables to work properly." + +See also: https://github.com/linuxdeploy/linuxdeploy/wiki/Plugin-system#apprun-hooks \ No newline at end of file diff --git a/cmake/linux/apprun-hooks/carla-hook.sh b/cmake/linux/apprun-hooks/carla-hook.sh new file mode 100644 index 00000000000..c505267bbf7 --- /dev/null +++ b/cmake/linux/apprun-hooks/carla-hook.sh @@ -0,0 +1,44 @@ +#!/usr/bin/env bash + +# Workaround nuances with carla being an optional-yet-hard-linked plugin +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )" +ME="$( basename "${BASH_SOURCE[0]}")" +CARLA_LIB_NAME="libcarla_native-plugin.so" +KNOWN_LOCATIONS=("lib" "lib64") +unset CARLA_LIB_FILE + +# Check for carla at "known" locations +if command -v carla > /dev/null 2>&1; then + CARLA_PATH="$(command -v carla)" + CARLA_PREFIX="${CARLA_PATH%/bin*}" + + # Look for libcarla_native-plugin.so in adjacent lib directory + for lib in "${KNOWN_LOCATIONS[@]}"; do + if [ -e "$CARLA_PREFIX/$lib/carla/$CARLA_LIB_NAME" ]; then + # Add directory to LD_LIBRARY_PATH so libcarlabase.so can find it + CARLA_LIB_FILE="$CARLA_PREFIX/$lib/carla/$CARLA_LIB_NAME" + export LD_LIBRARY_PATH="$CARLA_PREFIX/$lib/carla/:$LD_LIBRARY_PATH" + echo "[$ME] Carla appears to be installed on this system at $CARLA_PREFIX/$lib/carla so we'll use it." >&2 + break + fi + done +else + echo "[$ME] Carla does not appear to be installed. That's OK, please ignore any related library errors." >&2 +fi + +# Additional workarounds for library conflicts +# libgobject has been versioned "2.0" for over 20 years, but the ABI is constantly changing +KNOWN_CONFLICTS=("libgobject-2.0.so.0") +if [ -n "$CARLA_LIB_FILE" ]; then + for conflict in "${KNOWN_CONFLICTS[@]}"; do + # Only prepend LD_PRELOAD if we bundle the same version + if [ -e "$DIR/usr/lib/$conflict" ]; then + conflict_sys="$(ldd "$CARLA_LIB_FILE" | grep "$conflict" | awk '{print $3}')" + if [ -e "$conflict_sys" ]; then + # Add library to LD_PRELOAD so lmms can find it over its bundled version + echo "[$ME] Preferring the system's \"$conflict\" over the version bundled." >&2 + export LD_PRELOAD="$conflict_sys:$LD_PRELOAD" + fi + fi + done +fi diff --git a/cmake/linux/apprun-hooks/jack-hook.sh b/cmake/linux/apprun-hooks/jack-hook.sh new file mode 100644 index 00000000000..1e8321ecfe7 --- /dev/null +++ b/cmake/linux/apprun-hooks/jack-hook.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +# Workaround crash when jack is missing by providing a dummy version +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )" +ME="$( basename "${BASH_SOURCE[0]}")" +if ldconfig -p | grep libjack.so.0 > /dev/null 2>&1; then + echo "[$ME] Jack appears to be installed on this system, so we'll use it." >&2 +else + echo "[$ME] Jack does not appear to be installed. That's OK, we'll use a dummy version instead." >&2 + export LD_LIBRARY_PATH=$DIR/usr/lib/lmms/optional:$LD_LIBRARY_PATH +fi diff --git a/cmake/linux/apprun-hooks/unity-hook.sh b/cmake/linux/apprun-hooks/unity-hook.sh new file mode 100644 index 00000000000..7b0052ff7cf --- /dev/null +++ b/cmake/linux/apprun-hooks/unity-hook.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +# Workaround Unity desktop menubar integration +# - Unity's menubar relocation breaks Qt's MDI window handling in Linux +# - Unity was default in Ubuntu 11.04 - 18.04 +if [ "$XDG_CURRENT_DESKTOP" = "Unity" ]; then + export QT_X11_NO_NATIVE_MENUBAR=1 +fi diff --git a/cmake/linux/apprun-hooks/usr-lib-hooks.sh b/cmake/linux/apprun-hooks/usr-lib-hooks.sh new file mode 100644 index 00000000000..d33b8a22db7 --- /dev/null +++ b/cmake/linux/apprun-hooks/usr-lib-hooks.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +# Workaround libraries being incorrectly placed in usr/lib (e.g. instead of usr/lib/lmms, etc) +# FIXME: Remove when linuxdeploy supports subfolders https://github.com/linuxdeploy/linuxdeploy/issues/305 +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )" +export LMMS_PLUGIN_DIR="$DIR/usr/lib/" +export LADSPA_PATH="$DIR/usr/lib/" +export SUIL_MODULE_DIR="$DIR/usr/lib/" diff --git a/cmake/linux/apprun-hooks/vbox-hook.sh b/cmake/linux/apprun-hooks/vbox-hook.sh new file mode 100644 index 00000000000..e2ff1f6e003 --- /dev/null +++ b/cmake/linux/apprun-hooks/vbox-hook.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash +ME="$( basename "${BASH_SOURCE[0]}")" +# Workaround crash in VirtualBox when hardware rendering is enabled +if lsmod |grep vboxguest > /dev/null 2>&1; then + echo "[$ME] VirtualBox detected. Forcing libgl software rendering." >&2 + export LIBGL_ALWAYS_SOFTWARE=1; +fi diff --git a/cmake/linux/launch_lmms.sh b/cmake/linux/launch_lmms.sh deleted file mode 100644 index 131d2b92de3..00000000000 --- a/cmake/linux/launch_lmms.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/env bash -DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -export PATH="$PATH:/sbin" -if command -v carla > /dev/null 2>&1; then - CARLAPATH="$(command -v carla)" - CARLAPREFIX="${CARLAPATH%/bin*}" - echo "Carla appears to be installed on this system at $CARLAPREFIX/lib[64]/carla so we'll use it." >&2 - export LD_LIBRARY_PATH=$CARLAPREFIX/lib/carla:$CARLAPREFIX/lib64/carla:$LD_LIBRARY_PATH -else - echo "Carla does not appear to be installed. That's OK, please ignore any related library errors." >&2 -fi -export LD_LIBRARY_PATH=$DIR/usr/lib/:$DIR/usr/lib/lmms:$LD_LIBRARY_PATH -# Prevent segfault on VirualBox -if lsmod |grep vboxguest > /dev/null 2>&1; then - echo "VirtualBox detected. Forcing libgl software rendering." >&2 - export LIBGL_ALWAYS_SOFTWARE=1; -fi -if ldconfig -p | grep libjack.so.0 > /dev/null 2>&1; then - echo "Jack appears to be installed on this system, so we'll use it." >&2 -else - echo "Jack does not appear to be installed. That's OK, we'll use a dummy version instead." >&2 - export LD_LIBRARY_PATH=$DIR/usr/lib/lmms/optional:$LD_LIBRARY_PATH -fi - -# FIXME: Remove when linuxdeploy supports subfolders https://github.com/linuxdeploy/linuxdeploy/issues/305 -export LMMS_PLUGIN_DIR="$DIR/usr/lib/" -export LADSPA_PATH="$DIR/usr/lib/" -export SUIL_MODULE_DIR="$DIR/usr/lib/" - -QT_X11_NO_NATIVE_MENUBAR=1 "$DIR"/usr/bin/lmms "$@"