Skip to content

Commit 86658ae

Browse files
Do not create temp directories and files at runtime
Fix #24
1 parent 0b1f825 commit 86658ae

File tree

1 file changed

+7
-17
lines changed

1 file changed

+7
-17
lines changed

linuxdeploy-plugin-gtk.sh

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -182,16 +182,6 @@ cat > "$HOOKFILE" <<\EOF
182182
gsettings get org.gnome.desktop.interface gtk-theme 2> /dev/null | grep -qi "dark" && GTK_THEME_VARIANT="dark" || GTK_THEME_VARIANT="light"
183183
APPIMAGE_GTK_THEME="${APPIMAGE_GTK_THEME:-"Adwaita:$GTK_THEME_VARIANT"}" # Allow user to override theme (discouraged)
184184
185-
# in case we run from an AppImage, we use the $APPDIR environment variable as a template for the temporary directory that should be created
186-
# this allows users to attribute the tempdir to the running AppImage
187-
if [ "$APPDIR" != "" ]; then
188-
tempdir_template="$APPDIR".ld-p-gtk-tmp-XXXXXX
189-
else
190-
tempdir_template=/tmp/.ld-p-gtk-tmp-XXXXXX
191-
fi
192-
193-
export CACHEDIR="$(mktemp -d "$tempdir_template")"
194-
195185
export APPDIR="${APPDIR:-"$(dirname "$(realpath "$0")")"}" # Workaround to run extracted AppImage
196186
export GTK_DATA_PREFIX="$APPDIR"
197187
export GTK_THEME="$APPIMAGE_GTK_THEME" # Custom themes are broken
@@ -222,12 +212,12 @@ case "$DEPLOY_GTK_VERSION" in
222212
gtk3_immodules_cache_file="$(dirname "$gtk3_immodulesdir")/immodules.cache"
223213
gtk3_immodules_query="$(search_tool "gtk-query-immodules-3.0" "libgtk-3-0")"
224214
copy_tree "$gtk3_libdir" "$APPDIR/"
215+
sed -i "s|$gtk3_libdir/||g" "$APPDIR/$gtk3_immodules_cache_file"
225216
cat >> "$HOOKFILE" <<EOF
226217
export GTK_EXE_PREFIX="\$APPDIR/$gtk3_exec_prefix"
227218
export GTK_PATH="\$APPDIR/$gtk3_path"
228-
export GTK_IM_MODULE_DIR="\$APPDIR/$gtk3_immodulesdir"
229-
export GTK_IM_MODULE_FILE="\$CACHEDIR/immodules.cache"
230-
sed "s|$gtk3_libdir|\$APPDIR/$gtk3_libdir|g" "\$APPDIR/$gtk3_immodules_cache_file" > "\$GTK_IM_MODULE_FILE"
219+
export GTK_IM_MODULE_FILE="\$APPDIR/$gtk3_immodules_cache_file"
220+
231221
EOF
232222
if [ -x "$gtk3_immodules_query" ]; then
233223
echo "Updating immodules cache in $APPDIR/$gtk3_immodules_cache_file"
@@ -264,10 +254,9 @@ gdk_pixbuf_moduledir="$(get_pkgconf_variable "gdk_pixbuf_moduledir" "gdk-pixbuf-
264254
# Note: gdk_pixbuf_query_loaders variable is not defined on some systems
265255
gdk_pixbuf_query="$(search_tool "gdk-pixbuf-query-loaders" "gdk-pixbuf-2.0")"
266256
copy_tree "$gdk_pixbuf_binarydir" "$APPDIR/"
257+
sed -i "s|$gdk_pixbuf_moduledir/||g" "$APPDIR/$gdk_pixbuf_cache_file"
267258
cat >> "$HOOKFILE" <<EOF
268-
export GDK_PIXBUF_MODULEDIR="\$APPDIR/$gdk_pixbuf_moduledir"
269-
export GDK_PIXBUF_MODULE_FILE="\$CACHEDIR/loaders.cache"
270-
sed "s|$gdk_pixbuf_moduledir|\$APPDIR/$gdk_pixbuf_moduledir|g" "\$APPDIR/$gdk_pixbuf_cache_file" > "\$GDK_PIXBUF_MODULE_FILE"
259+
export GDK_PIXBUF_MODULE_FILE="\$APPDIR/$gdk_pixbuf_cache_file"
271260
EOF
272261
if [ -x "$gdk_pixbuf_query" ]; then
273262
echo "Updating pixbuf cache in $APPDIR/$gdk_pixbuf_cache_file"
@@ -315,6 +304,7 @@ PATCH_ARRAY=(
315304
for directory in "${PATCH_ARRAY[@]}"; do
316305
while IFS= read -r -d '' file; do
317306
# shellcheck disable=SC2016
318-
patchelf --set-rpath '$ORIGIN/../../../..' "$APPDIR/$file"
307+
patchelf --set-rpath '$ORIGIN' "$APPDIR/$file"
308+
ln $verbose -s "${file/\/usr\/lib\//}" "$APPDIR/usr/lib"
319309
done < <(find "$directory" -name '*.so' -print0)
320310
done

0 commit comments

Comments
 (0)