#!/usr/bin/env bash # Build an AppImage packaging blocker-daemon, blocker-ui and assets. set -euo pipefail ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" DIST_DIR="$ROOT_DIR/dist" APPDIR="$DIST_DIR/AppDir" PKG_DIR="$ROOT_DIR/packaging/appimage" echo "Building release binaries..." cargo build --release -p blocker-daemon -p blocker-ui echo "Preparing AppDir structure..." mkdir -p "$APPDIR" mkdir -p "$APPDIR/usr/bin" mkdir -p "$APPDIR/usr/share/applications" mkdir -p "$APPDIR/usr/share/icons/hicolor/scalable/apps" cp "$ROOT_DIR/target/release/blocker-daemon" "$APPDIR/usr/bin/" cp "$ROOT_DIR/target/release/blocker-ui" "$APPDIR/usr/bin/" cp "$PKG_DIR/AppRun" "$APPDIR/AppRun" cp "$PKG_DIR/blocker.desktop" "$APPDIR/blocker.desktop" cp "$PKG_DIR/blocker.desktop" "$APPDIR/usr/share/applications/" cp "$PKG_DIR/blocker.svg" "$APPDIR/blocker.svg" cp "$PKG_DIR/blocker.svg" "$APPDIR/usr/share/icons/hicolor/scalable/apps/" chmod +x "$APPDIR/AppRun" SQUASHFS_IMG="$DIST_DIR/appdir.squashfs" OUTPUT_APPIMAGE="$DIST_DIR/Blocker-x86_64.AppImage" RUNTIME_BIN="$PKG_DIR/bin/runtime-x86_64" rm -f "$OUTPUT_APPIMAGE" "$SQUASHFS_IMG" echo "Creating AppImage with mksquashfs..." mksquashfs "$APPDIR" "$SQUASHFS_IMG" -root-owned -noappend -comp xz if [ -f "$RUNTIME_BIN" ]; then echo "Embedding AppImage Type 2 ELF runtime..." cat "$RUNTIME_BIN" "$SQUASHFS_IMG" > "$OUTPUT_APPIMAGE" printf '\x41\x49\x02' | dd of="$OUTPUT_APPIMAGE" bs=1 seek=8 count=3 conv=notrunc 2>/dev/null rm -f "$SQUASHFS_IMG" else mv "$SQUASHFS_IMG" "$OUTPUT_APPIMAGE" fi chmod +x "$OUTPUT_APPIMAGE" echo "Built AppImage: $OUTPUT_APPIMAGE" ls -lh "$OUTPUT_APPIMAGE"