| 1 |
#!/bin/bash |
| 2 |
|
| 3 |
# Main AppImage internal startup script. |
| 4 |
# Wrap XDG_* variables properly for Qt. |
| 5 |
# |
| 6 |
# SPDX-FileCopyrightText: 2015-2026 by Gilles Caulier <caulier dot gilles at gmail dot com> |
| 7 |
# |
| 8 |
# SPDX-License-Identifier: BSD-3-Clause |
| 9 |
# |
| 10 |
|
| 11 |
# Function to preload a shared library in memory before to start application. |
| 12 |
|
| 13 |
preload_shared_library () |
| 14 |
{ |
| 15 |
FILENAME=$1 |
| 16 |
for dir in /usr/lib64 /usr/lib/x86_64-linux-gnu /lib/x86_64-linux-gnu ; do |
| 17 |
fullpath=$dir/$FILENAME |
| 18 |
# Check with ld.so if the library can be loaded |
| 19 |
# We need also to check if the library exists, otherwise ld.so will print: |
| 20 |
# ERROR: ld.so: object from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored. |
| 21 |
# but exit with 0. |
| 22 |
# See also bug 492040 |
| 23 |
# echo -n "$fullpath " # Uncomment for debugging |
| 24 |
if [ -f "$fullpath" ] && ld.so --preload "$fullpath" /bin/true >/dev/null 2>&1 ; then |
| 25 |
echo "Preloading $fullpath" |
| 26 |
export LD_PRELOAD="$LD_PRELOAD:$fullpath" |
| 27 |
return 0 |
| 28 |
fi |
| 29 |
done |
| 30 |
echo "Preloading skipped for $FILENAME" |
| 31 |
return 1 |
| 32 |
} |
| 33 |
|
| 34 |
### |
| 35 |
|
| 36 |
echo "-- digiKam Linux AppImage Bundle" |
| 37 |
echo "-- Use 'help' as CLI argument to know all available options for digiKam application." |
| 38 |
echo "-- Notes: to integrate this bundle to your desktop, use AppImageLauncher." |
| 39 |
echo "-- to enable all debug messages on the console, use 'export QT_LOGGING_RULES=\"digikam*=true\"'." |
| 40 |
echo "-- to extract the bundle contents locally, use option '--appimage-extract' on the command line." |
| 41 |
|
| 42 |
if [[ "$(uname -m)" != "x86_64" ]] ; then |
| 43 |
|
| 44 |
echo "!!! You trying to run a 64 bits binary on a 32 bits system. Aborted !!!" |
| 45 |
exit -1; |
| 46 |
|
| 47 |
fi |
| 48 |
|
| 49 |
# Show host OS name and version. |
| 50 |
|
| 51 |
OS_NAME=$(awk -F'=' '$1 ~ /^DISTRIB_ID/ {print $2}' /etc/*-release | tr -d '"') |
| 52 |
OS_ARCH=$(uname -m | sed 's/x86_//;s/i[3-6]86/32/') |
| 53 |
OS_VERSION=$(awk -F'=' '$1 ~ /^DISTRIB_RELEASE/ {print $2}' /etc/*-release | tr -d '"') |
| 54 |
|
| 55 |
if [ -z "${OS_NAME}" ] ; then |
| 56 |
|
| 57 |
OS_NAME=$(awk -F'=' '$1 ~ /^NAME/ {print $2}' /etc/*-release | tr -d '"') |
| 58 |
|
| 59 |
fi |
| 60 |
|
| 61 |
if [ -z "${OS_VERSION}" ] ; then |
| 62 |
|
| 63 |
OS_VERSION=$(awk -F'=' '$1 ~ /^VERSION_ID/ {print $2}' /etc/*-release | tr -d '"') |
| 64 |
|
| 65 |
fi |
| 66 |
|
| 67 |
if [ "${OS_NAME}" == "Debian GNU/Linux" ] ; then |
| 68 |
|
| 69 |
# Debian testing versions don't include numbers in /etc/os-release. |
| 70 |
OS_VERSION=$(</etc/debian_version) |
| 71 |
|
| 72 |
fi |
| 73 |
|
| 74 |
echo "-- Detected host Linux $OS_NAME-$OS_ARCH-$OS_VERSION" |
| 75 |
|
| 76 |
# See bugs #414016, #414028, #415882, Qt fill log files with unwanted |
| 77 |
# debug trace about locale rules. |
| 78 |
|
| 79 |
export QT_LOGGING_RULES="default*=false;"$QT_LOGGING_RULES |
| 80 |
|
| 81 |
# Try to make Qt apps more "native looking" on Gtk-based desktops, if possible |
| 82 |
# see https://github.com/AppImage/AppImageKit/issues/977#issue-462374883 |
| 83 |
|
| 84 |
case "${XDG_CURRENT_DESKTOP}" in |
| 85 |
|
| 86 |
*GNOME*|*gnome*|*XFCE*) |
| 87 |
export QT_QPA_PLATFORMTHEME=gtk2 |
| 88 |
;; |
| 89 |
|
| 90 |
esac |
| 91 |
|
| 92 |
DIR="`dirname \"$0\"`" |
| 93 |
DIR="`( cd \"$DIR\" && readlink -f $(pwd) )`" |
| 94 |
echo "-- AppImage mounted directory: $DIR" |
| 95 |
export APPDIR=$DIR |
| 96 |
|
| 97 |
# Note: these variables are used in patched Qt to detect AppImage session. |
| 98 |
|
| 99 |
export APPIMAGE_ORIGINAL_LD_LIBRARY_PATH=$LD_LIBRARY_PATH |
| 100 |
export APPIMAGE_ORIGINAL_QT_PLUGIN_PATH=$QT_PLUGIN_PATH |
| 101 |
export APPIMAGE_ORIGINAL_XDG_DATA_DIRS=$XDG_DATA_DIRS |
| 102 |
export APPIMAGE_ORIGINAL_LD_PRELOAD=$LD_PRELOAD |
| 103 |
export APPIMAGE_ORIGINAL_PATH=$PATH |
| 104 |
|
| 105 |
export LD_LIBRARY_PATH=$DIR/usr/lib/:$LD_LIBRARY_PATH |
| 106 |
export QT_PLUGIN_PATH=$DIR/usr/plugins/ |
| 107 |
|
| 108 |
# See bug #427906 |
| 109 |
|
| 110 |
if [ -d "/usr/share/X11/xkb/" ] ; then |
| 111 |
|
| 112 |
export XKB_CONFIG_ROOT=/usr/share/X11/xkb/ |
| 113 |
|
| 114 |
fi |
| 115 |
|
| 116 |
export XDG_DATA_DIRS=$DIR/usr/share/:$XDG_DATA_DIRS |
| 117 |
export PATH=$DIR/usr/bin:$DIR/usr/lib:$DIR/usr/lib/libexec/kf5:$DIR/usr/share/digikam/utils:$PATH |
| 118 |
|
| 119 |
# Gphoto2 runtime environment |
| 120 |
|
| 121 |
export CAMLIBS=$DIR/usr/lib/libgphoto2 |
| 122 |
export IOLIBS=$DIR/usr/lib/libgphoto2_port |
| 123 |
|
| 124 |
# ImageMagick run-time environment |
| 125 |
|
| 126 |
export APPIMAGE_ORIGINAL_MAGICK_CODER_MODULE_PATH=$MAGICK_CODER_MODULE_PATH |
| 127 |
export APPIMAGE_ORIGINAL_MAGICK_CODER_FILTER_PATH=$MAGICK_CODER_FILTER_PATH |
| 128 |
|
| 129 |
export MAGICK_CODER_MODULE_PATH=$DIR/usr/lib/modules-Q16HDRI/coders |
| 130 |
export MAGICK_CODER_FILTER_PATH=$DIR/usr/lib/modules-Q16HDRI/filters |
| 131 |
|
| 132 |
# QtWebEngine crash with some video card drivers |
| 133 |
# https://github.com/qutebrowser/qutebrowser/issues/2368 |
| 134 |
|
| 135 |
export QT_XCB_FORCE_SOFTWARE_OPENGL=1 |
| 136 |
export QTWEBENGINE_CHROMIUM_FLAGS="--disable-gpu" |
| 137 |
|
| 138 |
# Code to disable Plasma desktop detection with QDesktopService |
| 139 |
|
| 140 |
export APPIMAGE_ORIGINAL_KDE_FULL_SESSION=$KDE_FULL_SESSION |
| 141 |
export APPIMAGE_ORIGINAL_DESKTOP_SESSION=$DESKTOP_SESSION |
| 142 |
export APPIMAGE_ORIGINAL_XDG_CURRENT_DESKTOP=$XDG_CURRENT_DESKTOP |
| 143 |
export APPIMAGE_ORIGINAL_XDG_SESSION_DESKTOP=$XDG_SESSION_DESKTOP |
| 144 |
#unset KDE_FULL_SESSION |
| 145 |
#unset DESKTOP_SESSION |
| 146 |
#unset XDG_CURRENT_DESKTOP |
| 147 |
#unset XDG_SESSION_DESKTOP |
| 148 |
|
| 149 |
# if no customized Qt debug login variable is set, turn on one for a better readability |
| 150 |
|
| 151 |
if [ -z "$QT_MESSAGE_PATTERN" ] ; then |
| 152 |
|
| 153 |
export QT_MESSAGE_PATTERN="`echo -e "\033[34m%{function}\033[0m: %{message}"`" |
| 154 |
|
| 155 |
fi |
| 156 |
|
| 157 |
export APPIMAGE_STARTUP_LD_LIBRARY_PATH=$LD_LIBRARY_PATH |
| 158 |
export APPIMAGE_STARTUP_QT_PLUGIN_PATH=$QT_PLUGIN_PATH |
| 159 |
export APPIMAGE_STARTUP_XDG_DATA_DIRS=$XDG_DATA_DIRS |
| 160 |
export APPIMAGE_STARTUP_PATH=$PATH |
| 161 |
|
| 162 |
# See bug #401377: tested on Fedora 29 and Mageia 7 for transitional |
| 163 |
# migration from openssl 1.0 to openssl 1.1 |
| 164 |
|
| 165 |
if [ -f /etc/pki/openssl10.cnf ] ; then |
| 166 |
|
| 167 |
export OPENSSL_CONF=/etc/pki/openssl10.cnf |
| 168 |
|
| 169 |
fi |
| 170 |
|
| 171 |
# See Bug #109060 |
| 172 |
|
| 173 |
if [ -f $DIR/usr/lib/libavif.so.13 ] ; then |
| 174 |
|
| 175 |
export LD_PRELOAD=$LD_PRELOAD:$DIR/usr/lib/libavif.so.13 |
| 176 |
|
| 177 |
fi |
| 178 |
|
| 179 |
preload_shared_library libudev.so.0 |
| 180 |
|
| 181 |
# See bug #414737 |
| 182 |
|
| 183 |
preload_shared_library libxcb-dri3.so.0 |
| 184 |
|
| 185 |
# See bug #447150 |
| 186 |
|
| 187 |
preload_shared_library libcrypto.so.1.1 |
| 188 |
preload_shared_library libssl.so.1.1 |
| 189 |
|
| 190 |
# See bug #449308 |
| 191 |
|
| 192 |
preload_shared_library libnss3.so |
| 193 |
preload_shared_library libnssutil3.so |
| 194 |
preload_shared_library libsmime3.so |
| 195 |
|
| 196 |
# See bug #451196 and #451780 |
| 197 |
|
| 198 |
preload_shared_library libgmodule-2.0.so.0 |
| 199 |
|
| 200 |
# See bug #216915 and #492040 |
| 201 |
|
| 202 |
preload_shared_library libgnutls.so.30 |
| 203 |
|
| 204 |
# See bug #261634 |
| 205 |
|
| 206 |
preload_shared_library libnettle.so.8 |
| 207 |
|
| 208 |
# See bug #461495 |
| 209 |
# |
| 210 |
#preload_shared_library libpcre.so.3 |
| 211 |
# |
| 212 |
#preload_shared_library libfontconfig.so.1 |
| 213 |
#preload_shared_library libfreetype.so.6 |
| 214 |
|
| 215 |
echo "-- Preloading shared libs: $LD_PRELOAD" |
| 216 |
|
| 217 |
# Parse CLI options. |
| 218 |
|
| 219 |
if [[ $1 == "showfoto" ]] ; then |
| 220 |
|
| 221 |
# Run Showfoto as well. |
| 222 |
|
| 223 |
showfoto ${@:2} |
| 224 |
|
| 225 |
elif [[ $1 == "debug" ]] ; then |
| 226 |
|
| 227 |
export DIGIKAM_REMOTE_DEBUG=ON |
| 228 |
|
| 229 |
if [[ $2 == "showfoto" ]] ; then |
| 230 |
|
| 231 |
# Showfoto in debug mode. |
| 232 |
|
| 233 |
echo "Starting delayed Showfoto for remote debugging..." |
| 234 |
echo "Use 'bt' command on debugger prompt to get a crash backtrace." |
| 235 |
echo "Use 'q' command to quit debugger session." |
| 236 |
showfoto ${@:3} |
| 237 |
|
| 238 |
else |
| 239 |
|
| 240 |
# digiKam in debug mode. |
| 241 |
|
| 242 |
echo "Starting delayed digiKam for remote debugging..." |
| 243 |
echo "Use 'bt' command on debugger prompt to get a crash backtrace." |
| 244 |
echo "Use 'q' command to quit debugger session." |
| 245 |
digikam ${@:2} |
| 246 |
|
| 247 |
fi |
| 248 |
|
| 249 |
elif [[ $1 == "help" ]] ; then |
| 250 |
|
| 251 |
# digiKam/Showfoto CLI help. |
| 252 |
|
| 253 |
echo "digiKam AppImage bundle CLI options:" |
| 254 |
echo " without option : run digiKam." |
| 255 |
echo " <showfoto> : run Showfoto instead digiKam." |
| 256 |
echo " <debug> : run digiKam and wait at startup to be attached to a remote GDB instance (only suitable with the AppImage compiled with debug symbols)." |
| 257 |
echo " <debug> <showfoto> : run Showfoto and wait at startup to be attached to a remote GDB instance (only suitable with the AppImage compiled with debug symbols)." |
| 258 |
echo " <help> : show these information." |
| 259 |
|
| 260 |
else |
| 261 |
|
| 262 |
# Run digiKam as well. |
| 263 |
|
| 264 |
digikam $@ |
| 265 |
|
| 266 |
fi |