-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild-appimage.sh
More file actions
executable file
·127 lines (104 loc) · 4.68 KB
/
build-appimage.sh
File metadata and controls
executable file
·127 lines (104 loc) · 4.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#!/usr/bin/env bash
set -euo pipefail
# G-Helper Linux — AppImage Builder
# Packages the dist/ output into a portable AppImage.
#
# Prerequisites:
# ./build.sh (produces dist/ghelper + native libs)
#
# Usage:
# ./build-appimage.sh
#
# Output:
# GHelper-x86_64.AppImage
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
DIST_DIR="$SCRIPT_DIR/dist"
INSTALL_DIR="$SCRIPT_DIR/install"
APPDIR="$SCRIPT_DIR/GHelper.AppDir"
OUTPUT="$SCRIPT_DIR/GHelper-x86_64.AppImage"
APPIMAGETOOL="$SCRIPT_DIR/appimagetool"
echo "=== G-Helper AppImage Build ==="
echo ""
# ── Verify dist/ exists ───────────────────────────────────────────────────────
if [[ ! -f "$DIST_DIR/ghelper" ]]; then
echo "ERROR: dist/ghelper not found."
echo "Run ./build.sh first to compile the binary."
exit 1
fi
for lib in libSkiaSharp.so libHarfBuzzSharp.so; do
if [[ ! -f "$DIST_DIR/$lib" ]]; then
echo "ERROR: dist/$lib not found."
echo "Run ./build.sh first — native libs should be in dist/."
exit 1
fi
done
# ── Download appimagetool if needed ───────────────────────────────────────────
if [[ ! -x "$APPIMAGETOOL" ]]; then
echo "[1/4] Downloading appimagetool..."
curl -fsSL "https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-x86_64.AppImage" \
-o "$APPIMAGETOOL"
chmod +x "$APPIMAGETOOL"
else
echo "[1/4] appimagetool already present."
fi
# ── Assemble AppDir ──────────────────────────────────────────────────────────
echo "[2/4] Assembling AppDir..."
rm -rf "$APPDIR"
mkdir -p "$APPDIR/usr/bin"
mkdir -p "$APPDIR/usr/lib"
# Binary + native libs (next to binary so NativeLibExtractor Strategy 1 finds them)
cp "$DIST_DIR/ghelper" "$APPDIR/usr/bin/"
cp "$DIST_DIR/libSkiaSharp.so" "$APPDIR/usr/bin/"
cp "$DIST_DIR/libHarfBuzzSharp.so" "$APPDIR/usr/bin/"
chmod +x "$APPDIR/usr/bin/ghelper"
# Desktop entry (required by appimagetool at AppDir root)
cp "$INSTALL_DIR/ghelper.desktop" "$APPDIR/ghelper.desktop"
# Icon (required by appimagetool at AppDir root, matching Icon= in .desktop)
if [[ -f "$INSTALL_DIR/ghelper.png" ]]; then
cp "$INSTALL_DIR/ghelper.png" "$APPDIR/ghelper.png"
else
echo "WARNING: install/ghelper.png not found. Generating from favicon.ico..."
if command -v convert &>/dev/null; then
convert "$SCRIPT_DIR/src/UI/Assets/favicon.ico[2]" "$APPDIR/ghelper.png"
else
echo "ERROR: ImageMagick not found and install/ghelper.png missing."
echo "Install ImageMagick or create install/ghelper.png manually."
exit 1
fi
fi
# AppRun — entry point that appimagetool expects
cat > "$APPDIR/AppRun" << 'APPRUN'
#!/bin/bash
HERE="$(dirname "$(readlink -f "$0")")"
exec "$HERE/usr/bin/ghelper" "$@"
APPRUN
chmod +x "$APPDIR/AppRun"
# ── Build AppImage ────────────────────────────────────────────────────────────
echo "[3/4] Building AppImage..."
# ARCH must be set for appimagetool
export ARCH=x86_64
# appimagetool itself is an AppImage — if FUSE is not available, extract and run
if "$APPIMAGETOOL" --version &>/dev/null 2>&1; then
"$APPIMAGETOOL" "$APPDIR" "$OUTPUT"
else
echo " (FUSE not available, using --appimage-extract-and-run)"
"$APPIMAGETOOL" --appimage-extract-and-run "$APPDIR" "$OUTPUT"
fi
# ── Cleanup ───────────────────────────────────────────────────────────────────
echo "[4/4] Cleaning up..."
rm -rf "$APPDIR"
# ── Summary ───────────────────────────────────────────────────────────────────
APPIMAGE_SIZE=$(du -sh "$OUTPUT" | cut -f1)
APPIMAGE_NAME=$(basename "$OUTPUT")
echo ""
echo "=== AppImage Build Complete ==="
echo " Output: $OUTPUT"
echo " Size: $APPIMAGE_SIZE"
echo ""
echo "Run it:"
echo " chmod +x $APPIMAGE_NAME"
echo " ./$APPIMAGE_NAME"
echo ""
echo "Note: udev rules are still required for hardware access."
echo " sudo curl -sL https://raw.githubusercontent.com/utajum/g-helper-linux/master/install/90-ghelper.rules -o /etc/udev/rules.d/90-ghelper.rules"
echo " sudo udevadm control --reload-rules && sudo udevadm trigger"