#! /usr/bin/env bash

# make sure errors in sourced scripts will cause this script to stop
set -e

this_dir="$(readlink -f "$(dirname "$0")")"

# Export ImageMagick env
export MAGICK_HOME="$this_dir"/"usr"
export PATH="$MAGICK_HOME/bin:$PATH
LD_LIBRARY_PATH="${LD_LIBRARY_PATH:+$LD_LIBRARY_PATH:}$MAGICK_HOME/lib
export LD_LIBRARY_PATH
echo $LD_LIBRARY_PATH
export MAGICK_CONFIGURE_PATH="$this_dir"/.config/ImageMagick

# Export Ghostscript env
export GS_LIB="$this_dir/usr/share/ghostscript/9.26/Resource/Init"
export GS_FONTPATH="$this_dir/usr/share/ghostscript/9.26/Resource/Font"
export GS_OPTIONS="-sGenericResourceDir=$this_dir/usr/share/ghostscript/9.26/Resource/ -sICCProfilesDir=$this_dir/usr/share/ghostscript/9.26/iccprofiles/"

source "$this_dir"/apprun-hooks/"linuxdeploy-plugin-qt-hook.sh"

exec "$this_dir"/AppRun.wrapped "$@"

