Skip to content
Snippets Groups Projects

_v2-entry-point: Support custom LD_LIBRARY_PATH from game launch options

Merged Ludovico de Nittis requested to merge wip/denittis/t24167 into master
+ 43
0
@@ -142,6 +142,49 @@ if [ -z "${STEAM_COMPAT_SESSION_ID-}" ]; then
@@ -142,6 +142,49 @@ if [ -z "${STEAM_COMPAT_SESSION_ID-}" ]; then
is_main=yes
is_main=yes
fi
fi
 
# At this point $LD_LIBRARY_PATH might
 
# 1. be equal to $STEAM_RUNTIME_LIBRARY_PATH (e.g. a game without
 
# any special launch options).
 
# 2. contain all the entries of $STEAM_RUNTIME_LIBRARY_PATH, plus eventually
 
# any additional paths from the game launch options (e.g. a game launched
 
# with "LD_LIBRARY_PATH=/my_game_path:${LD_LIBRARY_PATH} %command%")
 
# 3. contain just new entries from the game launch options (e.g. a game
 
# launched with "LD_LIBRARY_PATH=/my_game_path %command%")
 
# 4. being unset or empty (e.g. a game launched with
 
# "LD_LIBRARY_PATH="" %command%")
 
#
 
# We extract all the entries from $LD_LIBRARY_PATH that are not under the
 
# $STEAM_RUNTIME paths. In this way we should end up with a list of paths
 
# that are from the system $LD_LIBRARY_PATH, the system "ldconfig" and the
 
# manually set $LD_LIBRARY_PATH paths from the game launch options.
 
case "${STEAM_RUNTIME-}" in
 
(/*)
 
oldIFS="$IFS"
 
IFS=:
 
paths=
 
 
for path in ${LD_LIBRARY_PATH-}; do
 
if [ "${path}" == "${STEAM_RUNTIME}" ]; then
 
# path is exactly the ${STEAM_RUNTIME}; ignore
 
continue
 
elif [ "${path#${STEAM_RUNTIME}/}" != "${path}" ]; then
 
# path is ${STEAM_RUNTIME}/...; ignore
 
continue
 
else
 
# keep it (note that we discard the extra leading ":" later)
 
paths="${paths}:${path}"
 
fi
 
done
 
 
IFS="$oldIFS"
 
export PRESSURE_VESSEL_APP_LD_LIBRARY_PATH="${paths#:}"
 
;;
 
(*)
 
# use LD_LIBRARY_PATH as-is
 
export PRESSURE_VESSEL_APP_LD_LIBRARY_PATH="${LD_LIBRARY_PATH-}"
 
;;
 
esac
 
unset LD_LIBRARY_PATH
unset LD_LIBRARY_PATH
unset STEAM_RUNTIME
unset STEAM_RUNTIME
Loading