How can you remap file access with hardcoded absolute paths inside a snap?
I want to create a classic snap of a program that calls executables located at /usr/libexec/
but that are actually located in the mounted snap at /snap/<name>/<version>/usr/libexec/
.
According to https://snapcraft.io/docs/snap-layouts, this can be solved with layouts. I defined the layout
layout:
/usr/libexec:
bind: $SNAP/usr/libexec
that should map all access to /usr/libexec
to /snap/<name>/<version>/usr/libexec/
.
However, it does not seem to have an effect. The program still fails to find the executables.
Details:
I am trying to snap the Wayland compositor Weston.
Excerpt (full file at https://raw.githubusercontent.com/christianrauch/weston-snap/master/snapcraft.yaml):
confinement: classic
base: core18
environment:
WESTON_MODULE_MAP: "gl-renderer.so=${SNAP}/usr/lib/${SNAPCRAFT_ARCH_TRIPLET}/libweston-7/gl-renderer.so;remoting-plugin.so=${SNAP}/usr/lib/${SNAPCRAFT_ARCH_TRIPLET}/libweston-7/remoting-plugin.so;drm-backend.so=${SNAP}/usr/lib/${SNAPCRAFT_ARCH_TRIPLET}/libweston-7/drm-backend.so;fbdev-backend.so=${SNAP}/usr/lib/${SNAPCRAFT_ARCH_TRIPLET}/libweston-7/fbdev-backend.so;headless-backend.so=${SNAP}/usr/lib/${SNAPCRAFT_ARCH_TRIPLET}/libweston-7/headless-backend.so;rdp-backend.so=${SNAP}/usr/lib/${SNAPCRAFT_ARCH_TRIPLET}/libweston-7/rdp-backend.so;wayland-backend.so=${SNAP}/usr/lib/${SNAPCRAFT_ARCH_TRIPLET}/libweston-7/wayland-backend.so;x11-backend.so=${SNAP}/usr/lib/${SNAPCRAFT_ARCH_TRIPLET}/libweston-7/x11-backend.so;desktop-shell.so=${SNAP}/usr/lib/${SNAPCRAFT_ARCH_TRIPLET}/weston/desktop-shell.so;fullscreen-shell.so=${SNAP}/usr/lib/${SNAPCRAFT_ARCH_TRIPLET}/weston/fullscreen-shell.so;ivi-shell.so=${SNAP}/usr/lib/${SNAPCRAFT_ARCH_TRIPLET}/weston/ivi-shell.so"
parts:
weston:
plugin: meson
meson-parameters:
- --prefix=/usr
- --pkg-config-path=$SNAPCRAFT_STAGE/share/pkgconfig
prime:
- usr/bin
- usr/lib
- usr/libexec
- usr/share/wayland-sessions/weston.desktop
- usr/share/X11/xkb
layout:
/usr/libexec:
bind: $SNAP/usr/libexec
apps:
weston:
command: bin/desktop-launch $SNAP/usr/bin/weston
desktop: usr/share/wayland-sessions/weston.desktop
plugs:
- desktop
- network
- home
- wayland
- x11
- opengl
When starting Weston, it will try to open /usr/libexec/weston-keyboard
, which should resolve to /snap/<name>/<version>/usr/libexec/weston-keyboard
.