Skip to content

Commit 8e70283

Browse files
fix(bundler): update linuxdeploy and linuxdeploy-plugin-gtk (#16062)
* fix(bundler): update linuxdeploy and linuxdeploy-plugin-gtk * actually use inline scripts again * fmt * fix(bundler): refresh cached plugin scripts, bundle on Fedora and Arch - Rewrite the embedded linuxdeploy-plugin-gtk/gstreamer scripts whenever the cached copy differs. A script left in the tools cache by an older CLI was used forever, so existing users kept `GDK_BACKEND=x11` and got no GIO module bundling. - Find gio-querymodules with search_tool: Fedora only ships gio-querymodules-64, which made the gtk plugin exit with 127. - Skip the gdk-pixbuf loaders when their directory does not exist (gdk-pixbuf 2.44 with glycin on Arch), instead of failing on `cp ''`. - Drop the old libgiognutls/GIO_EXTRA_MODULES block, now covered by GIO_MODULE_DIR. It found two copies of the module and exported a newline-separated value that included the build machine's AppDir path. * typo * chore: add change file [skip ci] --------- Co-authored-by: Lucas Nogueira <lucas@tauri.app>
1 parent 1b91b7b commit 8e70283

4 files changed

Lines changed: 163 additions & 77 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"tauri-bundler": "patch:bug"
3+
---
4+
5+
Update linuxdeploy and the GTK plugin used for AppImages, fixing `EGL_BAD_PARAMETER` crashes on newer Mesa and bundling on Fedora and Arch. AppImages no longer force `GDK_BACKEND=x11` and now use the native Wayland backend on Wayland sessions.

‎crates/tauri-bundler/src/bundle/linux/appimage/linuxdeploy-plugin-gtk.sh‎

Lines changed: 131 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ if [ "$DEBUG" != "" ]; then
1111
verbose="--verbose"
1212
fi
1313

14-
script=$(readlink -f "$0")
14+
SCRIPT="$(basename "$(readlink -f "$0")")"
1515

1616
show_usage() {
17-
echo "Usage: $script --appdir <path to AppDir>"
17+
echo "Usage: $SCRIPT --appdir <path to AppDir>"
1818
echo
1919
echo "Bundles resources for applications that use GTK into an AppDir"
2020
echo
@@ -38,13 +38,13 @@ variable_is_true() {
3838
get_pkgconf_variable() {
3939
local variable="$1"
4040
local library="$2"
41-
local default_path="$3"
41+
local default_value="$3"
4242

43-
path="$("$PKG_CONFIG" --variable="$variable" "$library")"
44-
if [ -n "$path" ]; then
45-
echo "$path"
46-
elif [ -n "$default_path" ]; then
47-
echo "$default_path"
43+
pkgconfig_ret="$("$PKG_CONFIG" --variable="$variable" "$library")"
44+
if [ -n "$pkgconfig_ret" ]; then
45+
echo "$pkgconfig_ret"
46+
elif [ -n "$default_value" ]; then
47+
echo "$default_value"
4848
else
4949
echo "$0: there is no '$variable' variable for '$library' library." > /dev/stderr
5050
echo "Please check the '$library.pc' file is present in \$PKG_CONFIG_PATH (you may need to install the appropriate -dev/-devel package)." > /dev/stderr
@@ -62,6 +62,44 @@ copy_tree() {
6262
done
6363
}
6464

65+
copy_lib_tree() {
66+
# The source lib directory could be /usr/lib, /usr/lib64, or /usr/lib/x86_64-linux-gnu
67+
# Therefore, when copying lib directories, we need to transform that target path
68+
# to a consistent /usr/lib
69+
local src=("${@:1:$#-1}")
70+
local dst="${*:$#}"
71+
72+
for elem in "${src[@]}"; do
73+
mkdir -p "${dst::-1}${elem/$LD_GTK_LIBRARY_PATH//usr/lib}"
74+
pushd "$LD_GTK_LIBRARY_PATH"
75+
cp "$(realpath --relative-to="$LD_GTK_LIBRARY_PATH" "$elem")" --archive --parents --target-directory="$dst/usr/lib" $verbose
76+
popd
77+
done
78+
}
79+
80+
get_triplet_path() {
81+
if command -v dpkg-architecture > /dev/null; then
82+
echo "/usr/lib/$(dpkg-architecture -qDEB_HOST_MULTIARCH)"
83+
fi
84+
}
85+
86+
87+
88+
search_library_path() {
89+
PATH_ARRAY=(
90+
"$(get_triplet_path)"
91+
"/usr/lib64"
92+
"/usr/lib"
93+
)
94+
95+
for path in "${PATH_ARRAY[@]}"; do
96+
if [ -d "$path" ]; then
97+
echo "$path"
98+
return 0
99+
fi
100+
done
101+
}
102+
65103
search_tool() {
66104
local tool="$1"
67105
local directory="$2"
@@ -71,7 +109,8 @@ search_tool() {
71109
fi
72110

73111
PATH_ARRAY=(
74-
"/usr/lib/$(uname -m)-linux-gnu/$directory/$tool"
112+
"$(get_triplet_path)/$directory/$tool"
113+
"/usr/lib64/$directory/$tool"
75114
"/usr/lib/$directory/$tool"
76115
"/usr/bin/$tool"
77116
"/usr/bin/$tool-64"
@@ -119,10 +158,19 @@ if [ "$APPDIR" == "" ]; then
119158
exit 1
120159
fi
121160

161+
APPDIR="$(realpath "$APPDIR")"
122162
mkdir -p "$APPDIR"
123163
# make lib64 writable again.
124164
chmod +w "$APPDIR"/usr/lib64 || true
125165

166+
. /etc/os-release
167+
if [ "$ID" = "debian" ] || [ "$ID" = "ubuntu" ]; then
168+
if ! command -v dpkg-architecture &>/dev/null; then
169+
echo -e "$0: dpkg-architecture not found.\nInstall dpkg-dev then re-run the plugin."
170+
exit 1
171+
fi
172+
fi
173+
126174
if command -v pkgconf > /dev/null; then
127175
PKG_CONFIG="pkgconf"
128176
elif command -v pkg-config > /dev/null; then
@@ -132,6 +180,9 @@ else
132180
exit 1
133181
fi
134182

183+
# GTK's library path *must not* have a trailing slash for later parameter substitution to work properly
184+
LD_GTK_LIBRARY_PATH="$(realpath "${LD_GTK_LIBRARY_PATH:-$(search_library_path)}")"
185+
135186
if ! command -v find &>/dev/null && ! type find &>/dev/null; then
136187
echo -e "$0: find not found.\nInstall findutils then re-run the plugin."
137188
exit 1
@@ -178,13 +229,21 @@ mkdir -p "$HOOKSDIR"
178229
cat > "$HOOKFILE" <<\EOF
179230
#! /usr/bin/env bash
180231
181-
gsettings get org.gnome.desktop.interface gtk-theme 2> /dev/null | grep -qi "dark" && GTK_THEME_VARIANT="dark" || GTK_THEME_VARIANT="light"
232+
COLOR_SCHEME="$(dbus-send --session --dest=org.freedesktop.portal.Desktop --type=method_call --print-reply --reply-timeout=1000 /org/freedesktop/portal/desktop org.freedesktop.portal.Settings.Read 'string:org.freedesktop.appearance' 'string:color-scheme' 2> /dev/null | tail -n1 | cut -b35- | cut -d' ' -f2 || printf '')"
233+
if [ -z "$COLOR_SCHEME" ]; then
234+
COLOR_SCHEME="$(gsettings get org.gnome.desktop.interface color-scheme 2> /dev/null || printf '')"
235+
fi
236+
case "$COLOR_SCHEME" in
237+
"1"|"'prefer-dark'") GTK_THEME_VARIANT="dark";;
238+
"2"|"'prefer-light'") GTK_THEME_VARIANT="light";;
239+
*) GTK_THEME_VARIANT="light";;
240+
esac
182241
APPIMAGE_GTK_THEME="${APPIMAGE_GTK_THEME:-"Adwaita:$GTK_THEME_VARIANT"}" # Allow user to override theme (discouraged)
183242
184243
export APPDIR="${APPDIR:-"$(dirname "$(realpath "$0")")"}" # Workaround to run extracted AppImage
185244
export GTK_DATA_PREFIX="$APPDIR"
186245
export GTK_THEME="$APPIMAGE_GTK_THEME" # Custom themes are broken
187-
export GDK_BACKEND="${GDK_BACKEND:-x11}" # Crash with Wayland backend on Wayland - We tested it without it and ended up with this: https://github.com/tauri-apps/tauri/issues/8541
246+
# export GDK_BACKEND=x11 # Monitor this closely. AppImage used to crash on Wayland!
188247
export XDG_DATA_DIRS="$APPDIR/usr/share:/usr/share:$XDG_DATA_DIRS" # g_get_system_data_dirs() from GLib
189248
EOF
190249

@@ -197,47 +256,67 @@ cat >> "$HOOKFILE" <<EOF
197256
export GSETTINGS_SCHEMA_DIR="\$APPDIR/$glib_schemasdir"
198257
EOF
199258

259+
echo "Installing GIRepository Typelibs"
260+
gi_typelibsdir="$(get_pkgconf_variable "typelibdir" "gobject-introspection-1.0" "$LD_GTK_LIBRARY_PATH/girepository-1.0")"
261+
copy_lib_tree "$gi_typelibsdir" "$APPDIR/"
262+
cat >> "$HOOKFILE" <<EOF
263+
export GI_TYPELIB_PATH="\$APPDIR/${gi_typelibsdir/$LD_GTK_LIBRARY_PATH//usr/lib}"
264+
EOF
265+
266+
echo "Installing Gio modules"
267+
gio_moduledir="$(get_pkgconf_variable "giomoduledir" "gio-2.0" "$LD_GTK_LIBRARY_PATH/gio/modules")"
268+
copy_lib_tree "$gio_moduledir" "$APPDIR/"
269+
gio_querymodules="$(search_tool "gio-querymodules" "glib-2.0")"
270+
if [ -x "$gio_querymodules" ]; then
271+
"$gio_querymodules" "$APPDIR/${gio_moduledir/$LD_GTK_LIBRARY_PATH//usr/lib}"
272+
else
273+
echo "WARNING: gio-querymodules not found"
274+
fi
275+
cat >> "$HOOKFILE" <<EOF
276+
export GIO_MODULE_DIR="\$APPDIR/${gio_moduledir/$LD_GTK_LIBRARY_PATH//usr/lib}"
277+
EOF
278+
200279
case "$DEPLOY_GTK_VERSION" in
201280
2)
202281
# https://github.com/linuxdeploy/linuxdeploy-plugin-gtk/pull/20#issuecomment-826354261
203282
echo "WARNING: Gtk+2 applications are not fully supported by this plugin"
204283
;;
205284
3)
206285
echo "Installing GTK 3.0 modules"
207-
gtk3_exec_prefix="$(get_pkgconf_variable "exec_prefix" "gtk+-3.0")"
208-
gtk3_libdir="$(get_pkgconf_variable "libdir" "gtk+-3.0")/gtk-3.0"
209-
#gtk3_path="$gtk3_libdir/modules" export GTK_PATH="\$APPDIR/$gtk3_path"
210-
gtk3_immodulesdir="$gtk3_libdir/$(get_pkgconf_variable "gtk_binary_version" "gtk+-3.0")/immodules"
211-
gtk3_printbackendsdir="$gtk3_libdir/$(get_pkgconf_variable "gtk_binary_version" "gtk+-3.0")/printbackends"
286+
gtk3_exec_prefix="$(get_pkgconf_variable "exec_prefix" "gtk+-3.0" "/usr")"
287+
gtk3_libdir="$(get_pkgconf_variable "libdir" "gtk+-3.0" "$LD_GTK_LIBRARY_PATH")/gtk-3.0"
288+
gtk3_path="$gtk3_libdir"
289+
gtk3_immodulesdir="$gtk3_libdir/$(get_pkgconf_variable "gtk_binary_version" "gtk+-3.0" "3.0.0")/immodules"
290+
gtk3_printbackendsdir="$gtk3_libdir/$(get_pkgconf_variable "gtk_binary_version" "gtk+-3.0" "3.0.0")/printbackends"
212291
gtk3_immodules_cache_file="$(dirname "$gtk3_immodulesdir")/immodules.cache"
213292
gtk3_immodules_query="$(search_tool "gtk-query-immodules-3.0" "libgtk-3-0")"
214-
copy_tree "$gtk3_libdir" "$APPDIR/"
293+
copy_lib_tree "$gtk3_libdir" "$APPDIR/"
215294
cat >> "$HOOKFILE" <<EOF
216295
export GTK_EXE_PREFIX="\$APPDIR/$gtk3_exec_prefix"
217-
export GTK_PATH="\$APPDIR/$gtk3_libdir:/usr/lib64/gtk-3.0:/usr/lib/x86_64-linux-gnu/gtk-3.0"
218-
export GTK_IM_MODULE_FILE="\$APPDIR/$gtk3_immodules_cache_file"
219-
296+
export GTK_PATH="\$APPDIR/${gtk3_path/$LD_GTK_LIBRARY_PATH//usr/lib}"
297+
export GTK_IM_MODULE_FILE="\$APPDIR/${gtk3_immodules_cache_file/$LD_GTK_LIBRARY_PATH//usr/lib}"
220298
EOF
299+
221300
if [ -x "$gtk3_immodules_query" ]; then
222-
echo "Updating immodules cache in $APPDIR/$gtk3_immodules_cache_file"
223-
"$gtk3_immodules_query" > "$APPDIR/$gtk3_immodules_cache_file"
301+
echo "Updating immodules cache in $APPDIR/${gtk3_immodules_cache_file/$LD_GTK_LIBRARY_PATH//usr/lib}"
302+
"$gtk3_immodules_query" > "$APPDIR/${gtk3_immodules_cache_file/$LD_GTK_LIBRARY_PATH//usr/lib}"
224303
else
225304
echo "WARNING: gtk-query-immodules-3.0 not found"
226305
fi
227-
if [ ! -f "$APPDIR/$gtk3_immodules_cache_file" ]; then
306+
if [ ! -f "$APPDIR/${gtk3_immodules_cache_file/$LD_GTK_LIBRARY_PATH//usr/lib}" ]; then
228307
echo "WARNING: immodules.cache file is missing"
229308
fi
230-
sed -i "s|$gtk3_libdir/3.0.0/immodules/||g" "$APPDIR/$gtk3_immodules_cache_file"
309+
sed -i "s|$gtk3_libdir/3.0.0/immodules/||g" "$APPDIR/${gtk3_immodules_cache_file/$LD_GTK_LIBRARY_PATH//usr/lib}"
231310
;;
232311
4)
233312
echo "Installing GTK 4.0 modules"
234313
gtk4_exec_prefix="$(get_pkgconf_variable "exec_prefix" "gtk4" "/usr")"
235314
gtk4_libdir="$(get_pkgconf_variable "libdir" "gtk4")/gtk-4.0"
236-
gtk4_path="$gtk4_libdir/modules"
237-
copy_tree "$gtk4_libdir" "$APPDIR/"
315+
gtk4_path="$gtk4_libdir"
316+
copy_lib_tree "$gtk4_libdir" "$APPDIR/"
238317
cat >> "$HOOKFILE" <<EOF
239318
export GTK_EXE_PREFIX="\$APPDIR/$gtk4_exec_prefix"
240-
export GTK_PATH="\$APPDIR/$gtk4_path"
319+
export GTK_PATH="\$APPDIR/${gtk4_path/$LD_GTK_LIBRARY_PATH//usr/lib}"
241320
EOF
242321
;;
243322
*)
@@ -247,39 +326,43 @@ EOF
247326
esac
248327

