Issues I Encountered While Packaging Darling

Hello Everyone,

I’m a member of the Darling team and I am currently assessing how viable it would be to run Darling as a Flatpak app.

Right now I am trying to build libfuse. From what I observed, it seems like libfuse builds just fine, but Darling is not able to detect the built library for some reason (It uses FindPkgConfig.cmake to check for the ‘fuse’ library).

-- Checking for module 'fuse'
--   Package 'fuse', required by 'virtual:world', not found
CMake Error at /usr/share/cmake-3.22/Modules/FindPkgConfig.cmake:603 (message):
  A required package was not found
Call Stack (most recent call first):
  /usr/share/cmake-3.22/Modules/FindPkgConfig.cmake:825 (_pkg_check_modules_internal)
  src/external/darling-dmg/CMakeLists.txt:121 (pkg_check_modules)

I looked at the build directory and noticed that the compiled FUSE files are stored in the files directory. The var/lib folder seems to be empty. Maybe this is the reason why Darling is not detecting the compiled FUSE libraries?

$ tree build-dir/
build-dir/
├── files
│   ├── bin
│   │   └── fusermount3
│   ├── etc
│   │   ├── fuse.conf
│   │   └── udev
│   │       └── rules.d
│   │           └── 99-fuse3.rules
│   ├── include
│   │   └── fuse3
│   │       ├── cuse_lowlevel.h
│   │       ├── fuse_common.h
│   │       ├── fuse.h
│   │       ├── fuse_log.h
│   │       ├── fuse_lowlevel.h
│   │       └── fuse_opt.h
│   ├── lib
│   │   ├── debug
│   │   │   ├── bin
│   │   │   │   └── fusermount3.debug
│   │   │   ├── lib
│   │   │   │   └── libfuse3.so.3.10.5.debug
│   │   │   ├── sbin
│   │   │   │   └── mount.fuse3.debug
│   │   │   └── source
│   │   │       └── fuse
│   │   │           ├── _flatpak_build
│   │   │           ├── include
│   │   │           │   ├── cuse_lowlevel.h
│   │   │           │   ├── fuse_common.h
│   │   │           │   ├── fuse.h
│   │   │           │   ├── fuse_kernel.h
│   │   │           │   ├── fuse_log.h
│   │   │           │   ├── fuse_lowlevel.h
│   │   │           │   └── fuse_opt.h
│   │   │           ├── lib
│   │   │           │   ├── buffer.c
│   │   │           │   ├── cuse_lowlevel.c
│   │   │           │   ├── fuse.c
│   │   │           │   ├── fuse_i.h
│   │   │           │   ├── fuse_log.c
│   │   │           │   ├── fuse_loop.c
│   │   │           │   ├── fuse_loop_mt.c
│   │   │           │   ├── fuse_lowlevel.c
│   │   │           │   ├── fuse_opt.c
│   │   │           │   ├── fuse_signals.c
│   │   │           │   ├── helper.c
│   │   │           │   ├── modules
│   │   │           │   │   ├── iconv.c
│   │   │           │   │   └── subdir.c
│   │   │           │   ├── mount.c
│   │   │           │   ├── mount_util.c
│   │   │           │   └── mount_util.h
│   │   │           └── util
│   │   │               ├── fusermount.c
│   │   │               └── mount.fuse.c
│   │   ├── libfuse3.so -> libfuse3.so.3
│   │   ├── libfuse3.so.3 -> libfuse3.so.3.10.5
│   │   ├── libfuse3.so.3.10.5
│   │   └── pkgconfig
│   │       └── fuse3.pc
│   ├── sbin
│   │   └── mount.fuse3
│   └── share
│       └── man
│           ├── man1
│           │   └── fusermount3.1
│           └── man8
│               └── mount.fuse3.8
├── metadata
└── var
    ├── lib
    ├── run -> /run
    └── tmp

Below is how I set the yml files. These files are also hosted on GitHub.

org.darlinghq.darling.yml

