diff --git a/.github/workflows/build_release.yml b/.github/workflows/build_release.yml index 71417dd2..67380fb5 100644 --- a/.github/workflows/build_release.yml +++ b/.github/workflows/build_release.yml @@ -164,9 +164,6 @@ jobs: - name: Create installers for Windows run: ${{ github.workspace }}/ci/create_win_installer.sh - - name: Set up QEMU integration for Docker - run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes - - name: Create AppImage (x86_64) env: ARCH: x86_64 diff --git a/ci/bundle_appimage.sh b/ci/bundle_appimage.sh deleted file mode 100755 index 3f51677c..00000000 --- a/ci/bundle_appimage.sh +++ /dev/null @@ -1,140 +0,0 @@ -#!/bin/bash - -fail_msg() { - echo "$1" - exit 1 -} - -# -# This script should be run in, or with the working directory set to, the root project directory -# - -pushd "$(readlink -f "$(dirname "${BASH_SOURCE[0]}")"/..)" > /dev/null - -# grab default variables -source ./packaging/vars - -[ -n "$NAME" ] || fail_msg "ERROR: Name isn't specified!" -[ -n "$ID" ] || fail_msg "ERROR: ID isn't specified!" -[ -n "$RIDS" ] || fail_msg "ERROR: Runtime IDs not specified!" -[ -n "$GITHUB_ORG" ] || fail_msg "ERROR: GitHub Project not specified!" - -PUBLISH_DIR="$(readlink -f ${PUBLISH_DIR:="./build/publish"})" - -[ -n "$PUBLISH_DIR" ] || fail_msg "ERROR: Publish directory isn't set!" -[ -d "$PUBLISH_DIR" ] || fail_msg "ERROR: Publish location isn't a directory!" - -OUTPUT_DIR="$(readlink -f ${OUTPUT_DIR:="./build/packages"})" - -[ -n "$OUTPUT_DIR" ] || fail_msg "ERROR: Output directory isn't set!" -[ -d "$OUTPUT_DIR" ] || fail_msg "ERROR: Output location isn't a directory!" - -# there should already be a usable binary, so just figure out what we should use -DOTNET_ARCH= - -case "$ARCH" in - "x86_64" | "x64") - DOTNET_ARCH="x64" - ;; - "aarch64" | "arm64") - DOTNET_ARCH="arm64" - ;; - *) - fail_msg "Unknown arch! Aborting!" - ;; -esac - -[ -n "$DOTNET_ARCH" ] || fail_msg "ERROR: No arch specified!" - -# make sure needed archive exists (should have checked for this already!!) -[ -f "$OUTPUT_DIR/Linux_$DOTNET_ARCH.tar.gz" ] || fail_msg "ERROR: Linux $DOTNET_ARCH archive not found!" - - -# VERSION="$(grep string\ AppVersion -rI $NAME | cut -d \" -f 2)" # this will surely come back to bite me -VERSION="${VERSION:="0.0.0"}" - -BUILD_DIR="/appimage" -APPDIR="$BUILD_DIR/AppDir" - -FILE_ROOT="./packaging/linux" - -APPRUN_FILE="AppRun" -METAINFO_FILE="knossos.metainfo.xml.in" -DESKTOP_FILE="knossos.desktop.in" - -ICON_SIZES="512 256 128 96 64 48" # must include 256x256 at a minimum -ICON_FILE="knossos" - -APPIMAGE_TOOL_URL="https://github.com/AppImage/AppImageKit/releases/download/13/appimagetool-$ARCH.AppImage" - -UPDATE_SCHEME="gh-releases-zsync|$GITHUB_ORG|$NAME|latest|$NAME-*$ARCH.AppImage.zsync" - - -# install required packages: -# for this script: wget, envsubst (from gettext) -# for appimagetool: zsync, file, appstream, gpg -# for docker arm64 multiarch workaround: qemu-user-static -export DEBIAN_FRONTEND=noninteractive -apt update && apt install -y wget gettext-base zsync file appstream gpg qemu-user-static - - -# grab appimagetool -mkdir -p "$BUILD_DIR" -wget -O "$BUILD_DIR/appimagetool" "$APPIMAGE_TOOL_URL" || fail_msg "ERROR: Failed to get appimagetool!" -chmod +x "$BUILD_DIR/appimagetool" - - -# configure templates -export _NAME="$NAME" -export _ID="$ID" -export _VERSION="$VERSION" - -envsubst < "$FILE_ROOT/$METAINFO_FILE" > "$BUILD_DIR/$ID.appdata.xml" -envsubst < "$FILE_ROOT/$DESKTOP_FILE" > "$BUILD_DIR/$ID.desktop" - -unset _NAME _ID _VERSION - - -# create and populate AppDir -if [ -d "$APPDIR" ] -then - rm -Rf "$APPDIR" -fi - -install -d "$APPDIR" -install -m 755 "$FILE_ROOT/$APPRUN_FILE" "$APPDIR" - -install -d "$APPDIR/usr/bin" -tar -xzvf "$OUTPUT_DIR/Linux_$DOTNET_ARCH.tar.gz" -C "$APPDIR/usr/bin" -chmod +x "$APPDIR/usr/bin/$NAME" - -install -d "$APPDIR/usr/share/applications" -install -m 644 "$BUILD_DIR/$ID.desktop" "$APPDIR/usr/share/applications" - -install -d "$APPDIR/usr/share/metainfo" -install -m 644 "$BUILD_DIR/$ID.appdata.xml" "$APPDIR/usr/share/metainfo" - -for size in $ICON_SIZES; do - install -d "$APPDIR/usr/share/icons/hicolor/${size}x${size}/apps" - install -m 644 "$FILE_ROOT/$ICON_FILE-$size.png" "$APPDIR/usr/share/icons/hicolor/${size}x${size}/apps/$ID.png" -done - -# provide symlinks to .desktop and app icon in root as required by AppImage spec -ln -s "usr/share/applications/$ID.desktop" "$APPDIR" -ln -s "usr/share/icons/hicolor/256x256/apps/$ID.png" "$APPDIR" - - -# -# create AppImage -# - -# can't use fuse in container, so work around it -export APPIMAGE_EXTRACT_AND_RUN=1 - -# arm64 appimagetool doesn't run properly in qemu multiarch so work around it -[ "$DOTNET_ARCH" = "arm64" ] && LAUNCHER="qemu-aarch64-static" || LAUNCHER="" - -$LAUNCHER "$BUILD_DIR/appimagetool" -u "$UPDATE_SCHEME" "$APPDIR" "$OUTPUT_DIR/$NAME-$ARCH.AppImage" - -# zsync file is saved to current directory so move it to proper place -[ -f "$NAME-$ARCH.AppImage.zsync" ] && mv "$NAME-$ARCH.AppImage.zsync" "$OUTPUT_DIR" \ No newline at end of file diff --git a/ci/create_appimage.sh b/ci/create_appimage.sh index 3c01fab8..cf4551e4 100755 --- a/ci/create_appimage.sh +++ b/ci/create_appimage.sh @@ -9,8 +9,7 @@ fail_msg() { # This script should be run in, or with the working directory set to, the root project directory # -REPO_ROOT="$(readlink -f "$(dirname "${BASH_SOURCE[0]}")"/..)" -pushd "$REPO_ROOT" > /dev/null +pushd "$(readlink -f "$(dirname "${BASH_SOURCE[0]}")"/..)" > /dev/null # grab default variables source ./packaging/vars @@ -18,6 +17,7 @@ source ./packaging/vars [ -n "$NAME" ] || fail_msg "ERROR: Name isn't specified!" [ -n "$ID" ] || fail_msg "ERROR: ID isn't specified!" [ -n "$RIDS" ] || fail_msg "ERROR: Runtime IDs not specified!" +[ -n "$GITHUB_ORG" ] || fail_msg "ERROR: GitHub Project not specified!" PUBLISH_DIR="$(readlink -f ${PUBLISH_DIR:="./build/publish"})" @@ -29,35 +29,98 @@ OUTPUT_DIR="$(readlink -f ${OUTPUT_DIR:="./build/packages"})" [ -n "$OUTPUT_DIR" ] || fail_msg "ERROR: Output directory isn't set!" [ -d "$OUTPUT_DIR" ] || fail_msg "ERROR: Output location isn't a directory!" -# everything needs a different arch name for some reason -DOTNET_ARCH="x64" -DOCKER_ARCH="amd64" +# there should already be a usable binary, so just figure out what we should use +DOTNET_ARCH= case "$ARCH" in "x86_64" | "x64") DOTNET_ARCH="x64" - DOCKER_ARCH="amd64" ;; "aarch64" | "arm64") DOTNET_ARCH="arm64" - DOCKER_ARCH="arm64/v8" ;; *) fail_msg "Unknown arch! Aborting!" ;; esac -# make sure needed archive exists +[ -n "$DOTNET_ARCH" ] || fail_msg "ERROR: No arch specified!" + +# make sure needed archive exists (should have checked for this already!!) [ -f "$OUTPUT_DIR/Linux_$DOTNET_ARCH.tar.gz" ] || fail_msg "ERROR: Linux $DOTNET_ARCH archive not found!" -# now just run script in appropriate container to generate bundle -docker run --platform linux/$DOCKER_ARCH --rm \ - -e ARCH="$ARCH" \ - -e PUBLISH_DIR="/PublishDir" \ - -e OUTPUT_DIR="/OutputDir" \ - -v "$REPO_ROOT":/repo \ - -v "$PUBLISH_DIR":/PublishDir \ - -v "$OUTPUT_DIR":/OutputDir \ - -t ubuntu:jammy \ - /bin/bash -xc "/repo/ci/bundle_appimage.sh" +# VERSION="$(grep string\ AppVersion -rI $NAME | cut -d \" -f 2)" # this will surely come back to bite me +VERSION="${VERSION:="0.0.0"}" + +BUILD_DIR="./build/appimage" +APPDIR="$BUILD_DIR/AppDir" + +FILE_ROOT="./packaging/linux" + +APPRUN_FILE="AppRun" +METAINFO_FILE="knossos.metainfo.xml.in" +DESKTOP_FILE="knossos.desktop.in" + +ICON_SIZES="512 256 128 96 64 48" # must include 256x256 at a minimum +ICON_FILE="knossos" + +APPIMAGE_TOOL_URL="https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-$(uname -m).AppImage" + +UPDATE_SCHEME="gh-releases-zsync|$GITHUB_ORG|$NAME|latest|$NAME-*$ARCH.AppImage.zsync" + + +# grab appimagetool +mkdir -p "$BUILD_DIR" +wget -O "$BUILD_DIR/appimagetool" "$APPIMAGE_TOOL_URL" || fail_msg "ERROR: Failed to get appimagetool!" +chmod +x "$BUILD_DIR/appimagetool" + + +# configure templates +export _NAME="$NAME" +export _ID="$ID" +export _VERSION="$VERSION" + +envsubst < "$FILE_ROOT/$METAINFO_FILE" > "$BUILD_DIR/$ID.appdata.xml" +envsubst < "$FILE_ROOT/$DESKTOP_FILE" > "$BUILD_DIR/$ID.desktop" + +unset _NAME _ID _VERSION + + +# create and populate AppDir +if [ -d "$APPDIR" ] +then + rm -Rf "$APPDIR" +fi + +install -d "$APPDIR" +install -m 755 "$FILE_ROOT/$APPRUN_FILE" "$APPDIR" + +install -d "$APPDIR/usr/bin" +tar -xzvf "$OUTPUT_DIR/Linux_$DOTNET_ARCH.tar.gz" -C "$APPDIR/usr/bin" +chmod +x "$APPDIR/usr/bin/$NAME" + +install -d "$APPDIR/usr/share/applications" +install -m 644 "$BUILD_DIR/$ID.desktop" "$APPDIR/usr/share/applications" + +install -d "$APPDIR/usr/share/metainfo" +install -m 644 "$BUILD_DIR/$ID.appdata.xml" "$APPDIR/usr/share/metainfo" + +for size in $ICON_SIZES; do + install -d "$APPDIR/usr/share/icons/hicolor/${size}x${size}/apps" + install -m 644 "$FILE_ROOT/$ICON_FILE-$size.png" "$APPDIR/usr/share/icons/hicolor/${size}x${size}/apps/$ID.png" +done + +# provide symlinks to .desktop and app icon in root as required by AppImage spec +ln -s "usr/share/applications/$ID.desktop" "$APPDIR" +ln -s "usr/share/icons/hicolor/256x256/apps/$ID.png" "$APPDIR" + + +# +# create AppImage +# + +ARCH=$ARCH "$BUILD_DIR/appimagetool" -u "$UPDATE_SCHEME" "$APPDIR" "$OUTPUT_DIR/$NAME-$ARCH.AppImage" + +# zsync file is saved to current directory so move it to proper place +[ -f "$NAME-$ARCH.AppImage.zsync" ] && mv "$NAME-$ARCH.AppImage.zsync" "$OUTPUT_DIR" \ No newline at end of file