Unable to build Librem 5 flatpak apps


#1

I was trying to follow Purism’s tutorial on building Flatpak apps for the Librem 5 but can’t get any of the examples to build with Flatpak. I was able to get the non-Purism Flatpak hello world example to build and run, so the issue seems to be specific to meson. However, when I build directly with meson and ninja as per the first link, the app builds without a problem. Has anyone else had this problem, or does anyone know what this error means? The error occurs when I try running the flatpak-builder script:

$ flatpak-builder --arch=aarch64 --repo=myrepo --force-clean -v _flatpak com.example.first_application.json
FB: Running: git config --get user.email
FB: Running: git config --get user.name
Emptying app dir '_flatpak'
FB: Running: flatpak info --arch=aarch64 --show-commit org.gnome.Sdk 3.30
FB: Running: flatpak info --show-location --arch=aarch64 org.gnome.Sdk 3.30
FB: Running: flatpak info --arch=aarch64 --show-commit org.gnome.Platform 3.30
Downloading sources
Starting build of com.example.first_application
Cache miss, checking out last cache hit
FB: starting: rofiles-fuse /home/user/repos/LibremApps/first-application/_flatpak /home/user/repos/LibremApps/first-application/.flatpak-builder/rofiles/rofiles-MetXqM
========================================================================
Building module first_application in /home/user/repos/LibremApps/first-application/.flatpak-builder/build/first_application-13
========================================================================
FB: Running: flatpak build --die-with-parent --env=FLATPAK_BUILDER_BUILDDIR=/run/build/first_application --nofilesystem=host --filesystem=/home/user/repos/LibremApps/first-application/.flatpak-builder/build/first_application-13 --bind-mount=/run/build/first_application=/home/user/repos/LibremApps/first-application/.flatpak-builder/build/first_application-13 --build-dir=/run/build/first_application/_flatpak_build --bind-mount=/run/ccache=/home/user/repos/LibremApps/first-application/.flatpak-builder/ccache --env=SOURCE_DATE_EPOCH=1555546863 '--env=CFLAGS=-O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection' '--env=CXXFLAGS=-O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection' '--env=LDFLAGS=-L/app/lib -Wl,-z,relro,-z,now -Wl,--as-needed' --env=CCACHE_DIR=/run/ccache/disabled --env=PATH=/app/bin:/usr/bin --env=LD_LIBRARY_PATH=/app/lib --env=PKG_CONFIG_PATH=/app/lib/pkgconfig:/app/share/pkgconfig:/usr/lib/pkgconfig:/usr/share/pkgconfig --env=FLATPAK_BUILDER_N_JOBS=4 /home/user/repos/LibremApps/first-application/.flatpak-builder/rofiles/rofiles-MetXqM meson --prefix=/app ..
bwrap: execvp meson: No such file or directory
Error: module first_application: Child process exited with code 1
FB: unmounting rofiles-fuse /home/user/repos/LibremApps/first-application/.flatpak-builder/rofiles/rofiles-MetXqM

#2

dos from our Matrix channel at #community-librem-apps:talk.puri.sm says:

I’d guess that the kernel can’t run aarch64 binaries and registering qemu-user in binfmt_misc should help

I don’t know why it is, but you could try to work around it by running this as root:

echo ":qemu-aarch64:M::\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xb7:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/bin/qemu-aarch64-static:OC" > /proc/sys/fs/binfmt_misc/register

It works on Fedora, perhaps you may need to adjust the qemu path.


#3

Thanks, I tried that and now get bwrap: execvp meson: No such file or directory when running the same command. All I can think is that the /app directory not existing is causing problems, but I’m not sure where that directory should actually be, since I don’t think it’s really expecting an app directory at the root of the whole filesystem.

I’ve created a Matrix account and joined the room you mentioned. If that’s a better place to ask development questions I can ask there, but for now I didn’t want to split the thread and ask the same question in two places.


#4

I’ve figured out what the problem was. I run Gentoo with OpenRC instead of systemd, and the Gentoo Flatpak overlay is only (fully) compatible with installations using systemd. I’m not sure if systemd is an upstream requirement or if it’s specific to the Gentoo overlay, but when I tried building on a Fedora VM everything worked without a problem.