Create a flatpak package from sources and rpm dependencies

Hi.

I created the two files container.yaml and ksensors.yaml, but then I get this error

flatpak-module build-container-local
Error: container.yaml is new style (compose:modules is not set). Missing keys:
     flatpak:packages

I would need help setting up the basic structure and configuration needed to create the package.
Or an example of a similar case to copy from.

P.S. I have read various guides, but they contradict each other and have non-existent commands.

container.yaml

#compose:
#    modules:
#    - ksensors:stable

modules:
    - name: ksensors
      buildsystem: cmake
      builddir: true
      sources:
        - type: dir
          path: ../

flatpak:
    id: org.kde.ksensors
    default-branch: master
    runtime-name: org.kde.Platform
    runtime-version: 5.15-23.08
    sdk: org.kde.Sdk
    command: ksensors
    rename-icon: ksensors
    desktop-file-name-suffix:  (Nightly)
    tags: []
    # Not sandboxed. See 'man flatpak-build-finish'
    finish-args: |-
        --filesystem=host
        --share=ipc
        --socket=x11
        --socket=wayland
        --socket=session-bus

ksensors.yaml

---
document: modulemd
version: 2
data:
  summary: KDE frontend to lm_sensors
  description: >-
    KSensors is a nice lm-sensors frontend for the K Desktop Environment. Install
    the hddtemp package if you wish to monitor hard disk temperatures with KSensors.
  license:
    module:
    - MIT
  dependencies:
  - buildrequires:
      flatpak-common: [f38]
      flatpak-runtime: [f38]
      platform: [f38]
    requires:
      flatpak-common: [f38]
      flatpak-runtime: [f38]
      platform: [f38]
  profiles:
    default:
      rpms:
      - ksensors
  components:
    rpms:
      arts:
        rationale: Runtime dependency
        ref: f38
      audiofile:
        rationale: Runtime dependency
        ref: f38
      breeze-icon-theme:
        rationale: Runtime dependency
        ref: f38
      fedora-logos:
        rationale: Runtime dependency
        ref: f38
      groff:
        rationale: Runtime dependency
        ref: f38
      iceauth:
        rationale: Runtime dependency
        ref: f38
      kde-filesystem:
        rationale: Runtime dependency
        ref: f38
      kdelibs:
        rationale: Runtime dependency
        ref: f38
      kdelibs3:
        rationale: Runtime dependency
        ref: f38
      ksensors:
        rationale: Application package
        ref: f38
        buildorder: 10
      libart_lgpl:
        rationale: Runtime dependency
        ref: f38
      libmad:
        rationale: Runtime dependency
        ref: f38
      perl:
        rationale: Runtime dependency
        ref: f38
      perl-Carp:
        rationale: Runtime dependency
        ref: f38
      perl-Data-Dumper:
        rationale: Runtime dependency
        ref: f38
      perl-Digest:
        rationale: Runtime dependency
        ref: f38
      perl-Digest-MD5:
        rationale: Runtime dependency
        ref: f38
      perl-Encode:
        rationale: Runtime dependency
        ref: f38
      perl-Exporter:
        rationale: Runtime dependency
        ref: f38
      perl-File-Path:
        rationale: Runtime dependency
        ref: f38
      perl-File-Temp:
        rationale: Runtime dependency
        ref: f38
      perl-Getopt-Long:
        rationale: Runtime dependency
        ref: f38
      perl-HTTP-Tiny:
        rationale: Runtime dependency
        ref: f38
      perl-IO-Socket-IP:
        rationale: Runtime dependency
        ref: f38
      perl-IO-Socket-SSL:
        rationale: Runtime dependency
        ref: f38
      perl-MIME-Base64:
        rationale: Runtime dependency
        ref: f38
      perl-Mozilla-CA:
        rationale: Runtime dependency
        ref: f38
      perl-Net-SSLeay:
        rationale: Runtime dependency
        ref: f38
      perl-PathTools:
        rationale: Runtime dependency
        ref: f38
      perl-Pod-Escapes:
        rationale: Runtime dependency
        ref: f38
      perl-Pod-Perldoc:
        rationale: Runtime dependency
        ref: f38
      perl-Pod-Simple:
        rationale: Runtime dependency
        ref: f38
      perl-Pod-Usage:
        rationale: Runtime dependency
        ref: f38
      perl-Scalar-List-Utils:
        rationale: Runtime dependency
        ref: f38
      perl-Socket:
        rationale: Runtime dependency
        ref: f38
      perl-Storable:
        rationale: Runtime dependency
        ref: f38
      perl-Term-ANSIColor:
        rationale: Runtime dependency
        ref: f38
      perl-Term-Cap:
        rationale: Runtime dependency
        ref: f38
      perl-Text-ParseWords:
        rationale: Runtime dependency
        ref: f38
      perl-Text-Tabs+Wrap:
        rationale: Runtime dependency
        ref: f38
      perl-Time-Local:
        rationale: Runtime dependency
        ref: f38
      perl-URI:
        rationale: Runtime dependency
        ref: f38
      perl-constant:
        rationale: Runtime dependency
        ref: f38
      perl-libnet:
        rationale: Runtime dependency
        ref: f38
      perl-parent:
        rationale: Runtime dependency
        ref: f38
      perl-podlators:
        rationale: Runtime dependency
        ref: f38
      qt3:
        rationale: Runtime dependency
        ref: f38
      redhat-menus:
        rationale: Runtime dependency
        ref: f38
