Skip to content

Fix libwebkit deployment #37

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 17 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 25 additions & 6 deletions linuxdeploy-plugin-gtk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ show_usage() {
echo
echo "Required variables:"
echo " LINUXDEPLOY=\".../linuxdeploy\" path to linuxdeploy (e.g., AppImage); set automatically when plugin is run directly by linuxdeploy"
echo
echo "Optional variables:"
echo " DEPLOY_GTK_VERSION (major version of GTK to deploy, e.g. '2', '3' or '4'; auto-detect by default)"
#echo
#echo "Optional variables:"
#echo " DEPLOY_GTK_VERSION (major version of GTK to deploy, e.g. '2', '3' or '4'; auto-detect by default)"
}

variable_is_true() {
Expand Down Expand Up @@ -86,7 +86,8 @@ search_tool() {
done
}

DEPLOY_GTK_VERSION="${DEPLOY_GTK_VERSION:-0}" # When not set by user, this variable use the integer '0' as a sentinel value
#DEPLOY_GTK_VERSION="${DEPLOY_GTK_VERSION:-0}" # When not set by user, this variable use the integer '0' as a sentinel value
DEPLOY_GTK_VERSION=3 # Force GTK3 for tauri apps

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you hardcoded DEPLOY_GTK_VERSION? You can set DEPLOY_GTK_VERSION=3 as an environment variable.

APPDIR=

while [ "$1" != "" ]; do
Expand Down Expand Up @@ -119,6 +120,8 @@ if [ "$APPDIR" == "" ]; then
fi

mkdir -p "$APPDIR"
# make lib64 writable again.
chmod +w "$APPDIR"/usr/lib64 || true

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not get it. As this point, $APPDIR is an empty directory, without usr inside.
Also, I am not a big fan of hardcoded /usr/lib64: it will not work on 32-bit distros. Furthermore, Debian-based distros use multiarch so there is no /usr/lib64.


if command -v pkgconf > /dev/null; then
PKG_CONFIG="pkgconf"
Expand Down Expand Up @@ -203,15 +206,15 @@ case "$DEPLOY_GTK_VERSION" in
echo "Installing GTK 3.0 modules"
gtk3_exec_prefix="$(get_pkgconf_variable "exec_prefix" "gtk+-3.0")"
gtk3_libdir="$(get_pkgconf_variable "libdir" "gtk+-3.0")/gtk-3.0"
gtk3_path="$gtk3_libdir/modules"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand, the issue is /modules should not be at the end of gtk3_path. In that case, why didn't you just remove /modules at the end to fix the issue?

#gtk3_path="$gtk3_libdir/modules" export GTK_PATH="\$APPDIR/$gtk3_path"
gtk3_immodulesdir="$gtk3_libdir/$(get_pkgconf_variable "gtk_binary_version" "gtk+-3.0")/immodules"
gtk3_printbackendsdir="$gtk3_libdir/$(get_pkgconf_variable "gtk_binary_version" "gtk+-3.0")/printbackends"
gtk3_immodules_cache_file="$(dirname "$gtk3_immodulesdir")/immodules.cache"
gtk3_immodules_query="$(search_tool "gtk-query-immodules-3.0" "libgtk-3-0")"
copy_tree "$gtk3_libdir" "$APPDIR/"
cat >> "$HOOKFILE" <<EOF
export GTK_EXE_PREFIX="\$APPDIR/$gtk3_exec_prefix"
export GTK_PATH="\$APPDIR/$gtk3_path"
export GTK_PATH="\$APPDIR/$gtk3_libdir:/usr/lib64/gtk-3.0:/usr/lib/x86_64-linux-gnu/gtk-3.0"
export GTK_IM_MODULE_FILE="\$APPDIR/$gtk3_immodules_cache_file"

EOF
Expand Down Expand Up @@ -305,3 +308,19 @@ for directory in "${PATCH_ARRAY[@]}"; do
ln $verbose -s "${file/\/usr\/lib\//}" "$APPDIR/usr/lib"
done < <(find "$directory" -name '*.so' -print0)
done

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/usr/lib64 is 755 on systems. I think the issue is how you create this directory before calling linuxdeploy.


# We have to copy the files first to not get permission errors when we assign gio_extras_dir
find /usr/lib* -name libgiognutls.so -exec mkdir -p "$APPDIR"/"$(dirname '{}')" \; -exec cp --parents '{}' "$APPDIR/" \; || true

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like you are trying to perform a copy_tree, isn't it?

# related files that we seemingly don't need:
# libgiolibproxy.so - libgiognomeproxy.so - glib-pacrunner

gio_extras_dir=$(find "$APPDIR"/usr/lib* -name libgiognutls.so -exec dirname '{}' \; 2>/dev/null)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not safe, it can returns multiples directories, like:

/usr/lib/gio/modules
/usr/lib32/gio/modules

Use "$(get_pkgconf_variable "giomoduledir" "gio-2.0") instead.

cat >> "$HOOKFILE" <<EOF
export GIO_EXTRA_MODULES="\$APPDIR/${gio_extras_dir#"$APPDIR"/}"
EOF

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From where libwebkit pops up? I do not see any copy of this library before.