gridcoin-community / Gridcoin-Research

Gridcoin-Research
MIT License
585 stars 173 forks source link

build: add Flatpak manifest file #2724

Open ikolomiko opened 7 months ago

ikolomiko commented 7 months ago

I've created an initial Flatpak manifest file and a script to create a local Flatpak bundle. The permissions are pretty much bare-bones at this point. Since the manifest doesn't give read/write permissions for the $HOME directory, the application fails to start after the initial setup done by the wizard. There are 3 ways to overcome this issue:

  1. Using a wrapper for setting the datadir to some predefined and sandboxed directory, just like how Bitcoin-Core handles this issue. This solution is pretty seamless and secure. However, it restricts the user from choosing another directory, and feels like a dirty hack.
  2. Letting the application access the $HOME directory. This approach requires the least effort. However, it violates the sandboxing Flatpak provides, and might cause conflicts if there's also a native version of Gridcoin installed besides the Flatpak version.
  3. Using the XDG Base Directory Specification for the default location of datadir, instead of using the ~/.GridcoinResearch directory. Following the XDG specifications is considered the best practice on Linux in general, both for Flatpak applications and for other package managers. However, this would require some modification in the codebase.
jamescowens commented 7 months ago

Actually, IIRC correctly, we already have code in the app handling the special Flatpack data directory scenario for BOINC in boinc.cpp, but not for the main data directory.

We have an existing issue that is the inverse of choice 2, which is here.... https://github.com/gridcoin-community/Gridcoin-Research/issues/2650. The issue is that if both the native and flatpack BOINC are installed, the Gridcoin app defaults to the native version of BOINC.

Since we need to straighten out flatpack handling anyway, I strongly advocate choice 3.

We should have some discussion here about what that would look like.

ikolomiko commented 5 months ago

@div72 A general guideline can be found here. About the filesystem access for unified config data, there's a special section in the Flathub requirements guide which strictly discourages that. While I'm not sure if it disqualifies the app from getting published on Flathub, it certainly is not the expected behavior of a Flatpak app.

jamescowens commented 5 months ago

I think we need to live with the XDG spec. Do we need to modify the existing FlatPack handling code?

jamescowens commented 5 months ago

The linter is barking again.... :)

ikolomiko commented 5 months ago

Apparently the web editor of GitHub inserts CRLF line endings to commit messages, causing the linter to go crazy, lol. Gotta rewrite the commit messages locally.

jamescowens commented 5 months ago

That is crazy that the Github editor is following the Windows line ending standard...

ikolomiko commented 5 months ago

Made a bunch of additions to the manifest for some permissions. AFAICT, the only missing piece is setting the default value of datadir to one of the XDG base directories. Possible candidates are XDG_DATA_HOME, XDG_CONFIG_HOME and XDG_STATE_HOME. Any ideas on which to pick?

CyberTailor commented 2 months ago

Using a wrapper for setting the datadir to some predefined and sandboxed directory, just like how Bitcoin-Core handles this issue. This solution is pretty seamless and secure. However, it restricts the user from choosing another directory, and feels like a dirty hack.

Actually no. Flatpak permissions can be fine-tuned in the system settings if you use KDE and in third-party Flatseal application otherwise.

CyberTailor commented 2 months ago

I'd also like to note that a .metainfo.xml file is required in order to be listed in app stores.

CyberTailor commented 2 months ago

I'm all for following the XDG specification but Flatpak's default XDG_*_HOME variables are set to application specific ~/.var/app/us.gridcoin.Gridcoin-Research/... which means a native installation and a Flatpak installation would have differing data directories. Flatpak advocates this but I'm not exactly sold on that. I think having a unified datadir is better UX overall.

Users installing both their distro's package and the Flatpak are going to be confused anyway.