Access to system directories from flatpak - lagrang3 - 07-15-2023
I've started developing an app for the Pinephone, my app would be deployed with a flatpak.
My application needs access to system directories to read the device camera.
Doing some testing I've discovered that a native Pinephone application called megapixels doesn't launch if I package it into a flatpak. The error is related to not being able to read a system directory `/sys/firmware/devicetree/base`
In order to diagnose the problem I've run a python terminal inside the container and I've verified that neither `/sys/firmware` nor `/dev/video*` are visible from within the container:
Code: mobian@mobian:~$ /usr/bin/flatpak run --branch=master --arch=aarch64 --command=python3 com.lagrange.myapp
Python 3.11.4 (main, Jul 13 2023, 12:52:58) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.listdir('/sys')
['devices', 'dev', 'class', 'bus', 'block']
>>> os.listdir('/dev')
['console', 'ptmx', 'pts', 'shm', 'core', 'fd', 'stderr', 'stdout', 'stdin', 'tty', 'urandom', 'random', 'full', 'zero', 'null']
>>> exit()
they are there, just not visible from the container:
Code: mobian@mobian:~$ ls /dev/video*
/dev/video0 /dev/video1 /dev/video2 /dev/video3
mobian@mobian:~$ ls /sys
block bus class dev devices firmware fs kernel module power
Even though I've built the flatpak with `"finish-args": ["--filesystem=host", "--filesystem=host-os"]`.
What am I missing?
Any help will be much appreciated.
RE: Access to system directories from flatpak - EuvzO8 - 02-20-2025
(07-15-2023, 05:53 AM)lagrang3 Wrote: I've started developing an app for the Pinephone, my app would be deployed with a flatpak.
My application needs access to system directories to read the device camera.
Doing some testing I've discovered that a native Pinephone application called megapixels doesn't launch if I package it into a flatpak. The error is related to not being able to read a system directory `/sys/firmware/devicetree/base`
In order to diagnose the problem I've run a python terminal inside the container and I've verified that neither `/sys/firmware` nor `/dev/video*` are visible from within the container:
Code: mobian@mobian:~$ /usr/bin/flatpak run --branch=master --arch=aarch64 --command=python3 com.lagrange.myapp
Python 3.11.4 (main, Jul 13 2023, 12:52:58) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.listdir('/sys')
['devices', 'dev', 'class', 'bus', 'block']
>>> os.listdir('/dev')
['console', 'ptmx', 'pts', 'shm', 'core', 'fd', 'stderr', 'stdout', 'stdin', 'tty', 'urandom', 'random', 'full', 'zero', 'null']
>>> exit()
they are there, just not visible from the container:
Code: mobian@mobian:~$ ls /dev/video*
/dev/video0 /dev/video1 /dev/video2 /dev/video3
mobian@mobian:~$ ls /sys
block bus class dev devices firmware fs kernel module power
Even though I've built the flatpak with `"finish-args": ["--filesystem=host", "--filesystem=host-os"]`.
What am I missing?
Any help will be much appreciated.
AFAIK running app using following command should give you access to /dev and /sys/firmware.
Code: flatpak run --device=all --filesystem=/sys <app-id>
Is your source code for megapixels flatpak publicly available in some repo?
RE: Access to system directories from flatpak - tllim - 02-25-2025
(02-20-2025, 01:40 AM)EuvzO8 Wrote: (07-15-2023, 05:53 AM)lagrang3 Wrote: I've started developing an app for the Pinephone, my app would be deployed with a flatpak.
My application needs access to system directories to read the device camera.
Doing some testing I've discovered that a native Pinephone application called megapixels doesn't launch if I package it into a flatpak. The error is related to not being able to read a system directory `/sys/firmware/devicetree/base`
In order to diagnose the problem I've run a python terminal inside the container and I've verified that neither `/sys/firmware` nor `/dev/video*` are visible from within the container:
Code: mobian@mobian:~$ /usr/bin/flatpak run --branch=master --arch=aarch64 --command=python3 com.lagrange.myapp
Python 3.11.4 (main, Jul 13 2023, 12:52:58) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.listdir('/sys')
['devices', 'dev', 'class', 'bus', 'block']
>>> os.listdir('/dev')
['console', 'ptmx', 'pts', 'shm', 'core', 'fd', 'stderr', 'stdout', 'stdin', 'tty', 'urandom', 'random', 'full', 'zero', 'null']
>>> exit()
they are there, just not visible from the container:
Code: mobian@mobian:~$ ls /dev/video*
/dev/video0 /dev/video1 /dev/video2 /dev/video3
mobian@mobian:~$ ls /sys
block bus class dev devices firmware fs kernel module power
Even though I've built the flatpak with `"finish-args": ["--filesystem=host", "--filesystem=host-os"]`.
What am I missing?
Any help will be much appreciated.
AFAIK running app using following command should give you access to /dev and /sys/firmware.
Code: flatpak run --device=all --filesystem=/sys <app-id>
Is your source code for megapixels flatpak publicly available in some repo?
Check with Martijn, the Megapixel developer. https://git.sr.ht/~martijnbraam/libmegapixels
|