...

Ha rimosso f38, kde, wayland

I would think you need to add a module section if I’m not mistaken in container.yaml. . .

So maybe here is an example :

the container.yaml file:

modules:
  - name: ksensors
    buildsystem: cmake
    builddir: true
    sources:
      - type: dir
        path: /path/to/source/directory  # Replace this with the actual path to your source directory
    build-options:
      ccache: true
    build-commands:
      - cmake .
      - make
    cleanup:
      - rm -rf build  # Add any cleanup commands if necessary
    flatpak:
      id: org.kde.ksensors
      runtime: org.kde.Platform
      runtime-version: 5.15
      sdk: org.kde.Sdk
      command: ksensors
      rename-icon: ksensors
      finish-args: |
        --socket=x11
        --socket=wayland
        --share=ipc
        --filesystem=host

the ksensors.yaml file:

name: ksensors
runtime: org.kde.Platform
runtime-version: '5.15'
sdk: org.kde.Sdk
command: ksensors
rename-icon: ksensors
tags:
  - graphics
  - kde
  - sensors
finish-args: |
  --share=ipc
  --socket=x11
  --socket=wayland
  --filesystem=host
modules:
  - name: ksensors
    sources:
      - type: git
        url: https://example.com/ksensors.git  # Replace with the actual URL to your repository
        branch: master  # Replace with the appropriate branch name
    buildsystem: cmake
    builddir: true
    cleanup:
      - rm -rf build  # Add any cleanup commands if necessary
    build-options:
      ccache: true
    build-commands:
      - cmake .
      - make

Slightly different from how I used to build Flatpaks, hope this helps you.

1 Like

In reality the modules section is already there.

I improved my post so that the contents of the files can be seen better.

I’m trying to use the commands suggested by the fedora documentation which are not the classic flatpak-builder, but for example flatpak-module, which should allow you to directly enter the use of rpm(s) for the libraries to be added.

I did some debuding of the flatpak-module commands, too complicated and the fedora documentation is outdated and leads to dead ends (at least for me).

I’m hoping someone who maintains or uses those commands will update the documentation and/or give me some suggestions.

In the meantime, I’m going back to trying the ‘normal’ method using flatpak-builder, and trying to take inspiration from your answers.

Thank you.

Yeah, i’m sorry but I have not had to build packages under the new style. all my experience is with the old way ( shouldn’t be too different? :thinking: ). I don’t have the environment to build and test this for you.

