From 277b21ed51dced25fc76b85b538a57e68342c711 Mon Sep 17 00:00:00 2001 From: Bruno Lopes Date: Fri, 5 Sep 2025 15:08:25 -0300 Subject: [PATCH] build/linux: Port 3P binaries plugins support from Snapcrafters --- build/linux/snap/patches/enable-plugins | 22 +++++++++++++++++ build/linux/snap/snapcraft.yaml | 32 ++++++++++++++++++++++--- 2 files changed, 51 insertions(+), 3 deletions(-) create mode 100644 build/linux/snap/patches/enable-plugins diff --git a/build/linux/snap/patches/enable-plugins b/build/linux/snap/patches/enable-plugins new file mode 100644 index 0000000000..ed0312cef5 --- /dev/null +++ b/build/linux/snap/patches/enable-plugins @@ -0,0 +1,22 @@ +#!/bin/sh +# +# Set LD_LIBRARY_PATH for third-party plugins. +# +# Each third-party plugin snap may provide a +# add-ld-library-path file so GIMP can find the +# plugin's .so's. The file should provide a path +# relative to ${SNAP}/gimp-plugins, which is the +# mount point for the GIMP snap's generic content +# interface plug. +# + +for path_file in "$SNAP"/gimp-plugins/*.conf/add-ld-library-path; do + if [ -f "$path_file" ]; then + while IFS= read -r path || [ -n "${path}" ]; do + LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${SNAP}/gimp-plugins/${path}" + done < "${path_file}" + fi +done +export LD_LIBRARY_PATH + +exec "$@" diff --git a/build/linux/snap/snapcraft.yaml b/build/linux/snap/snapcraft.yaml index 6fd915bde1..6bbded7d64 100644 --- a/build/linux/snap/snapcraft.yaml +++ b/build/linux/snap/snapcraft.yaml @@ -18,11 +18,12 @@ apps: gimp: common-id: org.gimp.GIMP command: usr/bin/gimp + command-chain: [command-chain/enable-plugins] desktop: usr/share/applications/gimp.desktop environment: HOME: $SNAP_REAL_HOME - #Internet connection and Matting Leving support on FG select - LD_LIBRARY_PATH: $SNAP/gnome-platform/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/libproxy:$SNAP/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/blas:$SNAP/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/lapack:$LD_LIBRARY_PATH + #Internet connection, Matting Leving support on FG select and NPU hardware support + LD_LIBRARY_PATH: $SNAP/gnome-platform/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/libproxy:$SNAP/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/blas:$SNAP/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/lapack:$SNAP/npu-libs:$LD_LIBRARY_PATH #JavaScript plug-ins support GI_TYPELIB_PATH: $SNAP/gnome-platform/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/gjs/girepository-1.0:$GI_TYPELIB_PATH #AVIF, HEIC and HEJ2 plug-ins support @@ -38,6 +39,9 @@ apps: - home - network - removable-media + - intel-npu + - npu-libs + - gimp-plugins extensions: [gnome] layout: @@ -55,6 +59,19 @@ slots: bus: session name: org.gimp.GIMP.UI +plugs: + intel-npu: + interface: custom-device + custom-device: intel-npu-device + npu-libs: + interface: content + content: npu-libs-2404 + target: $SNAP/npu-libs + gimp-plugins: + interface: content + content: gimp-plugins + target: $SNAP/gimp-plugins + parts: buildenv: plugin: nil @@ -158,7 +175,7 @@ parts: override-stage: | # update gimp's plugin search path so it will pick up plugins mounted over snapd's content interface current_path=$(grep "# (plug-in-path" ${CRAFT_PART_INSTALL}/etc/gimp/3.0/gimprc | cut -d '"' -f2) - echo "(plug-in-path \"${current_path}\")" >> ${CRAFT_PART_INSTALL}/etc/gimp/3.0/gimprc + echo "(plug-in-path \"${current_path}:/snap/${SNAPCRAFT_PROJECT_NAME}/current/gimp-plugins\")" >> ${CRAFT_PART_INSTALL}/etc/gimp/3.0/gimprc craftctl default parse-info: - usr/share/metainfo/org.gimp.GIMP.appdata.xml @@ -170,3 +187,12 @@ parts: for myb in $(find "$CRAFT_PRIME/usr/share/mypaint-data/2.0/brushes/Dieterle" -iname "*.myb"); do sed -i -e 's|surfacemap_x|gridmap_x|g' -e 's|surfacemap_y|gridmap_y|g' $myb; done + + command-chain-plugins: + plugin: dump + source: build/linux/snap/patches/ + override-pull: | + craftctl default + chmod +x enable-plugins + organize: + enable-plugins: command-chain/enable-plugins