app-id: org.darlinghq.Darling
runtime: org.freedesktop.Platform
runtime-version: '21.08'
sdk: org.freedesktop.Sdk
command: darling shell
modules:
  - name: darling
    buildsystem: cmake
    builddir: true
    modules:
      - modules/fuse.yml
    sources:
      - type: git
        url: https://github.com/darlinghq/darling.git
        commit: c30e22f13ea61d867d76adc2914ec8352cac66be

modules/fuse.yml

name: fuse
buildsystem: meson
config-opts:
  - -Dudevrulesdir=/app/etc/udev/rules.d
  - -Duseroot=false
sources:
  - type: archive
    url: https://github.com/libfuse/libfuse/releases/download/fuse-3.10.5/fuse-3.10.5.tar.xz
    sha256: b2e283485d47404ac896dd0bb7f7ba81e1470838e677e45f659804c3a3b69666

your cmake script can’t seem to find the .pc files - which is odd. Maybe tweaking the pkgconfig path would help.

I did some more testing, and it seems like the PKG_CONFIG_PATH is set up correctly. But for some reason, the pkg_check_modules method doesn’t check the path…

CMake Warning at src/external/darling-dmg/CMakeLists.txt:121 (message):
  (Check #3) PKG_CONFIG_PATH:
  /app/lib/pkgconfig:/app/share/pkgconfig:/usr/lib/pkgconfig:/usr/share/pkgconfig


-- Checking for module 'fuse'
--   Package 'fuse', required by 'virtual:world', not found
CMake Error at /usr/share/cmake-3.22/Modules/FindPkgConfig.cmake:603 (message):
  A required package was not found
Call Stack (most recent call first):
  /usr/share/cmake-3.22/Modules/FindPkgConfig.cmake:825 (_pkg_check_modules_internal)
  src/external/darling-dmg/CMakeLists.txt:122 (pkg_check_modules)

I’m going to make a bare-bones CMake project to see if I can reproduce the issue.

Yeah, this seems to be an issue with CMake itself. I made a simple CMake project and fails the same way (so it isn’t an issue with how Darling is using the CMake scripts).

files/CMakeLists.txt

cmake_minimum_required(VERSION 3.10)
project(cmake_flatpak_test)

include(FindPkgConfig)
message(WARNING "PKG_CONFIG_PATH: $ENV{PKG_CONFIG_PATH}")
pkg_check_modules(FUSE REQUIRED fuse)

I uploaded a reproducible example on GitHub.

I feel really silly for not catching this, but I was using the fuse3 version when Darling was using version 2 of fuse…

/run/build/darling/src/startup/mldr/resources/dserver-rpc-defs.h:1:10: fatal error: 'sys/socket.h' file not found
#include <sys/socket.h>

Is it expected that the FreeDesktop SDK not include some of the glibc headers? When I look for it in /usr/include/sys/, I don’t see the socket.h file.

[📦 org.darlinghq.Darling /]$ ls /usr/include/sys/
acl.h  asoundlib.h  capability.h  psx_syscall.h

You got these:

[📦 org.freedesktop.Sdk ~]$ cd /usr/include/
[📦 org.freedesktop.Sdk include]$ find . -ipath "./*/socket.h*"
./linux/socket.h
./gnutls/socket.h
./asm-generic/socket.h

I took a look at those three files, but they unfortunate don’t have the methods/structs that Darling needs.

For reference, here are some of the methods/structs that Darling grabs from sys/socket.h:

extern ssize_t recvmsg(int __fd, struct msghdr *__message, int __flags);
struct msghdr;
struct iovec;
struct msghdr;

There is another header under /usr/lib/x86_64-linux-gnu/include/sys/socket.h.

1 Like

After some trials and errors, I got Darling to successfully build! I just needed to add some build-options flags to stop Flatpak from adding Linux specific compiler/linker flags.


With that being said, there are issues when trying to run Darling. Darling is currently designed to launch with root permissions so that it can mount overlayfs and create PID namespaces.

It makes sense why the Darling executable doesn’t run with root permissions, but is it possible to mount and create PID namespaces in Flatpak without needing to be root?

You should probably ask the Flatpak developers directly (Flatpak mailing list or GitHub).

1 Like