|
| 1 | +#!/bin/bash |
| 2 | +set -e |
| 3 | + |
| 4 | +# Get the directory where this script is located (the AppImage root) |
| 5 | +APPDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" |
| 6 | + |
| 7 | +# Export library path to include bundled libraries |
| 8 | +export LD_LIBRARY_PATH="${APPDIR}/lib:${LD_LIBRARY_PATH}" |
| 9 | + |
| 10 | +# Try to find the dynamic linker in common locations |
| 11 | +find_ld_linux() { |
| 12 | + local ld_name="ld-linux-x86-64.so.2" |
| 13 | + |
| 14 | + # Check common locations in order of preference |
| 15 | + for path in \ |
| 16 | + "/lib64/${ld_name}" \ |
| 17 | + "/lib/${ld_name}" \ |
| 18 | + "/lib/x86_64-linux-gnu/${ld_name}" \ |
| 19 | + "/usr/lib64/${ld_name}" \ |
| 20 | + "/usr/lib/${ld_name}"; do |
| 21 | + if [ -f "$path" ]; then |
| 22 | + echo "$path" |
| 23 | + return 0 |
| 24 | + fi |
| 25 | + done |
| 26 | + |
| 27 | + # If not found in standard locations, try using ldd to find it |
| 28 | + if command -v ldd &> /dev/null; then |
| 29 | + local ldd_output=$(ldd /bin/bash 2>/dev/null | grep "ld-linux" | awk '{print $1}') |
| 30 | + if [ -n "$ldd_output" ] && [ -f "$ldd_output" ]; then |
| 31 | + echo "$ldd_output" |
| 32 | + return 0 |
| 33 | + fi |
| 34 | + fi |
| 35 | + |
| 36 | + # If still not found, try using ldconfig |
| 37 | + if command -v ldconfig &> /dev/null; then |
| 38 | + local ldconfig_output=$(ldconfig -p 2>/dev/null | grep "ld-linux-x86-64.so.2" | awk '{print $NF}') |
| 39 | + if [ -n "$ldconfig_output" ] && [ -f "$ldconfig_output" ]; then |
| 40 | + echo "$ldconfig_output" |
| 41 | + return 0 |
| 42 | + fi |
| 43 | + fi |
| 44 | + |
| 45 | + return 1 |
| 46 | +} |
| 47 | + |
| 48 | +# Get the path to the dynamic linker |
| 49 | +LD_LINUX=$(find_ld_linux) |
| 50 | + |
| 51 | +if [ -z "$LD_LINUX" ]; then |
| 52 | + echo "Error: Could not find dynamic linker (ld-linux-x86-64.so.2)" >&2 |
| 53 | + echo "Tried common locations: /lib64, /lib, /lib/x86_64-linux-gnu, /usr/lib64, /usr/lib" >&2 |
| 54 | + exit 1 |
| 55 | +fi |
| 56 | + |
| 57 | +# Execute the Saturn binary with the found dynamic linker |
| 58 | +exec "$LD_LINUX" --library-path "${APPDIR}/lib:${LD_LIBRARY_PATH}" "${APPDIR}/Saturn" "$@" |
0 commit comments