Skip to content

Commit

Permalink
Package: improve AppImage scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Rosalie241 committed Jan 20, 2025
1 parent 7f02a76 commit 1655488
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 43 deletions.
15 changes: 8 additions & 7 deletions Package/AppImage/AppRun
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#!/usr/bin/env sh
[ -f "$APPIMAGE".stylesheet ] && APPIMAGE_QT_THEME="$APPIMAGE.stylesheet"
[ -f "$APPIMAGE_QT_THEME" ] && set -- "$@" "-stylesheet" "$APPIMAGE_QT_THEME"
HERE="$(readlink -f "$(dirname "$0")")"
exec "$HERE/bin/RMG" \
--lib-path="$HERE/shared/lib/RMG" \
--core-path="$HERE/shared/lib/RMG/Core" \
--plugin-path="$HERE/shared/lib/RMG/Plugin" \
--shared-data-path="$HERE/share/RMG" \
"${@}"
cur_dir="$(readlink -f "$(dirname "$0")")"

exec "$cur_dir/bin/RMG" \
--lib-path="$cur_dir/shared/lib/RMG" \
--core-path="$cur_dir/shared/lib/RMG/Core" \
--plugin-path="$cur_dir/shared/lib/RMG/Plugin" \
--shared-data-path="$cur_dir/share/RMG" \
"$@"
96 changes: 60 additions & 36 deletions Package/AppImage/Create.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,54 +4,78 @@ set -ex
script_dir="$(dirname "$0")"
toplvl_dir="$(realpath "$script_dir/../../")"
bin_dir="$toplvl_dir/Bin/AppImage" # RMG should be installed here
lib_dir="/usr/lib64"

XVFB_RUN="xvfb-run -a --"
UPINFO="gh-releases-zsync|$(echo "$GITHUB_REPOSITORY" | tr '/' '|')|latest|*.AppImage.zsync"
LIB4BN="https://raw.githubusercontent.com/VHSgunzo/sharun/refs/heads/main/lib4bin"
APPIMAGETOOL="https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-x86_64.AppImage"
LIB4BIN_URL="https://raw.githubusercontent.com/VHSgunzo/sharun/refs/heads/main/lib4bin"
APPIMAGETOOL_URL="https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-x86_64.AppImage"
SHARUN_URL="https://github.com/VHSgunzo/sharun/releases/latest/download/sharun-x86_64"

export ARCH="$(uname -m)"
export ARCH=$(uname -m)
export APPIMAGE_EXTRACT_AND_RUN=1
export VERSION="$(git describe --tags --always)"
export OUTPUT="$bin_dir/../RMG-Portable-Linux64-$VERSION.AppImage"
export LD_LIBRARY_PATH="$toplvl_dir/Build/AppImage/Source/RMG-Core" # hack
export SHARUN="$script_dir/sharun"

cp "$bin_dir"/usr/share/applications/com.github.Rosalie241.RMG.desktop "$bin_dir"
cp "$bin_dir"/usr/share/icons/hicolor/scalable/apps/com.github.Rosalie241.RMG.svg "$bin_dir"
ln -s ./com.github.Rosalie241.RMG.svg "$bin_dir"/.DirIcon
mv "$bin_dir"/usr/share "$bin_dir"/share
mv "$bin_dir"/usr "$bin_dir"/shared
if [[ ! -f "$script_dir/lib4bin" ]]
then
curl -L "$LIB4BIN_URL" -o "$script_dir/lib4bin"
chmod +x "$script_dir/lib4bin"
fi

if [[ ! -f "$script_dir/appimagetool" ]]
then
curl -L "$APPIMAGETOOL_URL" -o "$script_dir/appimagetool"
chmod +x "$script_dir/appimagetool"
fi

if [[ ! -f "$script_dir/sharun" ]]
then
curl -L "$SHARUN_URL" -o "$script_dir/sharun"
chmod +x "$script_dir/sharun"
fi

