Skip to content

Commit 3da3a74

Browse files
committed
linux users, rejoice!
1 parent 99ca00e commit 3da3a74

File tree

2 files changed

+67
-49
lines changed

2 files changed

+67
-49
lines changed

.github/workflows/main.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,13 @@ jobs:
9999
libayatana-appindicator3-dev \
100100
libmpv-dev
101101
102+
- name: Set glibc compatibility
103+
run: |
104+
# Build with maximum glibc compatibility
105+
export GLIBC_COMPATIBILITY=1
106+
export CFLAGS="-march=x86-64 -mtune=generic"
107+
export CXXFLAGS="-march=x86-64 -mtune=generic"
108+
102109
- name: Install dependencies for AppImage
103110
run: |
104111
sudo apt install -y locate

linux/packaging/appimage/AppRun

Lines changed: 60 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,69 @@
11
#!/bin/bash
2-
set -e
32

4-
# Get the directory where this script is located (the AppImage root)
3+
set -u
4+
55
APPDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
6+
SATURN_BIN="${APPDIR}/Saturn"
67

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
8+
export LD_LIBRARY_PATH="${APPDIR}/lib:${APPDIR}/lib64"
9+
10+
SYSTEM_LIBDIRS=(
11+
"/usr/lib/x86_64-linux-gnu" # Debian/Ubuntu
12+
"/usr/lib64" # Fedora/RHEL/openSUSE (64-bit)
13+
"/usr/lib" # Generic (many distros)
14+
"/lib/x86_64-linux-gnu" # Debian/Ubuntu
15+
"/lib64" # Fedora/RHEL/openSUSE (64-bit)
16+
"/lib" # Generic (Arch, Alpine, etc.)
17+
"/usr/local/lib" # User-installed libraries
18+
"/usr/local/lib64" # User-installed libraries (64-bit)
19+
)
20+
21+
for libdir in "${SYSTEM_LIBDIRS[@]}"; do
22+
if [ -d "$libdir" ]; then
23+
export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${libdir}"
4324
fi
44-
45-
return 1
46-
}
25+
done
4726

48-
# Get the path to the dynamic linker
49-
LD_LINUX=$(find_ld_linux)
27+
# Preserve any existing LD_LIBRARY_PATH from the user's environment
28+
if [ -n "${LD_LIBRARY_PATH:-}" ]; then
29+
export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${LD_LIBRARY_PATH}"
30+
fi
5031

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
32+
if [ -x "$SATURN_BIN" ]; then
33+
# check if AOT library exists and is readable
34+
if [ -f "${APPDIR}/lib/libapp.so" ]; then
35+
export FLUTTER_AOT_LIBRARY="${APPDIR}/lib/libapp.so"
36+
fi
37+
exec "$SATURN_BIN" "$@"
5538
fi
5639

57-
# Execute the Saturn binary with the found dynamic linker
58-
exec "$LD_LINUX" --library-path "${APPDIR}/lib:${LD_LIBRARY_PATH}" "${APPDIR}/Saturn" "$@"
40+
# all common locations for the x86-64 dynamic linker
41+
DYNAMIC_LINKERS=(
42+
"/lib64/ld-linux-x86-64.so.2"
43+
"/lib/ld-linux-x86-64.so.2"
44+
"/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2"
45+
"/usr/lib64/ld-linux-x86-64.so.2"
46+
"/usr/lib/ld-linux-x86-64.so.2"
47+
)
48+
49+
for ld_path in "${DYNAMIC_LINKERS[@]}"; do
50+
if [ -f "$ld_path" ]; then
51+
exec "$ld_path" --library-path "${LD_LIBRARY_PATH}" "$SATURN_BIN" "$@"
52+
fi
53+
done
54+
55+
# GG
56+
echo "Error: Failed to start Saturn" >&2
57+
echo "" >&2
58+
echo "Diagnostics:" >&2
59+
echo " Saturn binary: $SATURN_BIN" >&2
60+
echo " Binary exists: $([ -f "$SATURN_BIN" ] && echo "yes" || echo "no")" >&2
61+
echo " Binary executable: $([ -x "$SATURN_BIN" ] && echo "yes" || echo "no")" >&2
62+
echo " LD_LIBRARY_PATH: ${LD_LIBRARY_PATH}" >&2
63+
echo "" >&2
64+
echo "To fix this, ensure the following packages are installed:" >&2
65+
echo " Arch Linux: pacman -S gtk3 libayatana-appindicator" >&2
66+
echo " Debian/Ubuntu: apt install libgtk-3-0 libayatana-appindicator3-1" >&2
67+
echo " Fedora/RHEL: dnf install gtk3 libayatana-appindicator" >&2
68+
echo " openSUSE: zypper install gtk3 libayatana-appindicator3" >&2
69+
exit 1

0 commit comments

Comments
 (0)