Skip to content

Commit f46da60

Browse files
Do not hardcode '/usr/lib/x86_64-linux-gnu' as fallback
Fix #40 --------- Co-authored-by: TheAssassin <[email protected]>
1 parent e0d1f95 commit f46da60

File tree

5 files changed

+39
-23
lines changed

5 files changed

+39
-23
lines changed

.github/workflows/main.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
- name: Setup dependencies
1919
run: |
2020
sudo apt-get update -y -qq
21-
sudo apt-get install -y -qq libgtk-3-0 libgtk-3-dev gir1.2-gtk-3.0 wget tree
21+
sudo apt-get install -y -qq libgtk-3-0 libgtk-3-dev gir1.2-gtk-3.0 wget tree libgirepository1.0-dev libfuse2
2222
2323
- name: Download external binairies
2424
run: |

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ This plugin requires the following dependencies in order to work properly:
1111
- `pkg-config` or `pkgconf` command
1212
- librsvg2 development files
1313
- GTK development files
14+
- GObject Introspection development files
1415

1516
## Usage
1617

containers/gtk3/Dockerfile.ubuntu

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ ARG TZ=UTC
77
RUN ln -snf "/usr/share/zoneinfo/$TZ" "/etc/localtime" && echo "$TZ" > /etc/timezone
88
RUN apt-get update && \
99
apt-get install -y wget librsvg2-dev file findutils pkg-config libgtk-3-0 \
10-
libgtk-3-dev gtk-3-examples gir1.2-gtk-3.0
10+
libgtk-3-dev gtk-3-examples gir1.2-gtk-3.0 libfuse2
1111
COPY . .
1212
ADD "https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage" .
1313
RUN chmod +x *.sh *.AppImage

containers/gtk4/Dockerfile.ubuntu

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ ARG TZ=UTC
77
RUN ln -snf "/usr/share/zoneinfo/$TZ" "/etc/localtime" && echo "$TZ" > /etc/timezone
88
RUN apt-get update && \
99
apt-get install -y wget librsvg2-dev file findutils pkg-config libgtk-4-1 \
10-
libgtk-4-dev gtk-4-examples gir1.2-gtk-4.0
10+
libgtk-4-dev gtk-4-examples gir1.2-gtk-4.0 libfuse2
1111
COPY . .
1212
ADD "https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage" .
1313
RUN chmod +x *.sh *.AppImage

linuxdeploy-plugin-gtk.sh

+35-20
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,20 @@ copy_tree() {
6262
done
6363
}
6464

65+
search_library_path() {
66+
PATH_ARRAY=(
67+
"/usr/lib/$(uname -m)-linux-gnu"
68+
"/usr/lib"
69+
)
70+
71+
for path in "${PATH_ARRAY[@]}"; do
72+
if [ -d "$path" ]; then
73+
echo "$path"
74+
return 0
75+
fi
76+
done
77+
}
78+
6579
search_tool() {
6680
local tool="$1"
6781
local directory="$2"
@@ -128,6 +142,7 @@ else
128142
echo "$0: pkg-config/pkgconf not found in PATH, aborting"
129143
exit 1
130144
fi
145+
LD_GTK_LIBRARY_PATH="${LD_GTK_LIBRARY_PATH:-$(search_library_path)}"
131146

132147
if ! command -v find &>/dev/null && ! type find &>/dev/null; then
133148
echo -e "$0: find not found.\nInstall findutils then re-run the plugin."
@@ -195,7 +210,7 @@ export GSETTINGS_SCHEMA_DIR="\$APPDIR/$glib_schemasdir"
195210
EOF
196211

197212
echo "Installing GIRepository Typelibs"
198-
gi_typelibsdir="$(get_pkgconf_variable "typelibdir" "gobject-introspection-1.0" "/usr/lib/x86_64-linux-gnu/girepository-1.0")"
213+
gi_typelibsdir="$(get_pkgconf_variable "typelibdir" "gobject-introspection-1.0" "$LD_GTK_LIBRARY_PATH/girepository-1.0")"
199214
copy_tree "$gi_typelibsdir" "$APPDIR/"
200215
cat >> "$HOOKFILE" <<EOF
201216
export GI_TYPELIB_PATH="\$APPDIR/$gi_typelibsdir"
@@ -209,7 +224,7 @@ case "$DEPLOY_GTK_VERSION" in
209224
3)
210225
echo "Installing GTK 3.0 modules"
211226
gtk3_exec_prefix="$(get_pkgconf_variable "exec_prefix" "gtk+-3.0" "/usr")"
212-
gtk3_libdir="$(get_pkgconf_variable "libdir" "gtk+-3.0" "/usr/lib/x86_64-linux-gnu")/gtk-3.0"
227+
gtk3_libdir="$(get_pkgconf_variable "libdir" "gtk+-3.0" "$LD_GTK_LIBRARY_PATH")/gtk-3.0"
213228
gtk3_path="$gtk3_libdir"
214229
gtk3_immodulesdir="$gtk3_libdir/$(get_pkgconf_variable "gtk_binary_version" "gtk+-3.0" "3.0.0")/immodules"
215230
gtk3_printbackendsdir="$gtk3_libdir/$(get_pkgconf_variable "gtk_binary_version" "gtk+-3.0" "3.0.0")/printbackends"
@@ -251,10 +266,10 @@ EOF
251266
esac
252267

