#42 Unable to use SDK as a runtime
Closed by otaylor. Opened by yselkowitz.

Flatpak SDKs serve two distinct purposes: 1) as a build environment for building apps against the corresponding Platform runtime with flatpak-builder, and 2) to serve as a runtime for development-oriented apps (such as IDEs). Some examples of apps that would benefit from the latter include:

  • emacs
  • gnome-builder
  • kdevelop
  • qt-creator

Unfortunately, it seems such an app cannot currently be built. Taking emacs as an example with the following container.yaml (RPMs are already built):

flatpak:
    id: org.gnu.emacs
    branch: stable
    runtime-name: flatpak-sdk
    runtime-version: f40
    packages:
        - emacs
        - emacs-gtk+x11
    command: emacs-desktop
    rename-appdata-file: emacs.metainfo.xml
    rename-desktop-file: emacs.desktop
    rename-icon: emacs
    finish-args: |-
        --share=network
        --share=ipc
        --socket=pulseaudio
        --socket=fallback-x11
        --socket=wayland
        --filesystem=host
        --filesystem=/tmp
        --filesystem=/var/tmp
    cleanup-commands: |
        rm -f /app/share/icons/hicolor/scalable/apps/emacs.ico

flatpak-module correctly uses the SDK to determine which dependencies need to be built in /app and builds the app, but it still wants to use the Platform as runtime instead of Sdk:

$ flatpak info org.gnu.emacs
GNU Emacs - An extensible text editor
          ID: org.gnu.emacs
         Ref: app/org.gnu.emacs/x86_64/stable
        Arch: x86_64
      Branch: stable
     License: GPL-3.0+ and GFDL-1.3+
      Origin: flatpak-module-tools
  Collection: 
Installation: user
   Installed: 463.4 MB
     Runtime: org.fedoraproject.Platform/x86_64/f40
         Sdk: org.fedoraproject.Sdk/x86_64/f40
      Commit: 1ef54d145247f725d7480f9bda3fec3357ed502c162e1a2feb56e9d9e7004899
     Subject: Export org.gnu.emacs
        Date: 2024-05-10 19:17:33 +0000
      Alt-id: bfb77ec3504274e2c5273080c7591ff7af216717b5bd8ee83a68a342307c609d

As a result, the application will not start OOTB, since one of its dependencies is libgccjit, which is Sdk-only. However, it will run by overriding the runtime with flatpak run --runtime=org.fedoraproject.Sdk//f40 org.gnu.emacs.

flatpak-module-tools should not try to be too clever. If an Sdk is used as the runtime-name, then it should be used as the runtime, not its corresponding Platform.


So, first let me say that using the Fedora SDK as the runtime is not going to work well. The set of development dependencies is unlikely to completely satisfy the needs of any usage. The reason that it sort of works for Flathub emacs, etc, is SDK extensions. But we're not going to add SDK extensions for the Fedora SDK. So, I'd rather we didn't do this...

The way it should actually work is a) make it work to create a toolbox from the Fedora Flatpak runtime or SDK b) make it work to launch an app using the toolbox rather than the runtime. It's all feasiblish but certainly some considerable amount of work.

That being said, I guess at the flatpak-module-tools we should allow this. The reason it doesn't work currently I wouldn't say has anything to do with flatpak-module-tools being "clever" - if we look at the metadata for the freedesktop runtime and SDK, we have, correspondingly:

name = org.freedesktop.Platform
runtime = org.freedesktop.Platform/x86_64/23.08
sdk = org.freedesktop.Sdk/x86_64/23.08
name = org.freedesktop.Sdk
runtime = org.freedesktop.Platform/x86_64/23.08
sdk = org.freedesktop.Sdk/x86_64/23.08

and Fedora sets things up exactly the same way. When we initialize the flatpak, we simply use first component of the runtime and sdk there for the runtime and sdk in the app metadata, which is the obvious, unclever thing to do.

Using name for the runtime_id, while keeping on using sdk for sdk_id would work, but there's a reason I don't want to do that, in a near-future version of flatpak-module-tools, it's going to be possible to do, in a Containerfile

FROM flatpak-sdk
RUN dnf install /usr/bin/texi2html
RUN ./configure --prefix=/app && make install
<magic to export /app as a containerfile>

and then we have an app where the runtime metadata comes from the sdk (flatpak-module-tools will just look at /metadata), but the app is supposed to run with the SDK. So, I think what I'd like to see is that if you specify 'flatpak: runtime: org.fedoraproject.Sdk' in an apps container.yaml, that gets honored, and overrides the value from the runtime metadata.

So, basically something like:

       build_init(
            builddir,
            app_id,
-            runtime_info.sdk_id,
-            runtime_info.runtime_id,
+          spec.sdk || runtime_info.sdk_id,
+           spec.runtime || runtime_info.runtime_id,
            runtime_info.version,
            self.arch,
            tags=spec.tags
        )

though that would need testing.

I have a patch that is working locally. Can we get #36 merged first?

Filed #44

Manually merged #44 to flatpak-module-tools and flatpak-container-tools

Metadata Update from @otaylor:
- Issue status updated to: Closed (was: Open)

Metadata
Related Pull Requests