|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# Build TIC-80 AppImage for Linux |
| 4 | + |
| 5 | +set -e |
| 6 | + |
| 7 | +# Check if we're on Linux |
| 8 | +if [[ "$OSTYPE" != "linux-gnu"* ]]; then |
| 9 | + echo "This script must be run on Linux to build AppImage" |
| 10 | + exit 1 |
| 11 | +fi |
| 12 | + |
| 13 | +# Check if tic80 binary exists |
| 14 | +if [ ! -f "build/bin/tic80" ]; then |
| 15 | + echo "Error: TIC-80 binary not found at build/bin/tic80" |
| 16 | + echo "Please build TIC-80 first with: mkdir build && cd build && cmake .. && make" |
| 17 | + exit 1 |
| 18 | +fi |
| 19 | + |
| 20 | +# Create AppDir structure |
| 21 | +APPDIR="TIC-80.AppDir" |
| 22 | +rm -rf "$APPDIR" |
| 23 | +mkdir -p "$APPDIR/usr/bin" |
| 24 | +mkdir -p "$APPDIR/usr/lib" |
| 25 | +mkdir -p "$APPDIR/usr/share/applications" |
| 26 | +mkdir -p "$APPDIR/usr/share/icons/hicolor/256x256/apps" |
| 27 | +mkdir -p "$APPDIR/usr/share/metainfo" |
| 28 | + |
| 29 | +# Copy binary |
| 30 | +cp build/bin/tic80 "$APPDIR/usr/bin/" |
| 31 | + |
| 32 | +# Copy desktop file |
| 33 | +sed 's|Icon=tic80|Icon=tic80.png|' build/linux/tic80.desktop.in > "$APPDIR/usr/share/applications/tic80.desktop" |
| 34 | + |
| 35 | +# Copy icon |
| 36 | +cp build/linux/tic80.png "$APPDIR/usr/share/icons/hicolor/256x256/apps/" |
| 37 | + |
| 38 | +# Configure and copy metainfo |
| 39 | +sed -e "s/@PROJECT_VERSION@/$(grep VERSION_MAJOR cmake/version.cmake | cut -d'"' -f2).$(grep VERSION_MINOR cmake/version.cmake | cut -d'"' -f2).$(grep VERSION_REVISION cmake/version.cmake | cut -d'"' -f2)/g" \ |
| 40 | + -e "s/@VERSION_YEAR@/$(date +%Y)/g" \ |
| 41 | + -e "s/@VERSION_MONTH@/$(date +%m)/g" \ |
| 42 | + -e "s/@VERSION_DAY@/$(date +%d)/g" \ |
| 43 | + build/linux/com.tic80.TIC_80.metainfo.xml.in > "$APPDIR/usr/share/metainfo/com.tic80.TIC_80.metainfo.xml" |
| 44 | + |
| 45 | +# Create AppRun script |
| 46 | +cat > "$APPDIR/AppRun" << 'EOF' |
| 47 | +#!/bin/bash |
| 48 | +HERE="$(dirname "$(readlink -f "${0}")")" |
| 49 | +export PATH="${HERE}/usr/bin:${PATH}" |
| 50 | +export LD_LIBRARY_PATH="${HERE}/usr/lib:${LD_LIBRARY_PATH}" |
| 51 | +exec "${HERE}/usr/bin/tic80" "$@" |
| 52 | +EOF |
| 53 | +chmod +x "$APPDIR/AppRun" |
| 54 | + |
| 55 | +# Copy required libraries (if any - TIC-80 should be statically linked) |
| 56 | +# ldd build/bin/tic80 | grep "=>" | awk '{print $3}' | xargs -I {} cp {} "$APPDIR/usr/lib/" 2>/dev/null || true |
| 57 | + |
| 58 | +# Download appimagetool if not present |
| 59 | +if [ ! -f "appimagetool.AppImage" ]; then |
| 60 | + echo "Downloading appimagetool..." |
| 61 | + wget -O appimagetool.AppImage https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage |
| 62 | + chmod +x appimagetool.AppImage |
| 63 | +fi |
| 64 | + |
| 65 | +# Create AppImage |
| 66 | +echo "Creating AppImage..." |
| 67 | +./appimagetool.AppImage "$APPDIR" TIC-80.AppImage |
| 68 | + |
| 69 | +echo "AppImage created: TIC-80.AppImage" |
0 commit comments