crystal/scripts/build-flatpak.sh
Jordan Bentley 7f2e862b72
Revert "refactor: Comprehensive project root cleanup and organization (#93)"
This reverts commit 95c934cb2fb0ea9ba3aa52e27857db6492a444a0.
2025-07-22 11:51:46 -04:00

51 lines
1.5 KiB
Bash
Executable File

#!/bin/bash
# Script to build Flatpak package from AppImage
# This should be run after the AppImage is built
set -e
echo "Building Flatpak package for Crystal..."
# Check if flatpak-builder is installed
if ! command -v flatpak-builder &> /dev/null; then
echo "Error: flatpak-builder is not installed"
echo "Please install it with: sudo apt install flatpak-builder"
exit 1
fi
# Check if AppImage exists
APPIMAGE=$(ls dist-electron/Crystal-*-x64.AppImage 2>/dev/null | head -n1)
if [ -z "$APPIMAGE" ]; then
echo "Error: No AppImage found in dist-electron/"
echo "Please build the AppImage first with: pnpm run build:linux"
exit 1
fi
echo "Found AppImage: $APPIMAGE"
# Install required runtime and SDK if not present
echo "Installing Flatpak runtime and SDK..."
flatpak install -y flathub org.freedesktop.Platform//23.08 org.freedesktop.Sdk//23.08 org.electronjs.Electron2.BaseApp//23.08 || true
# Update the manifest with the actual AppImage path
sed -i "s|path: dist-electron/Crystal-\*.AppImage|path: $APPIMAGE|" com.stravu.crystal.yml
# Build the Flatpak
echo "Building Flatpak..."
flatpak-builder --force-clean --repo=repo build-dir com.stravu.crystal.yml
# Create a single-file bundle
echo "Creating Flatpak bundle..."
flatpak build-bundle repo crystal.flatpak com.stravu.crystal
# Restore the manifest
git checkout com.stravu.crystal.yml
echo "Flatpak bundle created: crystal.flatpak"
echo ""
echo "To install locally:"
echo " flatpak install crystal.flatpak"
echo ""
echo "To run:"
echo " flatpak run com.stravu.crystal"