253268
echo "Installing GDK PixBufs"
254-
gdk_libdir="$(get_pkgconf_variable "libdir" "gdk-pixbuf-2.0" "/usr/lib/x86_64-linux-gnu")"
255-
gdk_pixbuf_binarydir="$(get_pkgconf_variable "gdk_pixbuf_binarydir" "gdk-pixbuf-2.0" "$gdk_libdir""/gdk-pixbuf-2.0/2.10.0")"
256-
gdk_pixbuf_cache_file="$(get_pkgconf_variable "gdk_pixbuf_cache_file" "gdk-pixbuf-2.0" "$gdk_pixbuf_binarydir""/loaders.cache")"
257-
gdk_pixbuf_moduledir="$(get_pkgconf_variable "gdk_pixbuf_moduledir" "gdk-pixbuf-2.0" "$gdk_pixbuf_binarydir""/loaders")"
269+
gdk_libdir="$(get_pkgconf_variable "libdir" "gdk-pixbuf-2.0" "$LD_GTK_LIBRARY_PATH")"
270+
gdk_pixbuf_binarydir="$(get_pkgconf_variable "gdk_pixbuf_binarydir" "gdk-pixbuf-2.0" "$gdk_libdir/gdk-pixbuf-2.0/2.10.0")"
271+
gdk_pixbuf_cache_file="$(get_pkgconf_variable "gdk_pixbuf_cache_file" "gdk-pixbuf-2.0" "$gdk_pixbuf_binarydir/loaders.cache")"
272+
gdk_pixbuf_moduledir="$(get_pkgconf_variable "gdk_pixbuf_moduledir" "gdk-pixbuf-2.0" "$gdk_pixbuf_binarydir/loaders")"
258273
# Note: gdk_pixbuf_query_loaders variable is not defined on some systems
259274
gdk_pixbuf_query="$(search_tool "gdk-pixbuf-query-loaders" "gdk-pixbuf-2.0")"
260275
copy_tree "$gdk_pixbuf_binarydir" "$APPDIR/"
@@ -273,12 +288,12 @@ fi
273288
sed -i "s|$gdk_pixbuf_moduledir/||g" "$APPDIR/$gdk_pixbuf_cache_file"
274289

275290
echo "Copying more libraries"
276-
gobject_libdir="$(get_pkgconf_variable "libdir" "gobject-2.0" "/usr/lib/x86_64-linux-gnu")"
277-
gio_libdir="$(get_pkgconf_variable "libdir" "gio-2.0" "/usr/lib/x86_64-linux-gnu")"
278-
librsvg_libdir="$(get_pkgconf_variable "libdir" "librsvg-2.0" "/usr/lib/x86_64-linux-gnu")"
279-
pango_libdir="$(get_pkgconf_variable "libdir" "pango" "/usr/lib/x86_64-linux-gnu")"
280-
pangocairo_libdir="$(get_pkgconf_variable "libdir" "pangocairo" "/usr/lib/x86_64-linux-gnu")"
281-
pangoft2_libdir="$(get_pkgconf_variable "libdir" "pangoft2" "/usr/lib/x86_64-linux-gnu")"
291+
gobject_libdir="$(get_pkgconf_variable "libdir" "gobject-2.0" "$LD_GTK_LIBRARY_PATH")"
292+
gio_libdir="$(get_pkgconf_variable "libdir" "gio-2.0" "$LD_GTK_LIBRARY_PATH")"
293+
librsvg_libdir="$(get_pkgconf_variable "libdir" "librsvg-2.0" "$LD_GTK_LIBRARY_PATH")"
294+
pango_libdir="$(get_pkgconf_variable "libdir" "pango" "$LD_GTK_LIBRARY_PATH")"
295+
pangocairo_libdir="$(get_pkgconf_variable "libdir" "pangocairo" "$LD_GTK_LIBRARY_PATH")"
296+
pangoft2_libdir="$(get_pkgconf_variable "libdir" "pangoft2" "$LD_GTK_LIBRARY_PATH")"
282297
FIND_ARRAY=(
283298
"$gdk_libdir" "libgdk_pixbuf-*.so*"
284299
"$gobject_libdir" "libgobject-*.so*"

0 commit comments

Comments
 (0)