Skip to content

Fix for #24 #29

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

Merged
merged 6 commits into from
Feb 20, 2022
Merged
Show file tree
Hide file tree
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
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ This is an (as of yet experimental) plugin for linuxdeploy. Its job is to bundle

This plugin requires the following dependencies in order to work properly:

- `patchelf` command
- `file` command
- `find` command
- `pkg-config` or `pkgconf` command
Expand Down
2 changes: 1 addition & 1 deletion containers/gtk3/Dockerfile.debian
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ARG APPDIR=/AppDir
ARG TZ=UTC
RUN ln -snf "/usr/share/zoneinfo/$TZ" "/etc/localtime" && echo "$TZ" > /etc/timezone
RUN apt-get update && \
apt-get install -y wget patchelf librsvg2-dev file findutils pkg-config libgtk-3-0 libgtk-3-dev gtk-3-examples
apt-get install -y wget librsvg2-dev file findutils pkg-config libgtk-3-0 libgtk-3-dev gtk-3-examples
COPY . .
ADD "https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage" .
RUN chmod +x *.sh *.AppImage
Expand Down
7 changes: 4 additions & 3 deletions containers/gtk3/Dockerfile.fedora
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
FROM docker.io/fedora:33 AS build-stage
FROM docker.io/fedora:latest AS build-stage
WORKDIR /linuxdeploy
ENV APPIMAGE_EXTRACT_AND_RUN=1
ARG APPDIR=/AppDir
RUN dnf install -y wget patchelf librsvg2-devel file findutils pkgconfig gtk3 gtk3-devel
RUN dnf install -y wget librsvg2-devel file findutils pkgconfig gtk3 gtk3-devel
COPY . .
ADD "https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage" .
RUN chmod +x *.sh *.AppImage
RUN gtk-query-immodules-3.0-64 --update-cache
RUN ./linuxdeploy-x86_64.AppImage \
--appdir ${APPDIR} \
--plugin gtk \
Expand All @@ -14,7 +15,7 @@ RUN ./linuxdeploy-x86_64.AppImage \
--desktop-file /usr/share/applications/gtk3-widget-factory.desktop \
--icon-file /usr/share/icons/hicolor/256x256/apps/gtk3-widget-factory.png

FROM docker.io/fedora:33
FROM docker.io/fedora:latest
VOLUME ["/AppImage"]
WORKDIR /AppImage
ENV APPIMAGE_EXTRACT_AND_RUN=1
Expand Down
2 changes: 1 addition & 1 deletion containers/gtk3/Dockerfile.opensuse
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM docker.io/opensuse/leap:15 AS build-stage
WORKDIR /linuxdeploy
ENV APPIMAGE_EXTRACT_AND_RUN=1
ARG APPDIR=/AppDir
RUN zypper install -y wget patchelf librsvg2-devel file findutils pkg-config gtk3 gtk3-devel
RUN zypper install -y wget librsvg2-devel file findutils pkg-config gtk3 gtk3-devel
COPY . .
ADD "https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage" .
RUN chmod +x *.sh *.AppImage
Expand Down
2 changes: 1 addition & 1 deletion containers/gtk3/Dockerfile.ubuntu
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ARG APPDIR=/AppDir
ARG TZ=UTC
RUN ln -snf "/usr/share/zoneinfo/$TZ" "/etc/localtime" && echo "$TZ" > /etc/timezone
RUN apt-get update && \
apt-get install -y wget patchelf librsvg2-dev file findutils pkg-config libgtk-3-0 libgtk-3-dev gtk-3-examples
apt-get install -y wget librsvg2-dev file findutils pkg-config libgtk-3-0 libgtk-3-dev gtk-3-examples
COPY . .
ADD "https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage" .
RUN chmod +x *.sh *.AppImage
Expand Down
2 changes: 1 addition & 1 deletion containers/gtk4/Dockerfile.debian
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ARG APPDIR=/AppDir
ARG TZ=UTC
RUN ln -snf "/usr/share/zoneinfo/$TZ" "/etc/localtime" && echo "$TZ" > /etc/timezone
RUN apt-get update && \
apt-get install -y wget patchelf librsvg2-dev file findutils pkg-config && \
apt-get install -y wget librsvg2-dev file findutils pkg-config && \
apt-get install -y -t experimental libgtk-4-1 libgtk-4-dev gtk-4-examples
COPY . .
ADD "https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage" .
Expand Down
6 changes: 3 additions & 3 deletions containers/gtk4/Dockerfile.fedora
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
FROM docker.io/fedora:33 AS build-stage
FROM docker.io/fedora:latest AS build-stage
WORKDIR /linuxdeploy
ENV APPIMAGE_EXTRACT_AND_RUN=1
ARG APPDIR=/AppDir
RUN dnf install -y wget patchelf librsvg2-devel file findutils pkgconfig gtk4 gtk4-devel
RUN dnf install -y wget librsvg2-devel file findutils pkgconfig gtk4 gtk4-devel gtk4-devel-tools
COPY . .
ADD "https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage" .
RUN chmod +x *.sh *.AppImage
Expand All @@ -14,7 +14,7 @@ RUN ./linuxdeploy-x86_64.AppImage \
--desktop-file /usr/share/applications/org.gtk.WidgetFactory4.desktop \
--icon-file /usr/share/icons/hicolor/scalable/apps/org.gtk.WidgetFactory4.svg