You have no reason to be sorry, I’m the one who tried to follow a path that theoretically should be easy, convenient and automatic (it seems to me that fedora uses it to automatically transform RMP(S) into flakpack).

The problem is my total inexperience and my groping here and there.

Things are starting to work, I’m missing some dependencies and then testing if the program installed by flatpak works (which I doubt).

This is my current manifest (if you, or anyone else, have any advice or criticism, thank you)

id: org.kde.ksensors5
runtime: org.kde.Platform
default-branch: master
runtime-version: 5.15-23.08
sdk: org.kde.Sdk
command: ksensors5
rename-icon: ksensors5
desktop-file-name-suffix:  (Nightly)
tags:
    - graphics
    - kde
    - sensors
finish-args:
  - --require-version=0.11.4
  - --share=ipc
  - --socket=wayland
  - --socket=fallback-x11
  - --socket=session-bus
  - --device=all
  - --filesystem=host
  - --filesystem=xdg-run/pipewire-0
  - --filesystem=xdg-config/kdeglobals:ro
modules:
  - name: lm_sensors
    buildsystem: autotools
#    build-options:
#       PREFIX: /app
#       DESTDIR: /app
    make-install-args:
       - PREFIX=/app
    builddir: true
    no-autogen: true
    sources:
      - type: dir
        path: ./lm-sensors-3-6-0
  - name: ksensors5
    buildsystem: cmake
    builddir: true
    sources:
      - type: dir
        path: ../
1 Like

Well, to my knowledge and tools I have used in the past. . . Tools like

fedmod rpm2flatpak & flatpak-builder along with Gnome Builder was how I used to do it.

Documentation was hit or miss. . .

It is quite a classic of the programmers, especially in open source, perhaps there is a lot of documentation of the individual and specific parts, but documentation that explains how to do things is little and contradictory.

It starts to work.

Schermata_20240506_212236

Now comes the really difficult part, lm_sensors and hddtemp don’t work properly, they don’t see the hardware and probably their configuration files.
And maybe this is another dead end.
I could use the help of someone experienced in this part, but I doubt that will happen.

1 Like

Can you post your current Manifest ? .yaml files and build commands (flatpak-build etc…)

something like :

