From ec80478f87f1941fe52f15c5f4fa7ee6a70d7006 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Fri, 11 Oct 2019 11:10:53 +0200 Subject: [PATCH] AppImage: don't use AppRun; set up environment in select-binary.sh instead The original AppRun contains a hard-coded change to the current working directory to the mounted installation. This made using relative file names impossible. However, the MKVToolNix can be run from anywhere and don't rely on the current working directory. Fixes #2632. --- NEWS.md | 9 +++++++++ packaging/appimage/build.sh | 12 ++++++------ packaging/appimage/select-binary.sh | 24 ++++++++++++++++++++---- 3 files changed, 35 insertions(+), 10 deletions(-) diff --git a/NEWS.md b/NEWS.md index ce7ef2526..dc049e0c5 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,12 @@ +# Version ? + +## Bug fixes + +* Linux AppImage: the AppImage will no longer change directories before + running the desired executable allow the use of relative file names. Fixes + #2632. + + # Version 38.0.0 "The Silent Type" 2019-10-06 ## New features and enhancements diff --git a/packaging/appimage/build.sh b/packaging/appimage/build.sh index c331c871d..bd68384ce 100755 --- a/packaging/appimage/build.sh +++ b/packaging/appimage/build.sh @@ -148,7 +148,12 @@ drake -j${JOBS} apps:mkvtoolnix-gui drake -j${JOBS} drake install DESTDIR="${APP_DIR}" -cd appimage/${APP}.AppDir/usr +cd appimage/${APP}.AppDir + +cp "${TOP_DIR}/packaging/appimage/select-binary.sh" AppRun +chmod 0755 AppRun + +cd usr # Qt plugins mkdir -p bin/{audio,mediaservice,platforms} @@ -158,9 +163,6 @@ cp ${QTDIR}/plugins/platforms/libq{minimal,offscreen,wayland,xcb}*.so bin/platfo find bin -type f -exec strip {} \+ -cp "${TOP_DIR}/packaging/appimage/select-binary.sh" bin/ -chmod 0755 bin/select-binary.sh - mkdir -p lib lib64 chmod u+rwx lib lib64 @@ -200,8 +202,6 @@ cp ./usr/share/icons/hicolor/256x256/apps/mkvtoolnix-gui.png . cp ./usr/share/applications/org.bunkus.mkvtoolnix-gui.desktop mkvtoolnix-gui.desktop fix_desktop mkvtoolnix-gui.desktop -sed -i -e 's/^Exec=.*/Exec=select-binary.sh %F/' mkvtoolnix-gui.desktop -get_apprun cd .. generate_type2_appimage diff --git a/packaging/appimage/select-binary.sh b/packaging/appimage/select-binary.sh index a3c142ca9..aec87ca78 100755 --- a/packaging/appimage/select-binary.sh +++ b/packaging/appimage/select-binary.sh @@ -1,12 +1,28 @@ #!/bin/bash -BIN_DIR="$(dirname "$(readlink -f "${0}")")" +APPIMAGE_DIR="$(dirname "$(readlink -f "${0}")")" +# Adopted from AppRun.c +export GSETTINGS_SCHEMA_DIR="$APPIMAGE_DIR/usr/share/glib-2.0/schemas/:$GSETTINGS_SCHEMA_DIR" +export GST_PLUGIN_SYSTEM_PATH="$APPIMAGE_DIR/usr/lib/gstreamer:$GST_PLUGIN_SYSTEM_PATH" +export GST_PLUGIN_SYSTEM_PATH_1_0="$APPIMAGE_DIR/usr/lib/gstreamer-1.0:$GST_PLUGIN_SYSTEM_PATH_1_0" +export LD_LIBRARY_PATH="$APPIMAGE_DIR/usr/lib/:$APPIMAGE_DIR/usr/lib/i386-linux-gnu/:$APPIMAGE_DIR/usr/lib/x86_64-linux-gnu/:$APPIMAGE_DIR/usr/lib32/:$APPIMAGE_DIR/usr/lib64/:$APPIMAGE_DIR/lib/:$APPIMAGE_DIR/lib/i386-linux-gnu/:$APPIMAGE_DIR/lib/x86_64-linux-gnu/:$APPIMAGE_DIR/lib32/:$APPIMAGE_DIR/lib64/:$LD_LIBRARY_PATH" +export PATH="$APPIMAGE_DIR/usr/bin/:$APPIMAGE_DIR/usr/sbin/:$APPIMAGE_DIR/usr/games/:$APPIMAGE_DIR/bin/:$APPIMAGE_DIR/sbin/:$PATH" +export PERLLIB="$APPIMAGE_DIR/usr/share/perl5/:$APPIMAGE_DIR/usr/lib/perl5/:$PERLLIB" +export PYTHONDONTWRITEBYTECODE=1 +export PYTHONHOME="$APPIMAGE_DIR/usr/" +export PYTHONPATH="$APPIMAGE_DIR/usr/share/pyshared/:$PYTHONPATH" +export QT_PLUGIN_PATH="$APPIMAGE_DIR/usr/lib/qt4/plugins/:$APPIMAGE_DIR/usr/lib/i386-linux-gnu/qt4/plugins/:$APPIMAGE_DIR/usr/lib/x86_64-linux-gnu/qt4/plugins/:$APPIMAGE_DIR/usr/lib32/qt4/plugins/:$APPIMAGE_DIR/usr/lib64/qt4/plugins/:$APPIMAGE_DIR/usr/lib/qt5/plugins/:$APPIMAGE_DIR/usr/lib/i386-linux-gnu/qt5/plugins/:$APPIMAGE_DIR/usr/lib/x86_64-linux-gnu/qt5/plugins/:$APPIMAGE_DIR/usr/lib32/qt5/plugins/:$APPIMAGE_DIR/usr/lib64/qt5/plugins/:$QT_PLUGIN_PATH" +export XDG_DATA_DIRS="$APPIMAGE_DIR/usr/share/:/usr/local/share/:/usr/share" + +# Get binary to run from executable's name: symlink the AppImage to +# e.g. "mkvmerge", execute that symlink & mkvmerge will be run from +# inside the AppImage. If no such binary exists, fall back to the GUI. if [ ! -z $APPIMAGE ] ; then BINARY_NAME="$(basename "$ARGV0")" - if [ -e "$BIN_DIR/$BINARY_NAME" ] ; then - exec "$BIN_DIR/$BINARY_NAME" "$@" + if [ -e "$APPIMAGE_DIR/usr/bin/$BINARY_NAME" ] ; then + exec "$APPIMAGE_DIR/usr/bin/$BINARY_NAME" "$@" fi fi -exec "$BIN_DIR/mkvtoolnix-gui" "$@" +exec "$APPIMAGE_DIR/usr/bin/mkvtoolnix-gui" "$@"