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.
This commit is contained in:
Moritz Bunkus 2019-10-11 11:10:53 +02:00
parent c568460c1c
commit ec80478f87
No known key found for this signature in database
GPG Key ID: 74AF00ADF2E32C85
3 changed files with 35 additions and 10 deletions

View File

@ -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

View File

@ -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

View File

@ -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" "$@"