Files
UltraGrid/data/scripts/Linux-AppImage/scripts/preload.sh
Martin Pulec b9ce913b9d AppImage: include libOpenGL.so.0 fallback
Currently Ubuntu 25.10 live DVD (ubuntu-25.10-desktop-amd64.iso)
does not include the library, preventing the GUI from being
run.  On the other hand, if used unconditionally, it causes
the warning (even in the U25.10) for which it was removed:
<https://github.com/linuxdeploy/linuxdeploy/issues/152>

So preload the library if is in the system and use the bundled just as
a fallback.
2025-11-25 09:33:09 +01:00

38 lines
1.0 KiB
Bash

# shellcheck shell=sh
get_loader() {
loaders='/lib64/ld-linux-*so* /lib/ld-linux-*so* /lib*/ld-linux-*so*'
for n in $loaders; do
for m in $n; do
if [ -x "$m" ]; then
echo "$m"
return
fi
done
done
}
# @param $1 UG library name
# @param $2 system preloaded library pattern
#
set_ld_preload() {
ug_module_lib=$AI_LIB_PATH/ultragrid/$1
set_ld_preload_exe "$ug_module_lib" "$2"
}
set_ld_preload_exe() {
bin=${1?}
if [ ! -f "$bin" ]; then
return
fi
loader=$(get_loader)
if [ ! -x "$loader" ]; then
return
fi
system_lib=$(LD_TRACE_LOADED_OBJECTS=1 $loader "$bin" | grep "$2" |
grep -v 'not found' | awk '{print $3}')
if [ -n "$system_lib" ]; then
export LD_PRELOAD="$system_lib"${LD_PRELOAD:+":$LD_PRELOAD"}
fi
}