diff --git a/.gitignore b/.gitignore index ecf4752..c229618 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ /target /assets/ui/.dist Cargo.lock + +/scripts/appimage/dist +/scripts/appimage/*.AppImage diff --git a/README.md b/README.md index 8f96e92..b8cff85 100644 --- a/README.md +++ b/README.md @@ -32,3 +32,10 @@ cargo run ```sh cargo build --release ``` + +### Building AppImage + +``` +cd scripts/appimage +./build_appimage.sh +``` diff --git a/scripts/appimage/anime-game-launcher.desktop b/scripts/appimage/anime-game-launcher.desktop new file mode 100644 index 0000000..e12d1e4 --- /dev/null +++ b/scripts/appimage/anime-game-launcher.desktop @@ -0,0 +1,7 @@ +[Desktop Entry] +Name=An Anime Game Launcher +Icon=icon +Exec=AppRun +Type=Application +Categories=Game +Terminal=false diff --git a/scripts/appimage/build_appimage.sh b/scripts/appimage/build_appimage.sh new file mode 100755 index 0000000..de25940 --- /dev/null +++ b/scripts/appimage/build_appimage.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +linuxdeploy="linuxdeploy-x86_64.AppImage" +appimagetool="appimagetool-x86_64.AppImage" + +version="0.3.1" + +if [ ! -f $linuxdeploy ]; +then + echo "Downloading LinuxDeploy..." + + curl -s -L -o $linuxdeploy https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage + + chmod +x $linuxdeploy +fi + +if [ ! -f $appimagetool ]; +then + echo "Downloading AppImageTool..." + + curl -s -L -o $appimagetool https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage + + chmod +x $appimagetool +fi + +if [ -d dist ]; +then + rm -rf dist +fi + +mkdir dist + +cp "../../target/release/anime-game-launcher" "dist/anime-game-launcher" + +echo "Executing LinuxDeploy..." + +./$linuxdeploy --appdir dist -d anime-game-launcher.desktop --custom-apprun run.sh -i icon.png -o appimage + +echo "Executing AppImageTool..." + +VERSION=$version ./$appimagetool dist diff --git a/scripts/appimage/icon.png b/scripts/appimage/icon.png new file mode 100644 index 0000000..6355931 Binary files /dev/null and b/scripts/appimage/icon.png differ diff --git a/scripts/appimage/run.sh b/scripts/appimage/run.sh new file mode 100644 index 0000000..47ab990 --- /dev/null +++ b/scripts/appimage/run.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +if [ -z "$APPDIR" ] ; then + path="$(dirname "$(readlink -f "${THIS}")")" + + while [[ "$path" != "" && ! -e "$path/$1" ]]; do + path=${path%/*} + done + + APPDIR="$path" +fi + +export PATH="${APPDIR}:${APPDIR}/usr/sbin:${PATH}" +export XDG_DATA_DIRS="./share/:/usr/share/gnome:/usr/local/share/:/usr/share/:${XDG_DATA_DIRS}" +export LD_LIBRARY_PATH="${APPDIR}/usr/lib:${LD_LIBRARY_PATH}" +export XDG_DATA_DIRS="${APPDIR}"/usr/share/:"${XDG_DATA_DIRS}":/usr/share/gnome/:/usr/local/share/:/usr/share/ +export GSETTINGS_SCHEMA_DIR="${APPDIR}/usr/share/glib-2.0/schemas:${GSETTINGS_SCHEMA_DIR}" + +cd "$APPDIR" + +exec "$APPDIR/anime-game-launcher" $@