Make apprun-hooks POSIX compliant (#8121)

Remove bash-ishms, make apprun-hooks POSIX compliant per #8105
This commit is contained in:
Tres Finocchiaro
2025-11-11 13:00:10 -05:00
committed by GitHub
parent 478f5345dd
commit db4523aa5d
7 changed files with 26 additions and 37 deletions

View File

@@ -1,6 +1,6 @@
# AppRun Hooks
Scripts placed in this directory will automatically be bundled into AppImages
Scripts placed in this directory will automatically be bundled into linuxdeploy AppImages
(e.g. `LMMS.AppDir/apprun-hooks`) and executed immediately before lmms.
Quoting:

20
cmake/linux/apprun-hooks/carla-hook.sh Normal file → Executable file
View File

@@ -1,10 +1,8 @@
#!/usr/bin/env bash
#!/bin/sh
# 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")
KNOWN_LOCATIONS="lib lib64"
unset CARLA_LIB_FILE
# Check for carla at "known" locations
@@ -13,31 +11,31 @@ if command -v carla > /dev/null 2>&1; then
CARLA_PREFIX="${CARLA_PATH%/bin*}"
# Look for libcarla_native-plugin.so in adjacent lib directory
for lib in "${KNOWN_LOCATIONS[@]}"; do
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
echo "[${0##*/}] 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, we'll remove it from the plugin listing." >&2
echo "[${0##*/}] Carla does not appear to be installed, we'll remove it from the plugin listing." >&2
export "LMMS_EXCLUDE_PLUGINS=libcarla,${LMMS_EXCLUDE_PLUGINS}"
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")
KNOWN_CONFLICTS="libgobject-2.0.so.0"
if [ -n "$CARLA_LIB_FILE" ]; then
for conflict in "${KNOWN_CONFLICTS[@]}"; do
for conflict in $KNOWN_CONFLICTS; do
# Only prepend LD_PRELOAD if we bundle the same version
if [ -e "$DIR/usr/lib/$conflict" ]; then
if [ -e "$APPDIR/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
echo "[${0##*/}] Preferring the system's \"$conflict\" over the version bundled." >&2
export LD_PRELOAD="$conflict_sys:$LD_PRELOAD"
fi
fi

16
cmake/linux/apprun-hooks/jack-hook.sh Normal file → Executable file
View File

@@ -1,15 +1,9 @@
#!/usr/bin/env bash
#!/bin/sh
# Workaround crash when jack is missing by providing a dummy version
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )"
ME="$( basename "${BASH_SOURCE[0]}")"
# Set language to English
export LC_ALL=C
if ldd "$DIR/usr/bin/lmms" |grep "libjack.so" |grep "not found" > /dev/null 2>&1; then
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/jack:$LD_LIBRARY_PATH"
if LC_ALL=C ldd "$APPDIR/usr/bin/lmms" |grep "libjack.so" |grep "not found" > /dev/null 2>&1; then
echo "[${0##*/}] Jack does not appear to be installed. That's OK, we'll use a dummy version instead." >&2
export LD_LIBRARY_PATH="$APPDIR/usr/lib/jack:$LD_LIBRARY_PATH"
else
echo "[$ME] Jack appears to be installed on this system, so we'll use it." >&2
echo "[${0##*/}] Jack appears to be installed on this system, so we'll use it." >&2
fi
# Restore language
unset LC_ALL

2
cmake/linux/apprun-hooks/unity-hook.sh Normal file → Executable file
View File

@@ -1,4 +1,4 @@
#!/usr/bin/env bash
#!/bin/sh
# Workaround Unity desktop menubar integration
# - Unity's menubar relocation breaks Qt's MDI window handling in Linux

5
cmake/linux/apprun-hooks/usr-lib-hooks.sh Normal file → Executable file
View File

@@ -1,5 +1,4 @@
#!/usr/bin/env bash
#!/bin/sh
# Paths for plugin systems to pick-up
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )"
export SUIL_MODULE_DIR="$DIR/usr/lib/suil-0/" # See also ${SUIL_MODULES_TARGET}
export SUIL_MODULE_DIR="$APPDIR/usr/lib/suil-0/" # See also ${SUIL_MODULES_TARGET}

6
cmake/linux/apprun-hooks/vbox-hook.sh Normal file → Executable file
View File

@@ -1,7 +1,7 @@
#!/usr/bin/env bash
ME="$( basename "${BASH_SOURCE[0]}")"
#!/bin/sh
# 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
echo "[${0##*/}] VirtualBox detected. Forcing libgl software rendering." >&2
export LIBGL_ALWAYS_SOFTWARE=1;
fi

12
cmake/linux/apprun-hooks/wayland-hook.sh Normal file → Executable file
View File

@@ -1,12 +1,10 @@
#!/usr/bin/env bash
# Configure QPlatform Abstraction (qpa) to prefer X-Protocol C-Bindings (xcb) over Wayland
ME="$( basename "${BASH_SOURCE[0]}")"
#!/bin/sh
# Configure QPlatform Abstraction (qpa) to prefer X-Protocol C-Bindings (xcb) over Wayland
if [ -n "$QT_QPA_PLATFORM" ]; then
echo "[$ME] QT_QPA_PLATFORM=\"$QT_QPA_PLATFORM\" was provided, using." >&2
echo "[${0##*/}] QT_QPA_PLATFORM=\"$QT_QPA_PLATFORM\" was provided, using." >&2
else
export QT_QPA_PLATFORM="xcb"
echo "[$ME] Defaulting to QT_QPA_PLATFORM=\"$QT_QPA_PLATFORM\" for compatibility purposes." >&2
echo "[$ME] To force wayland, set QT_QPA_PLATFORM=\"wayland\" or call using \"-platform wayland\"." >&2
echo "[${0##*/}] Defaulting to QT_QPA_PLATFORM=\"$QT_QPA_PLATFORM\" for compatibility purposes." >&2
echo "[${0##*/}] To force wayland, set QT_QPA_PLATFORM=\"wayland\" or call using \"-platform wayland\"." >&2
fi