249328
echo "Installing GDK PixBufs"
250-
gdk_libdir="$(get_pkgconf_variable "libdir" "gdk-pixbuf-2.0")"
251-
gdk_pixbuf_binarydir="$(get_pkgconf_variable "gdk_pixbuf_binarydir" "gdk-pixbuf-2.0")"
252-
gdk_pixbuf_cache_file="$(get_pkgconf_variable "gdk_pixbuf_cache_file" "gdk-pixbuf-2.0")"
253-
gdk_pixbuf_moduledir="$(get_pkgconf_variable "gdk_pixbuf_moduledir" "gdk-pixbuf-2.0")"
329+
gdk_libdir="$(get_pkgconf_variable "libdir" "gdk-pixbuf-2.0" "$LD_GTK_LIBRARY_PATH")"
330+
gdk_pixbuf_binarydir="$(get_pkgconf_variable "gdk_pixbuf_binarydir" "gdk-pixbuf-2.0" "$gdk_libdir/gdk-pixbuf-2.0/2.10.0")"
331+
gdk_pixbuf_cache_file="$(get_pkgconf_variable "gdk_pixbuf_cache_file" "gdk-pixbuf-2.0" "$gdk_pixbuf_binarydir/loaders.cache")"
332+
gdk_pixbuf_moduledir="$(get_pkgconf_variable "gdk_pixbuf_moduledir" "gdk-pixbuf-2.0" "$gdk_pixbuf_binarydir/loaders")"
254333
# Note: gdk_pixbuf_query_loaders variable is not defined on some systems
255334
gdk_pixbuf_query="$(search_tool "gdk-pixbuf-query-loaders" "gdk-pixbuf-2.0")"
256-
copy_tree "$gdk_pixbuf_binarydir" "$APPDIR/"
335+
if [ -d "$gdk_pixbuf_binarydir" ]; then
336+
copy_lib_tree "$gdk_pixbuf_binarydir" "$APPDIR/"
257337
cat >> "$HOOKFILE" <<EOF
258-
export GDK_PIXBUF_MODULE_FILE="\$APPDIR/$gdk_pixbuf_cache_file"
338+
export GDK_PIXBUF_MODULE_FILE="\$APPDIR/${gdk_pixbuf_cache_file/$LD_GTK_LIBRARY_PATH//usr/lib}"
259339
EOF
260340
if [ -x "$gdk_pixbuf_query" ]; then
261-
echo "Updating pixbuf cache in $APPDIR/$gdk_pixbuf_cache_file"
262-
"$gdk_pixbuf_query" > "$APPDIR/$gdk_pixbuf_cache_file"
341+
echo "Updating pixbuf cache in $APPDIR/${gdk_pixbuf_cache_file/$LD_GTK_LIBRARY_PATH//usr/lib}"
342+
"$gdk_pixbuf_query" > "$APPDIR/${gdk_pixbuf_cache_file/$LD_GTK_LIBRARY_PATH//usr/lib}"
263343
else
264344
echo "WARNING: gdk-pixbuf-query-loaders not found"
265345
fi
266-
if [ ! -f "$APPDIR/$gdk_pixbuf_cache_file" ]; then
346+
if [ ! -f "$APPDIR/${gdk_pixbuf_cache_file/$LD_GTK_LIBRARY_PATH//usr/lib}" ]; then
267347
echo "WARNING: loaders.cache file is missing"
268348
fi
269-
sed -i "s|$gdk_pixbuf_moduledir/||g" "$APPDIR/$gdk_pixbuf_cache_file"
349+
sed -i "s|$gdk_pixbuf_moduledir/||g" "$APPDIR/${gdk_pixbuf_cache_file/$LD_GTK_LIBRARY_PATH//usr/lib}"
350+
else
351+
echo "WARNING: $gdk_pixbuf_binarydir not found, not bundling gdk-pixbuf loaders"
352+
fi
270353

271354
echo "Copying more libraries"
272-
gobject_libdir="$(get_pkgconf_variable "libdir" "gobject-2.0")"
273-
gio_libdir="$(get_pkgconf_variable "libdir" "gio-2.0")"
274-
librsvg_libdir="$(get_pkgconf_variable "libdir" "librsvg-2.0")"
275-
pango_libdir="$(get_pkgconf_variable "libdir" "pango")"
276-
pangocairo_libdir="$(get_pkgconf_variable "libdir" "pangocairo")"
277-
pangoft2_libdir="$(get_pkgconf_variable "libdir" "pangoft2")"
355+
gobject_libdir="$(get_pkgconf_variable "libdir" "gobject-2.0" "$LD_GTK_LIBRARY_PATH")"
356+
gio_libdir="$(get_pkgconf_variable "libdir" "gio-2.0" "$LD_GTK_LIBRARY_PATH")"
357+
librsvg_libdir="$(get_pkgconf_variable "libdir" "librsvg-2.0" "$LD_GTK_LIBRARY_PATH")"
358+
pango_libdir="$(get_pkgconf_variable "libdir" "pango" "$LD_GTK_LIBRARY_PATH")"
359+
pangocairo_libdir="$(get_pkgconf_variable "libdir" "pangocairo" "$LD_GTK_LIBRARY_PATH")"
360+
pangoft2_libdir="$(get_pkgconf_variable "libdir" "pangoft2" "$LD_GTK_LIBRARY_PATH")"
278361
FIND_ARRAY=(
279-
"$gdk_libdir" "libgdk_pixbuf-*.so*"
280-
"$gobject_libdir" "libgobject-*.so*"
281-
"$gio_libdir" "libgio-*.so*"
282-
"$librsvg_libdir" "librsvg-*.so*"
362+
"$gdk_libdir" "libgdk_pixbuf-*.so*"
363+
"$gobject_libdir" "libgobject-*.so*"
364+
"$gio_libdir" "libgio-*.so*"
365+
"$librsvg_libdir" "librsvg-*.so*"
283366
"$pango_libdir" "libpango-*.so*"
284367
"$pangocairo_libdir" "libpangocairo-*.so*"
285368
"$pangoft2_libdir" "libpangoft2-*.so*"
@@ -305,22 +388,13 @@ PATCH_ARRAY=(
305388
)
306389
for directory in "${PATCH_ARRAY[@]}"; do
307390
while IFS= read -r -d '' file; do
308-
ln $verbose -s "${file/\/usr\/lib\//}" "$APPDIR/usr/lib"
391+
ln $verbose -sf "${file/$LD_GTK_LIBRARY_PATH\//}" "$APPDIR/usr/lib"
309392
done < <(find "$directory" -name '*.so' -print0)
310393
done
311394

312395
# set write permission on lib64 again to make it deletable.
313396
chmod +w "$APPDIR"/usr/lib64 || true
314397

315-
# We have to copy the files first to not get permission errors when we assign gio_extras_dir
316-
find /usr/lib* -name libgiognutls.so -exec mkdir -p "$APPDIR"/"$(dirname '{}')" \; -exec cp --parents '{}' "$APPDIR/" \; || true
317-
# related files that we seemingly don't need:
318-
# libgiolibproxy.so - libgiognomeproxy.so - glib-pacrunner
319-
320-
gio_extras_dir=$(find "$APPDIR"/usr/lib* -name libgiognutls.so -exec dirname '{}' \; 2>/dev/null)
321-
cat >> "$HOOKFILE" <<EOF
322-
export GIO_EXTRA_MODULES="\$APPDIR/${gio_extras_dir#"$APPDIR"/}"
323-
EOF
324398

325399
#binary patch absolute paths in libwebkit files
326400
find "$APPDIR"/usr/lib* -name 'libwebkit*' -exec sed -i -e "s|/usr|././|g" '{}' \;

‎crates/tauri-bundler/src/bundle/linux/appimage/linuxdeploy.rs‎

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -206,47 +206,54 @@ pub fn bundle_project(settings: &Settings) -> crate::Result<Vec<PathBuf>> {
206206

207207
// returns the linuxdeploy path to keep linuxdeploy_arch contained
208208
fn prepare_tools(tools_path: &Path, arch: &str, verbose: bool) -> crate::Result<PathBuf> {
209+
const LINUXDEPLOY_COMMIT_HASH: &str = "07333c6";
210+
209211
let apprun = tools_path.join(format!("AppRun-{arch}"));
210212
if !apprun.exists() {
211213
let data = download(&format!(
212214
"https://github.com/tauri-apps/binary-releases/releases/download/apprun-old/AppRun-{arch}"
213215
))?;
214-
write_and_make_executable(&apprun, data)?;
216+
write_and_make_executable(&apprun, &data)?;
215217
}
216218

217219
let linuxdeploy_arch = if arch == "i686" { "i386" } else { arch };
218-
let linuxdeploy = tools_path.join(format!("linuxdeploy-{linuxdeploy_arch}.AppImage"));
220+
let linuxdeploy = tools_path.join(format!(
221+
"linuxdeploy-{LINUXDEPLOY_COMMIT_HASH}-{linuxdeploy_arch}.AppImage"
222+
));
219223
if !linuxdeploy.exists() {
220224
let data = download(&format!(
221-
"https://github.com/tauri-apps/binary-releases/releases/download/linuxdeploy/linuxdeploy-{linuxdeploy_arch}.AppImage"
225+
"https://github.com/tauri-apps/binary-releases/releases/download/linuxdeploy-{LINUXDEPLOY_COMMIT_HASH}/linuxdeploy-{linuxdeploy_arch}.AppImage"
222226
))?;
223-
write_and_make_executable(&linuxdeploy, data)?;
224-
}
225-
226-
let gtk = tools_path.join("linuxdeploy-plugin-gtk.sh");
227-
if !gtk.exists() {
228-
let data = download(
229-
"https://raw.githubusercontent.com/tauri-apps/linuxdeploy-plugin-gtk/master/linuxdeploy-plugin-gtk.sh",
230-
)?;
231-
write_and_make_executable(&gtk, data)?;
227+
write_and_make_executable(&linuxdeploy, &data)?;
232228
}
233229

234-
let gstreamer = tools_path.join("linuxdeploy-plugin-gstreamer.sh");
235-
if !gstreamer.exists() {
236-
let data = download(
237-
"https://raw.githubusercontent.com/tauri-apps/linuxdeploy-plugin-gstreamer/master/linuxdeploy-plugin-gstreamer.sh",
238-
)?;
239-
write_and_make_executable(&gstreamer, data)?;
230+
// The plugin scripts are embedded, so rewrite them whenever the cached copy differs:
231+
// a copy left behind by an older CLI would otherwise be used forever.
232+
for (name, data) in [
233+
(
234+
"linuxdeploy-plugin-gtk.sh",
235+
include_bytes!("./linuxdeploy-plugin-gtk.sh").as_slice(),
236+
),
237+
(
238+
"linuxdeploy-plugin-gstreamer.sh",
239+
include_bytes!("./linuxdeploy-plugin-gstreamer.sh").as_slice(),
240+
),
241+
] {
242+
let path = tools_path.join(name);
243+
if fs::read(&path).ok().as_deref() != Some(data) {
244+
write_and_make_executable(&path, data)?;
245+
}
240246
}
241247

242248
let appimage = tools_path.join("linuxdeploy-plugin-appimage.AppImage");
243249
if !appimage.exists() {
244250
// This is optional, linuxdeploy will fall back to its built-in version if the download failed.
251+
// Since switching to linuxdeploy-07333c6 this shouldn't be necessary anymore, but we keep it here for now just for fun.
245252
let data = download(&format!(
246253
"https://github.com/linuxdeploy/linuxdeploy-plugin-appimage/releases/download/continuous/linuxdeploy-plugin-appimage-{arch}.AppImage"
247254
));
248255
match data {
249-
Ok(data) => write_and_make_executable(&appimage, data)?,
256+
Ok(data) => write_and_make_executable(&appimage, &data)?,
250257
Err(err) => {
251258
log::error!("Download of AppImage plugin failed. Using older built-in version instead.");
252259
if verbose {

0 commit comments

Comments
 (0)