diff --git a/packaging/appimage/AppRun b/packaging/appimage/AppRun index 898e71a..4a7e705 100755 --- a/packaging/appimage/AppRun +++ b/packaging/appimage/AppRun @@ -4,14 +4,29 @@ APPDIR="$(dirname "$(readlink -f "$0")")" export WORM_UI_ROOT="${WORM_UI_ROOT:-$APPDIR/usr/share/worm/ui}" export WORM_APP_ICON="${WORM_APP_ICON:-$APPDIR/usr/share/icons/hicolor/256x256/apps/worm.png}" +WEBKIT_BUNDLE_DIR="$APPDIR/usr/lib/x86_64-linux-gnu/webkit2gtk-4.1" +if [ -d "$WEBKIT_BUNDLE_DIR" ]; then + export WEBKIT_EXEC_PATH="${WEBKIT_EXEC_PATH:-$WEBKIT_BUNDLE_DIR}" + export WEBKIT_INJECTED_BUNDLE_PATH="${WEBKIT_INJECTED_BUNDLE_PATH:-$WEBKIT_BUNDLE_DIR/injected-bundle}" +fi + +run_ui() { + cd "$APPDIR" || exit 1 + exec "$APPDIR/usr/bin/worm" ui "$@" +} + case "${1:-}" in "" ) - exec "$APPDIR/usr/bin/worm" ui + run_ui + ;; + ui ) + shift + run_ui "$@" ;; - settings-default|hash|disk-list|disk-list-helper|image-helper|ram-helper|mount-helper|disk-size|verify|remote-disks|remote-image|remote-tool-check|ram-status|wireguard-config|ui|ui-browser ) + settings-default|hash|disk-list|disk-list-helper|image-helper|ram-helper|mount-helper|disk-size|verify|remote-disks|remote-image|remote-tool-check|ram-status|wireguard-config|ui-browser ) exec "$APPDIR/usr/bin/worm" "$@" ;; * ) - exec "$APPDIR/usr/bin/worm" ui "$@" + run_ui "$@" ;; esac diff --git a/scripts/build-appimage.sh b/scripts/build-appimage.sh index eceff84..111c03a 100755 --- a/scripts/build-appimage.sh +++ b/scripts/build-appimage.sh @@ -48,6 +48,16 @@ cp -a "$ROOT_DIR/ui/." "$APPDIR/usr/share/worm/ui/" install -m 755 "$ROOT_DIR/packaging/appimage/AppRun" "$APPDIR/AppRun" install -m 644 "$ROOT_DIR/packaging/appimage/worm.desktop" "$APPDIR/worm.desktop" install -m 644 "$ROOT_DIR/packaging/appimage/worm.desktop" "$APPDIR/usr/share/applications/worm.desktop" + +WEBKIT_BUNDLE_DIR="${WEBKIT_BUNDLE_DIR:-/usr/lib/x86_64-linux-gnu/webkit2gtk-4.1}" +if [[ -d "$WEBKIT_BUNDLE_DIR" ]]; then + mkdir -p "$APPDIR/usr/lib/x86_64-linux-gnu" + cp -a "$WEBKIT_BUNDLE_DIR" "$APPDIR/usr/lib/x86_64-linux-gnu/" +else + echo "WebKitGTK helper directory not found: $WEBKIT_BUNDLE_DIR" >&2 + exit 1 +fi + if command -v magick >/dev/null 2>&1; then magick "$ROOT_DIR/ui/assets/logo/icon.png" -resize 256x256 "$APPDIR/usr/share/icons/hicolor/256x256/apps/worm.png" elif command -v convert >/dev/null 2>&1; then @@ -60,9 +70,21 @@ install -m 644 "$APPDIR/usr/share/icons/hicolor/256x256/apps/worm.png" "$APPDIR/ NO_STRIP="${NO_STRIP:-1}" STRIP="${STRIP:-/usr/bin/strip}" OUTPUT="$APPIMAGE" "$LINUXDEPLOY_RUN" \ --appdir "$APPDIR" \ --executable "$APPDIR/usr/bin/worm" \ + --deploy-deps-only "$APPDIR/usr/lib/x86_64-linux-gnu/webkit2gtk-4.1" \ --desktop-file "$APPDIR/worm.desktop" \ --icon-file "$APPDIR/worm.png" \ --custom-apprun "$ROOT_DIR/packaging/appimage/AppRun" + +WEBKIT_LIB="$APPDIR/usr/lib/libwebkit2gtk-4.1.so.0" +if [[ -f "$WEBKIT_LIB" ]]; then + perl -0pi -e \ + 's#/usr/lib/x86_64-linux-gnu/webkit2gtk-4\.1/injected-bundle/#usr/lib/x86_64-linux-gnu/webkit2gtk-4.1/injected-bundle/\x00#g; s#/usr/lib/x86_64-linux-gnu/webkit2gtk-4\.1#usr/lib/x86_64-linux-gnu/webkit2gtk-4.1\x00#g' \ + "$WEBKIT_LIB" +else + echo "WebKitGTK library not found in AppDir: $WEBKIT_LIB" >&2 + exit 1 +fi + "$APPIMAGETOOL" --runtime-file "$RUNTIME_FILE" "$APPDIR" "$APPIMAGE" chmod +x "$APPIMAGE" echo "$APPIMAGE"