FROM docker.io/fedora:33
FROM docker.io/fedora:latest
VOLUME ["/AppImage"]
WORKDIR /AppImage
ENV APPIMAGE_EXTRACT_AND_RUN=1
Expand Down
2 changes: 1 addition & 1 deletion containers/gtk4/Dockerfile.opensuse
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ FROM docker.io/opensuse/tumbleweed:latest AS build-stage
WORKDIR /linuxdeploy
ENV APPIMAGE_EXTRACT_AND_RUN=1
ARG APPDIR=/AppDir
RUN zypper install -y wget patchelf librsvg2-devel file findutils pkg-config gtk4 gtk4-devel
RUN zypper install -y wget librsvg2-devel file findutils pkg-config gtk4 gtk4-devel
COPY . .
ADD "https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage" .
RUN chmod +x *.sh *.AppImage
Expand Down
2 changes: 1 addition & 1 deletion containers/gtk4/Dockerfile.ubuntu
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ARG APPDIR=/AppDir
ARG TZ=UTC
RUN ln -snf "/usr/share/zoneinfo/$TZ" "/etc/localtime" && echo "$TZ" > /etc/timezone
RUN apt-get update && \
apt-get install -y wget patchelf librsvg2-dev file findutils pkg-config libgtk-4-1 libgtk-4-dev gtk-4-examples
apt-get install -y wget librsvg2-dev file findutils pkg-config libgtk-4-1 libgtk-4-dev gtk-4-examples
COPY . .
ADD "https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage" .
RUN chmod +x *.sh *.AppImage
Expand Down
32 changes: 9 additions & 23 deletions linuxdeploy-plugin-gtk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,6 @@ if ! command -v find &>/dev/null && ! type find &>/dev/null; then
exit 1
fi

if ! command -v patchelf &>/dev/null && ! type patchelf &>/dev/null; then
echo -e "$0: patchelf not found.\nInstall patchelf then re-run the plugin."
exit 1
fi

if [ -z "$LINUXDEPLOY" ]; then
echo -e "$0: LINUXDEPLOY environment variable is not set.\nDownload a suitable linuxdeploy AppImage, set the environment variable and re-run the plugin."
exit 1
Expand Down Expand Up @@ -182,16 +177,6 @@ cat > "$HOOKFILE" <<\EOF
gsettings get org.gnome.desktop.interface gtk-theme 2> /dev/null | grep -qi "dark" && GTK_THEME_VARIANT="dark" || GTK_THEME_VARIANT="light"
APPIMAGE_GTK_THEME="${APPIMAGE_GTK_THEME:-"Adwaita:$GTK_THEME_VARIANT"}" # Allow user to override theme (discouraged)

# in case we run from an AppImage, we use the $APPDIR environment variable as a template for the temporary directory that should be created
# this allows users to attribute the tempdir to the running AppImage
if [ "$APPDIR" != "" ]; then
tempdir_template="$APPDIR".ld-p-gtk-tmp-XXXXXX
else
tempdir_template=/tmp/.ld-p-gtk-tmp-XXXXXX
fi

export CACHEDIR="$(mktemp -d "$tempdir_template")"

