make `argv[0]` in AppImage reliable to fix configuration file path (#109)

This commit is contained in:
Cyano Hao 2023-04-06 15:48:58 +08:00 committed by GitHub
parent cc5e6d1dab
commit 4190826c52
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 4 deletions

View File

@ -2,6 +2,9 @@
set -xe set -xe
VERSION=$(sed -nr -e '/APP_VERSION\s*=/ s/APP_VERSION\s*=\s*(([0-9]+\.)*[0-9]+)\s*/\1/p' /build/RedPanda-CPP/Red_Panda_CPP.pro)
APPIMAGE_FILE=RedPandaIDE-$VERSION-$CARCH.AppImage
# build RedPanda C++ # build RedPanda C++
mkdir -p /build/redpanda-build mkdir -p /build/redpanda-build
cd /build/redpanda-build cd /build/redpanda-build
@ -13,18 +16,19 @@ make install INSTALL_ROOT=/build/RedPandaIDE.AppDir
# setup AppImage resource # setup AppImage resource
cd /build/RedPandaIDE.AppDir cd /build/RedPandaIDE.AppDir
ln -s usr/bin/RedPandaIDE AppRun
ln -s usr/share/applications/redpandaide.desktop redpandaide.desktop ln -s usr/share/applications/redpandaide.desktop redpandaide.desktop
ln -s usr/share/icons/hicolor/scalable/apps/redpandaide.svg redpandaide.svg ln -s usr/share/icons/hicolor/scalable/apps/redpandaide.svg redpandaide.svg
cp /build/RedPanda-CPP/platform/linux/redpandaide.png .DirIcon # following files may come from Windows filesystem, use `install` to preseve file permission
install -m755 /build/RedPanda-CPP/packages/appimage/AppRun.sh AppRun
install -m644 /build/RedPanda-CPP/platform/linux/redpandaide.png .DirIcon
# copy dependency # copy dependency
cp /usr/local/bin/alacritty usr/bin cp /usr/local/bin/alacritty usr/bin
# create AppImage # create AppImage
cd /build cd /build
appimagetool --appimage-extract-and-run RedPandaIDE.AppDir RedPandaIDE-$CARCH.AppImage appimagetool --appimage-extract-and-run RedPandaIDE.AppDir $APPIMAGE_FILE
# copy back to host # copy back to host
mkdir -p /build/RedPanda-CPP/dist mkdir -p /build/RedPanda-CPP/dist
cp RedPandaIDE-$CARCH.AppImage /build/RedPanda-CPP/dist cp $APPIMAGE_FILE /build/RedPanda-CPP/dist

7
packages/appimage/AppRun.sh Executable file
View File

@ -0,0 +1,7 @@
#!/bin/sh
# AppImage runtime set `argv[0]` to AppImage file, which is not reliable.
# Qt framework expects reliable `argv[0]` to locate configuration files.
# This wrapper fixes `argv[0]`.
exec "$(dirname "$0")/usr/bin/RedPandaIDE" "$@"