modules:
  - name: ksensors
    # ... other configurations
    permissions:
      - path: /dev/bus/usb/*  # Example for USB sensors
        mode: access user
      - path: /dev/i2c*  # Example for I2C sensors (adjust paths as needed)
        mode: access user

Also just from thought you might need to provide --filesystem=host is there are any configuration files it needs to access.

1 Like

ksensors5.yaml

id: org.kde.ksensors5
runtime: org.kde.Platform
default-branch: master
runtime-version: 5.15-23.08
sdk: org.kde.Sdk
command: ksensors5
rename-icon: ksensors5
rename-desktop-file: ksensors5.desktop
desktop-file-name-suffix:  (Nightly)
tags:
    - graphics
    - kde
    - sensors
finish-args:
  - --require-version=0.11.4
  - --share=ipc
  - --socket=wayland
  - --socket=fallback-x11
  - --socket=session-bus
  - --device=all
  - --filesystem=host
  - --filesystem=xdg-run/pipewire-0
  - --filesystem=xdg-config/kdeglobals:ro
modules:
  - name: lm_sensors
    buildsystem: autotools
    make-args:
       - PREFIX=/app
    make-install-args:
       - PREFIX=/app
    builddir: true
    no-autogen: true
    sources:
      - type: dir
        path: ./lm-sensors-3-6-0
  - name: hddtemp
    buildsystem: autotools
    make-args:
       - PREFIX=/app
    make-install-args:
       - PREFIX=/app
    builddir: true
    sources:
      - type: dir
        path: ./hddtemp-0.3-beta15
  - name: ksensors5
    buildsystem: cmake
    builddir: true
    sources:
      - type: dir
        path: ../

build

flatpak-builder build ksensors5.yaml --force-clean --verbose

errors

hddtemp: can’t open /usr/share/misc/hddtemp.db

sensors_init: Kernel interface error

I suspect that I will have to customize the programs so that they behave differently within the flatpak package.

P.S. I have to say that flatpak is quite fascinating, what it manages to do, given the enormous complexities it has to deal with, is a discreet miracle.

You’re probably right, I need to do some experimenting and learn how to set access permissions.
it’s a good opportunity to learn almost about debugging a flatpak package.

The initial insistence on trying to use the fedora style build was also for the purpose of learning and gathering information, by banging my head against that wall I learned almost everything I know (very little :sweat_smile: ).

Thank you.

1 Like

Suggestions here :

Try including hddtemp.db within your flatpak by adding the directory containing the file to the sources section of the hddtemp module in your ksensors5.yaml

Under the modules section, consider adding a permissions section to grant access to the required device files.

I’m a little bit stretched here, but I’ll give you all I can to help. It’s been far too long since I built Flatpaks.

1 Like

Perhaps there are several overlapping problems.

The first is that I have to remember that any manual changes are very labile (the build inexorably erases them).

I tried this

mkdir -p build/files/usr/share/misc/
cp -a hddtemp.db build/files/usr/share/misc/

flatpak-builder --run build ksensors5.yaml sh

build/files/sbin/hddtemp
hddtemp: can’t open /usr/share/misc/hddtemp.db: No such file or directory

ls -l build/files/usr/share/misc/hddtemp.db
-rw-r–r-- 1 gdb gdb 2829 May 6 21:41 build/files/usr/share/misc/hddtemp.db

I think debugging and testing isn’t that trivial :sweat_smile: .
And I’d better go to refresh myself on how to activate the log in ksensors5.

I’m a little bit stretched here, but I’ll give you all I can to help. It’s been far too long since I built Flatpaks.

Please don’t stress yourself more about this.
The help given is already good, if this doesn’t amuse you, if it weighs on you, forget it, take care of yourself and the things around you.

Hmm, Well keep us posted and let’s see how far we can get. :+1:t5:

It’s no problem. The only issue is that I don’t have my main machine accessible at the moment. There, I would have easily recreated it and helped more. I also have a lot of my old flatpak builds and tools.

1 Like

Your Hmmm is correct.

I believe hddtemp is looking for its file in the runtime area, which I don’t think is updatable.

Maybe I really need to change hddtemp code.

flatpak-builder --run build ksensors5.yaml sh

ls /usr/share/misc/
magic.mgc

cp -a flatpak/build/files/usr/share/misc/hddtemp.db /usr/share/misc/
cp: cannot create regular file ‘/usr/share/misc/hddtemp.db’: Read-only file system

hddtemp -f build/files/usr/share/misc/hddtemp.db
/dev/sda: Permission denied (adding a permissions)
/dev/sdb: Permission denied ( … )
/dev/sdc: Permission denied ( … )
/dev/sdd: Permission denied ( … )
/dev/sde: HUAWEI TF CARD Storage: S.M.A.R.T. not available

:thinking:

Here is a Manifest from a project that also uses sensors etc, maybe contrast and compare?


Also try :
flatpak run --command=bash <app>

You’ve already attempted to copy it during the build process, but encountered a read-only filesystem issue.

Instead of trying to copy it directly to /usr/share/misc/, you can place the hddtemp.db file in a directory within your Flatpak application’s sandbox during the build process. Then, ensure that hddtemp knows where to find it.

1 Like

From what I understand and read, I still have a lot to learn, it will take me a while.

It seems that programs launched by kensors5 do not have the access privileges assigned to ksensors5, you need to modify it so that it launches commands using for example flapak-spawn.

Then I want to avoid double databases, settings and configurations, of the hardware description (in the host and in the flatpak package).

It’s going to be a long thing.

1 Like