Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flatpak version #11

Closed
AsciiWolf opened this issue Feb 27, 2021 · 8 comments
Closed

Flatpak version #11

AsciiWolf opened this issue Feb 27, 2021 · 8 comments

Comments

@AsciiWolf
Copy link

Thanks for making this useful app! I think it would be great if this app could be packaged as a Flatpak and published on Flathub. :-)

@ilya-zlobintsev
Copy link
Owner

ilya-zlobintsev commented Feb 27, 2021

I'm not sure if it's possible, since LACT requires a background daemon running as root, and I don't know if flatpak allows for such usage.
An appimage with a distro-agnostic install script would be possible, but it would still require things like the service to be installed separately, so it's still not a "single-file, self-contained application" scenario like it can be with standalone GUI apps.

I think making deb/rpm packages is a better approach for this kind of applications.

@eszlari
Copy link

eszlari commented Feb 26, 2023

A Flatpak version might be possible:

  1. First you need to build the daemon as a separate, fully statically linked binary.
  2. Flatpak allows you to run commands on the host system from inside the sandbox like this:
flatpak-run --host <COMMAND>

(needs the permission --talk-name=org.freedesktop.Flatpak)

  1. You could add a button to the GUI that says something like "Install & enable daemon on host system".
  2. This button would execute the following commands:
flatpak-run --host pkexec install -Dm755 $DIR/lactd /usr/local/bin/lactd
flatpak-run --host pkexec install -Dm644 $DIR/lactd.service /etc/systemd/system/lactd.service
flatpak-run --host pkexec systemctl enable --now lactd

The path to the files from the Flatpak installation data ($DIR) can be found in the file /.flatpak-info inside the sandbox.

@ilya-zlobintsev
Copy link
Owner

A Flatpak version might be possible:

1. First you need to build the daemon as a separate, fully statically linked binary.

2. Flatpak allows you to run commands on the host system from inside the sandbox like this:
flatpak-run --host <COMMAND>

(needs the permission --talk-name=org.freedesktop.Flatpak)

3. You could add a button to the GUI that says something like "Install & enable daemon on host system".

4. This button would execute the following commands:
flatpak-run --host pkexec install -Dm755 $DIR/lactd /usr/local/bin/lactd
flatpak-run --host pkexec install -Dm644 $DIR/lactd.service /etc/systemd/systemd/lactd.service
flatpak-run --host pkexec systemctl enable --now lactd

The path to the files from the Flatpak installation data ($DIR) can be found in the file /.flatpak-info inside the sandbox.

I initially rejected the idea of having the GUI and daemon parts being installed separately due to the installation process being convoluted, but if it could be automated like this, then maybe Flatpak isn't impossible after all.

However, there are some potential problems with this:

  • Will the daemon have to be reinstalled every time the GUI Flatpak is updated?
  • If the user uninstalls the Flatpak, there will still be a daemon leftover
  • Will the users understand that while they installed a Flatpak, in reality it's going to run an install script affecting the host system?

And probably the most important question: is there demand for it, when it's not a "proper" self-sufficient Flatpak application? There is a way to easily generate native packages for different distros now with pkger, with the only limitation being that the distro has the required dependencies (mainly gtk4). Are there many people that want to use LACT and happen to run a distro older than Ubuntu 22.04 or a semi-recent version of Fedora?

@AsciiWolf
Copy link
Author

Installing files into a system using flatpak-run --host is a very bad and dangerous idea, at least in my opinion.

@eszlari
Copy link

eszlari commented Feb 26, 2023

If you don't need systemd, you could run the daemon directly without installing:

flatpak-run --host pkexec $DIR/lactd

(see flathub/org.wireshark.Wireshark#4 (comment))

@AsciiWolf
Copy link
Author

That is a much better solution, thanks!

@ilya-zlobintsev
Copy link
Owner

If you don't need systemd, you could run the daemon directly without installing:

flatpak-run --host pkexec $DIR/lactd

(see flathub/org.wireshark.Wireshark#4 (comment))

The problem with this is that the process either:

  • Runs as a chlid process of the GUI, which means it exists when the GUI closes. This makes it pretty useless for fan control, and goes against the whole idea of why there is a daemon.
  • Gets detached and runs separately. This means that there is no lifecycle management of any kind as it's not a systemd service, with no way to restart it or even stop it outside of finding and killing the process manually.

@eszlari
Copy link

eszlari commented Feb 26, 2023

How about creating a link to the .service file:

flatpak-run --host pkexec systemctl enable /var/lib/flatpak/app/com.domain.LACT/current/active/files/lactd.service

https://unix.stackexchange.com/questions/271541/enabling-linked-unit-files-in-systemd

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants