Skip to content

Commit 7f710b8

Browse files
authored
fix(bundler): inline linuxdeploy plugin scripts (#14390)
1 parent bda1d22 commit 7f710b8

File tree

4 files changed

+503
-6
lines changed

4 files changed

+503
-6
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
tauri-bundler: "patch:enhance"
3+
---
4+
5+
Inline linuxdeploy plugins which were previously downloaded from `https://raw.githubusercontent.com` which lately blocks many users with a 429 error.
Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
#! /bin/bash
2+
3+
# abort on all errors
4+
set -e
5+
6+
if [ "$DEBUG" != "" ]; then
7+
set -x
8+
fi
9+
10+
script=$(readlink -f "$0")
11+
12+
show_usage() {
13+
echo "Usage: $script --appdir <path to AppDir>"
14+
echo
15+
echo "Bundles GStreamer plugins into an AppDir"
16+
echo
17+
echo "Required variables:"
18+
echo " LINUXDEPLOY=\".../linuxdeploy\" path to linuxdeploy (e.g., AppImage); set automatically when plugin is run directly by linuxdeploy"
19+
echo
20+
echo "Optional variables:"
21+
echo " GSTREAMER_INCLUDE_BAD_PLUGINS=\"1\" (default: disabled; set to empty string or unset to disable)"
22+
echo " GSTREAMER_PLUGINS_DIR=\"...\" (directory containing GStreamer plugins; default: guessed based on main distro architecture)"
23+
echo " GSTREAMER_HELPERS_DIR=\"...\" (directory containing GStreamer helper tools like gst-plugin-scanner; default: guessed based on main distro architecture)"
24+
echo " GSTREAMER_VERSION=\"1.0\" (default: 1.0)"
25+
}
26+
27+
while [ "$1" != "" ]; do
28+
case "$1" in
29+
--plugin-api-version)
30+
echo "0"
31+
exit 0
32+
;;
33+
--appdir)
34+
APPDIR="$2"
35+
shift
36+
shift
37+
;;
38+
--help)
39+
show_usage
40+
exit 0
41+
;;
42+
*)
43+
echo "Invalid argument: $1"
44+
echo
45+
show_usage
46+
exit 1
47+
;;
48+
esac
49+
done
50+
51+
if [ "$APPDIR" == "" ]; then
52+
show_usage
53+
exit 1
54+
fi
55+
56+
if ! which patchelf &>/dev/null && ! type patchelf &>/dev/null; then
57+
echo "Error: patchelf not found"
58+
echo
59+
show_usage
60+
exit 2
61+
fi
62+
63+
if [[ "$LINUXDEPLOY" == "" ]]; then
64+
echo "Error: \$LINUXDEPLOY not set"
65+
echo
66+
show_usage
67+
exit 3
68+
fi
69+
70+
mkdir -p "$APPDIR"
71+
72+
export GSTREAMER_VERSION="${GSTREAMER_VERSION:-1.0}"
73+
74+
plugins_target_dir="$APPDIR"/usr/lib/gstreamer-"$GSTREAMER_VERSION"
75+
helpers_target_dir="$APPDIR"/usr/lib/gstreamer"$GSTREAMER_VERSION"/gstreamer-"$GSTREAMER_VERSION"
76+
77+
if [ "$GSTREAMER_PLUGINS_DIR" != "" ]; then
78+
plugins_dir="${GSTREAMER_PLUGINS_DIR}"
79+
elif [ -d /usr/lib/"$(uname -m)"-linux-gnu/gstreamer-"$GSTREAMER_VERSION" ]; then
80+
plugins_dir=/usr/lib/$(uname -m)-linux-gnu/gstreamer-"$GSTREAMER_VERSION"
81+
else
82+
plugins_dir=/usr/lib/gstreamer-"$GSTREAMER_VERSION"
83+
fi
84+
85+
if [ "$GSTREAMER_HELPERS_DIR" != "" ]; then
86+
helpers_dir="${GSTREAMER_HELPERS_DIR}"
87+
else
88+
helpers_dir=/usr/lib/$(uname -m)-linux-gnu/gstreamer"$GSTREAMER_VERSION"/gstreamer-"$GSTREAMER_VERSION"
89+
fi
90+
91+
if [ ! -d "$plugins_dir" ]; then
92+
echo "Error: could not find plugins directory: $plugins_dir"
93+
exit 1
94+
fi
95+
96+
mkdir -p "$plugins_target_dir"
97+
98+
echo "Copying plugins into $plugins_target_dir"
99+
for i in "$plugins_dir"/*; do
100+
[ -d "$i" ] && continue
101+
[ ! -f "$i" ] && echo "File does not exist: $i" && continue
102+
103+
echo "Copying plugin: $i"
104+
cp "$i" "$plugins_target_dir"
105+
done
106+
107+
"$LINUXDEPLOY" --appdir "$APPDIR"
108+
109+
for i in "$plugins_target_dir"/*; do
110+
[ -d "$i" ] && continue
111+
[ ! -f "$i" ] && echo "File does not exist: $i" && continue
112+
(file "$i" | grep -v ELF --silent) && echo "Ignoring non ELF file: $i" && continue
113+
114+
echo "Manually setting rpath for $i"
115+
patchelf --set-rpath '$ORIGIN/..:$ORIGIN' "$i"
116+
done
117+
118+
mkdir -p "$helpers_target_dir"
119+
120+
echo "Copying helpers in $helpers_target_dir"
121+
for i in "$helpers_dir"/*; do
122+
[ -d "$i" ] && continue
123+
[ ! -f "$i" ] && echo "File does not exist: $i" && continue
124+
125+
echo "Copying helper: $i"
126+
cp "$i" "$helpers_target_dir"
127+
done
128+
129+
for i in "$helpers_target_dir"/*; do
130+
[ -d "$i" ] && continue
131+
[ ! -f "$i" ] && echo "File does not exist: $i" && continue
132+
(file "$i" | grep -v ELF --silent) && echo "Ignoring non ELF file: $i" && continue
133+
134+
echo "Manually setting rpath for $i"
135+
patchelf --set-rpath '$ORIGIN/../..' "$i"
136+
done
137+
138+
echo "Installing AppRun hook"
139+
mkdir -p "$APPDIR"/apprun-hooks
140+
141+
if [ "$GSTREAMER_VERSION" == "1.0" ]; then
142+
cat > "$APPDIR"/apprun-hooks/linuxdeploy-plugin-gstreamer.sh <<\EOF
143+
#! /bin/bash
144+
145+
export GST_REGISTRY_REUSE_PLUGIN_SCANNER="no"
146+
export GST_PLUGIN_SYSTEM_PATH_1_0="${APPDIR}/usr/lib/gstreamer-1.0"
147+
export GST_PLUGIN_PATH_1_0="${APPDIR}/usr/lib/gstreamer-1.0"
148+
149+
export GST_PLUGIN_SCANNER_1_0="${APPDIR}/usr/lib/gstreamer1.0/gstreamer-1.0/gst-plugin-scanner"
150+
export GST_PTP_HELPER_1_0="${APPDIR}/usr/lib/gstreamer1.0/gstreamer-1.0/gst-ptp-helper"
151+
EOF
152+
elif [ "$GSTREAMER_VERSION" == "0.10" ]; then
153+
cat > "$APPDIR"/apprun-hooks/linuxdeploy-plugin-gstreamer.sh <<\EOF
154+
#! /bin/bash
155+
156+
export GST_REGISTRY_REUSE_PLUGIN_SCANNER="no"
157+
export GST_PLUGIN_SYSTEM_PATH_0_10="${APPDIR}/usr/lib/gstreamer-1.0"
158+
159+
export GST_PLUGIN_SCANNER_0_10="${APPDIR}/usr/lib/gstreamer1.0/gstreamer-1.0/gst-plugin-scanner"
160+
export GST_PTP_HELPER_0_10="${APPDIR}/usr/lib/gstreamer1.0/gstreamer-1.0/gst-ptp-helper"
161+
EOF
162+
else
163+
echo "Warning: unknown GStreamer version: $GSTREAMER_VERSION, cannot install AppRun hook"
164+
fi
165+

0 commit comments

Comments
 (0)