Skip to content

Commit c3b1981

Browse files
committed
trial 'n error
1 parent 842b6e9 commit c3b1981

File tree

2 files changed

+101
-0
lines changed

2 files changed

+101
-0
lines changed

.github/workflows/main.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,49 @@ jobs:
112112
- name: Build and release
113113
run: fastforge release --name linux
114114

115+
- name: Replace AppRun
116+
run: |
117+
# Find the AppImage file
118+
APPIMAGE_FILE=$(find dist -name "*.AppImage" -type f | head -1)
119+
if [ -z "$APPIMAGE_FILE" ]; then
120+
echo "No AppImage found, skipping AppRun replacement"
121+
exit 0
122+
fi
123+
124+
# Convert to absolute path
125+
APPIMAGE_FILE="$(cd "$(dirname "$APPIMAGE_FILE")" && pwd)/$(basename "$APPIMAGE_FILE")"
126+
echo "Found AppImage: $APPIMAGE_FILE"
127+
128+
# Make AppImage executable
129+
chmod +x "$APPIMAGE_FILE"
130+
131+
# Extract the AppImage
132+
APPIMAGE_DIR=$(mktemp -d)
133+
echo "Extracting to: $APPIMAGE_DIR"
134+
cd "$APPIMAGE_DIR"
135+
"$APPIMAGE_FILE" --appimage-extract
136+
137+
# Check if extraction was successful
138+
if [ ! -d squashfs-root ]; then
139+
echo "Error: AppImage extraction failed"
140+
exit 1
141+
fi
142+
143+
# Replace the AppRun script with our distro-agnostic version
144+
if [ -f squashfs-root/AppRun ]; then
145+
cp "$GITHUB_WORKSPACE/linux/packaging/appimage/AppRun" squashfs-root/AppRun
146+
chmod +x squashfs-root/AppRun
147+
echo "Replaced AppRun script"
148+
else
149+
echo "Warning: AppRun not found in extracted AppImage"
150+
fi
151+
152+
# Rebuild the AppImage
153+
cd "$GITHUB_WORKSPACE"
154+
appimagetool -n "$APPIMAGE_DIR/squashfs-root" "$APPIMAGE_FILE"
155+
rm -rf "$APPIMAGE_DIR"
156+
echo "AppImage rebuilt with custom AppRun"
157+
115158
- name: Upload build artifacts
116159
uses: actions/upload-artifact@v4
117160
with:

linux/packaging/appimage/AppRun

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
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

Comments
 (0)