export APPDIR="${APPDIR:-"$(dirname "$(realpath "$0")")"}" # Workaround to run extracted AppImage
export GTK_DATA_PREFIX="$APPDIR"
export GTK_THEME="$APPIMAGE_GTK_THEME" # Custom themes are broken
Expand Down Expand Up @@ -219,15 +204,15 @@ case "$DEPLOY_GTK_VERSION" in
gtk3_libdir="$(get_pkgconf_variable "libdir" "gtk+-3.0")/gtk-3.0"
gtk3_path="$gtk3_libdir/modules"
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_IM_MODULE_DIR="\$APPDIR/$gtk3_immodulesdir"
export GTK_IM_MODULE_FILE="\$CACHEDIR/immodules.cache"
sed "s|$gtk3_libdir|\$APPDIR/$gtk3_libdir|g" "\$APPDIR/$gtk3_immodules_cache_file" > "\$GTK_IM_MODULE_FILE"
export GTK_IM_MODULE_FILE="\$APPDIR/$gtk3_immodules_cache_file"

EOF
if [ -x "$gtk3_immodules_query" ]; then
echo "Updating immodules cache in $APPDIR/$gtk3_immodules_cache_file"
Expand All @@ -238,6 +223,7 @@ EOF
if [ ! -f "$APPDIR/$gtk3_immodules_cache_file" ]; then
echo "WARNING: immodules.cache file is missing"
fi
sed -i "s|$gtk3_libdir/3.0.0/immodules/||g" "$APPDIR/$gtk3_immodules_cache_file"
;;
4)
echo "Installing GTK 4.0 modules"
Expand Down Expand Up @@ -265,9 +251,7 @@ gdk_pixbuf_moduledir="$(get_pkgconf_variable "gdk_pixbuf_moduledir" "gdk-pixbuf-
gdk_pixbuf_query="$(search_tool "gdk-pixbuf-query-loaders" "gdk-pixbuf-2.0")"
copy_tree "$gdk_pixbuf_binarydir" "$APPDIR/"
cat >> "$HOOKFILE" <<EOF
export GDK_PIXBUF_MODULEDIR="\$APPDIR/$gdk_pixbuf_moduledir"
export GDK_PIXBUF_MODULE_FILE="\$CACHEDIR/loaders.cache"
sed "s|$gdk_pixbuf_moduledir|\$APPDIR/$gdk_pixbuf_moduledir|g" "\$APPDIR/$gdk_pixbuf_cache_file" > "\$GDK_PIXBUF_MODULE_FILE"
export GDK_PIXBUF_MODULE_FILE="\$APPDIR/$gdk_pixbuf_cache_file"
EOF
if [ -x "$gdk_pixbuf_query" ]; then
echo "Updating pixbuf cache in $APPDIR/$gdk_pixbuf_cache_file"
Expand All @@ -278,6 +262,7 @@ fi
if [ ! -f "$APPDIR/$gdk_pixbuf_cache_file" ]; then
echo "WARNING: loaders.cache file is missing"
fi
sed -i "s|$gdk_pixbuf_moduledir/||g" "$APPDIR/$gdk_pixbuf_cache_file"

echo "Copying more libraries"
gobject_libdir="$(get_pkgconf_variable "libdir" "gobject-2.0")"
Expand Down Expand Up @@ -306,6 +291,8 @@ done

env LINUXDEPLOY_PLUGIN_MODE=1 "$LINUXDEPLOY" --appdir="$APPDIR" "${LIBRARIES[@]}"

# Create symbolic links as a workaround
# Details: https://github.com/linuxdeploy/linuxdeploy-plugin-gtk/issues/24#issuecomment-1030026529
echo "Manually setting rpath for GTK modules"
PATCH_ARRAY=(
"$gtk3_immodulesdir"
Expand All @@ -314,7 +301,6 @@ PATCH_ARRAY=(
)
for directory in "${PATCH_ARRAY[@]}"; do
while IFS= read -r -d '' file; do
# shellcheck disable=SC2016
patchelf --set-rpath '$ORIGIN/../../../..' "$APPDIR/$file"
ln $verbose -s "${file/\/usr\/lib\//}" "$APPDIR/usr/lib"
done < <(find "$directory" -name '*.so' -print0)
done