fix(snap): make bundled magick find libgomp at runtime

The `magick` part builds ImageMagick from source with `--prefix=/usr`, so
its own libraries are installed to `usr/lib`, and the binary's RPATH (set
by `enable-patchelf`) is `$ORIGIN/../lib`. However, `libgomp1` is pulled in
as a stage-package and installs `libgomp.so.1` into the multiarch directory
`usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/`, which is not on that RPATH.

As a result the bundled binary fails to start whenever yazi invokes it for
Font/HEIC/JPEG-XL previews:

    magick: error while loading shared libraries: libgomp.so.1:
    cannot open shared object file: No such file or directory

Relocate the bundled libgomp alongside the Magick libraries in `usr/lib`
so the existing `$ORIGIN/../lib` RPATH resolves it. Verified by placing
libgomp on that path next to the shipped binary and running it with no
LD_LIBRARY_PATH set.
This commit is contained in:
cyanyux 2026-06-02 18:44:26 +08:00
parent 8e80798984
commit 7239eb5168

View file

@ -133,9 +133,16 @@ parts:
- --prefix=/usr
build-attributes:
- enable-patchelf
organize:
# `libgomp1` installs libgomp into the multiarch directory, but the
# `magick` binary's RPATH only searches `$ORIGIN/../lib` (i.e. usr/lib).
# Move it alongside the Magick libraries so the bundled binary can load
# it at runtime; otherwise magick fails with:
# "libgomp.so.1: cannot open shared object file: No such file or directory"
usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/libgomp.so*: usr/lib/
prime:
- usr/bin/magick
- usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/libgomp.so.1
- usr/lib/libgomp.so*
- usr/lib/libMagickCore-7.Q16HDRI.so*
- usr/lib/libMagickWand-7.Q16HDRI.so*