From 4190826c52914bbb82044f53fbebdf54f2c78541 Mon Sep 17 00:00:00 2001 From: Cyano Hao Date: Thu, 6 Apr 2023 15:48:58 +0800 Subject: [PATCH] make `argv[0]` in AppImage reliable to fix configuration file path (#109) --- packages/appimage/01-in-docker.sh | 12 ++++++++---- packages/appimage/AppRun.sh | 7 +++++++ 2 files changed, 15 insertions(+), 4 deletions(-) create mode 100755 packages/appimage/AppRun.sh diff --git a/packages/appimage/01-in-docker.sh b/packages/appimage/01-in-docker.sh index 59b171df..6d2ce65c 100755 --- a/packages/appimage/01-in-docker.sh +++ b/packages/appimage/01-in-docker.sh @@ -2,6 +2,9 @@ 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++ mkdir -p /build/redpanda-build cd /build/redpanda-build @@ -13,18 +16,19 @@ make install INSTALL_ROOT=/build/RedPandaIDE.AppDir # setup AppImage resource cd /build/RedPandaIDE.AppDir -ln -s usr/bin/RedPandaIDE AppRun ln -s usr/share/applications/redpandaide.desktop redpandaide.desktop 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 cp /usr/local/bin/alacritty usr/bin # create AppImage 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 mkdir -p /build/RedPanda-CPP/dist -cp RedPandaIDE-$CARCH.AppImage /build/RedPanda-CPP/dist +cp $APPIMAGE_FILE /build/RedPanda-CPP/dist diff --git a/packages/appimage/AppRun.sh b/packages/appimage/AppRun.sh new file mode 100755 index 00000000..fcf3e05e --- /dev/null +++ b/packages/appimage/AppRun.sh @@ -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" "$@"