if [[ "x$DISPLAY" != "x" ]]
then
XVFB_RUN=""
fi

if [ ! -f "./lib4bin" ]; then
curl -L "$LIB4BN" -o ./lib4bin
chmod +x ./lib4bin
if [[ -d "/usr/lib/x86_64-linux-gnu/" ]]
then
lib_dir="/usr/lib/x86_64-linux-gnu/"
fi

xvfb-run -a -- ./lib4bin --dst-dir "$bin_dir" -p -v -r -s -k -e \
"$bin_dir"/shared/bin/RMG \
/usr/lib/x86_64-linux-gnu/libSDL* \
/usr/lib/x86_64-linux-gnu/libGL* \
/usr/lib/x86_64-linux-gnu/libEGL* \
/usr/lib/x86_64-linux-gnu/libvulkan* \
/usr/lib/x86_64-linux-gnu/dri/* \
/usr/lib/x86_64-linux-gnu/libssl.so* \
/usr/lib/x86_64-linux-gnu/qt6/plugins/iconengines/* \
/usr/lib/x86_64-linux-gnu/qt6/plugins/imageformats/* \
/usr/lib/x86_64-linux-gnu/qt6/plugins/platforms/* \
/usr/lib/x86_64-linux-gnu/qt6/plugins/platformthemes/* \
/usr/lib/x86_64-linux-gnu/qt6/plugins/styles/* \
/usr/lib/x86_64-linux-gnu/qt6/plugins/xcbglintegrations/* \
/usr/lib/x86_64-linux-gnu/qt6/plugins/tls/* \
/usr/lib/x86_64-linux-gnu/qt6/plugins/wayland-*/*
cp "$bin_dir/usr/share/applications/com.github.Rosalie241.RMG.desktop" "$bin_dir"
cp "$bin_dir/usr/share/icons/hicolor/scalable/apps/com.github.Rosalie241.RMG.svg" "$bin_dir"
ln -s ./com.github.Rosalie241.RMG.svg "$bin_dir"/.DirIcon
mv "$bin_dir/usr/share" "$bin_dir/share"
mv "$bin_dir/usr" "$bin_dir/shared"

$XVFB_RUN "$script_dir/lib4bin" --dst-dir "$bin_dir" \
--hard-links --patch-rpath --strip \
--with-hooks --strace-mode --with-sharun \
"$bin_dir/shared/bin/RMG" \
"$lib_dir"/libSDL* \
"$lib_dir"/libGL* \
"$lib_dir"/libEGL* \
"$lib_dir"/libvulkan* \
"$lib_dir"/dri/* \
"$lib_dir"/libssl.so* \
"$lib_dir"/qt6/plugins/iconengines/* \
"$lib_dir"/qt6/plugins/imageformats/* \
"$lib_dir"/qt6/plugins/platforms/* \
"$lib_dir"/qt6/plugins/platformthemes/* \
"$lib_dir"/qt6/plugins/styles/* \
"$lib_dir"/qt6/plugins/xcbglintegrations/* \
"$lib_dir"/qt6/plugins/tls/* \
"$lib_dir"/qt6/plugins/wayland-*/*

# Prepare sharun
"$bin_dir"/sharun -g
cp -v "$script_dir/AppRun" "$bin_dir"
chmod +x "$bin_dir"/AppRun
"$bin_dir/sharun" -g
cp "$script_dir/AppRun" "$bin_dir"

# make appimage
if [ ! -f "./appimagetool" ]; then
curl -L "$APPIMAGETOOL" -o ./appimagetool
chmod +x ./appimagetool
fi
./appimagetool --comp zstd \
"$script_dir/appimagetool" --comp zstd \
--mksquashfs-opt -Xcompression-level --mksquashfs-opt 22 \
-n -u "$UPINFO" "$bin_dir" "$OUTPUT"

0 comments on commit 1655488

Please sign in to comment.