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 packaging #14

Open
AtmosphericIgnition opened this issue Dec 20, 2024 · 27 comments
Open

Flatpak packaging #14

AtmosphericIgnition opened this issue Dec 20, 2024 · 27 comments
Labels

Comments

@AtmosphericIgnition
Copy link

I'm sure at least some Futo engineers are familiar with the Flatpak packaging format for Linux. Offering a Grayjay Flatpak would have the following advantages:

  • Easy installation on every distribution which offers Flatpak support (every distro I know does)
  • You get to vendor your own dependencies, preventing issues stemming from different distro packaging outdated or patched dependencies
  • More consistent stack traces and crash reports, since the app runs in the same environment on every distro

You could publish on Flathub, which would make installing Grayjay even easier, since almost every distro already configures Flathub out of the box, and give you some additional exposure. Flathub has some guidelines for developers who want to get verified, or get their app featured on the front page.

If you want the benefits of Flatpak, but for any reason do not want to deal with Flathub, you can also self-host your own Flatpak repository (you already self-host an F-Droid repo). There is documentation for this on the Flatpak website.

I understand this will most likely be very low priority, before Grayjay Desktop reaches a stable release.

@Mr-Bajs
Copy link

Mr-Bajs commented Dec 21, 2024

Yes, an verified release on Flathub would be most welcome. I'll guess it's on the roadmap for the stable release.

@ffoxD
Copy link

ffoxD commented Dec 26, 2024

The current tarball approach is not optimal, a flatpak release would be greatly beneficial!
Flatpaks work on all distros and systems regardless of installed libraries, are auto-updating and are super convenient.

@zestygrass
Copy link

+1

@MoralCode
Copy link

MoralCode commented Jan 15, 2025

I've made a few flatpak contributions before so i figured i'd give this a shot (more as a learning project than anything else)

Here's my metadata repo so far: https://github.com/MoralCode/Grayjay-Flatpak/tree/grayjay-desktop

Current status: i can get it to build a flatpak, but I'm still working through a list of errors when I go to run it that are mostly caused by Flatpak's read only filesystem and structure. If anyone is familiar with how Flatpak's work, assistance would definitely be appreciated to help speed up the process.

The current issue that I have that I cant resolve easily is that Grayjay wants to create a temp_files directory. When it tries to, it runs into Unhandled exception. System.IO.IOException: Read-only file system : '/app/grayjay/temp_files'

When I symlink that location to a place that is writable, it complains that Unhandled exception. System.IO.IOException: The file '/app/grayjay/temp_files' already exists.

related: #63. seems like the issue is fixed and just waiting for a new release. so flatpaks cant work until at least release 6 comes out.

@MoralCode
Copy link

Another not really issue but something that may be nice to have is that FUTO's source first license does not have an SPDX identifier associated with it, making it hard to define the license in the flatpak metadata (therefore i just made up some value)

@AtmosphericIgnition
Copy link
Author

Flathub has a "Special license" option for cases like this. See DuckStation for an example.

With FUTO's license, the Flathub license section would be yellow and read something like:

This app is developed under the special license Source First License 1.1.
You may or may not be able to contribute to this app.

@MoralCode
Copy link

MoralCode commented Jan 15, 2025

Flathub has a "Special license" option for cases like this. See DuckStation for an example.

Yeah, it looks like that may be detecting the use of a creative commons license for source code (which is typically not recommended). While i cant find the manifest for DuckStation (the flathub page links to a github gist thats now a 404) I strongly suspect they still declared that license using the SPDX identifier that exists for that particular creative commons license (since thats a well known license for art and other content).

Also looking at Flatpaks MetaInfo guidelines, i think i may be technically in the wrong by making up something thats not in the SPDX identifier list.

i might end up doing what the docs suggest until theres a proper identifier for all the variants of the source first license:

Proprietary applications/custom licenses can use LicenseRef-proprietary with a link to the license:

<project_license>LicenseRef-proprietary=https://example.org/legal/</project_license>

I realize calling grayjay proprietary is not correct, but if I cant specify the source first license, id rather err on the side of proprietary and then have people be surprised to read the license and find that its more open versus the other way around.

Let me know if there's a different way that flathub offers to specify custom, non-SPDX licenses that I'm not aware of!

@AtmosphericIgnition
Copy link
Author

When publishing to Flahub, I'm sure they will be able to override their system, and make FUTO's license fall into the "special license" category on their site. For now, the LicenseRef-proprietary is probably the best option.

@MoralCode
Copy link

related: #63. seems like the issue is fixed and just waiting for a new release. so flatpaks cant work until at least release 6 comes out.

Seems like release 5 has disappeared from the tagged releases? unsure what happened

@MoralCode
Copy link

@michaelBelsanti's nix build from source config may also be pretty helpful here. I'm probably still going to wait for a new release to get cut and work from there

@MoralCode
Copy link

ok, release 5 is back, but unsure if it contains the necessary fix to follow the XDG spec

@Zvonimir-FUTO
Copy link
Collaborator

ok, release 5 is back, but unsure if it contains the necessary fix to follow the XDG spec

that was included in v4 already

@MoralCode
Copy link

MoralCode commented Feb 27, 2025

ah ok. Does the latest tagged release correspond to the zip files that are hosted on the grayjay website? thats currently where im getting the release versions of the code for the flatpak so i'm not dealing with both setting up a new build process AND seeing if it works

@Zvonimir-FUTO
Copy link
Collaborator

Yep

@MoralCode
Copy link

MoralCode commented Mar 2, 2025

Small breakthrough: i now have a window that opens

cons: the window is blank and there are errors in the log.

will keep playing with it. contributions from people who know this codebase better are welcome! I definitely wont have the bandwidth to maintain this into forever

@MoralCode
Copy link

MoralCode commented Mar 2, 2025

Side quest for someone else:

#167 (comment) should probably be documented somewhere for others trying to use this app in other systems/configurations, like installing to /opt. i also experienced it while debugging the flatpak stuff but ended up only doing so after reading the code, so it would have saved me time

@MoralCode
Copy link

we have a UI!

Image

Note for anyone recreating this: you need to copy wwwroot and grayjay.png from the extracted zip file into the user data location (ptobably .var/app/app.grayjay.Desktop/data/Grayjay) in order for it to work. This is an ugly hack that is so ugly i didn't want to automate it becuase i dont want to automatically pollute peoples data directories with stuff that shouldnt be there

@MoralCode
Copy link

MoralCode commented Mar 2, 2025

playing with the app now. it appears to work well.
Actions tried:

  • add the youtube plugin
  • enable the youtube plugin
  • set up sync from my phone
  • play a video from my feed

A couple youtube channel thumbnails seem to not be loading but that seems pretty minor

My system is a Kubuntu 24.04 LTS system, so having some validation that this works (even with the sketchy workaround above) on other systems (Gnome, NixOS/atomic distros, etc) would be great

@MoralCode
Copy link

MoralCode commented Mar 3, 2025

Should people choose to test this early and dont want to build it from the metadata, i found some instructions for bundling a flatpak to (and loading it from) a file.

The bundle file I have generated has been uploaded as an artifact to the repository at https://github.com/MoralCode/Grayjay-Flatpak/releases/tag/v1

Note the comments above and in the "release notes" - you need to copy some files to make it run.

Proposing this to flathub is currently blocked on:

  • the proper resolution to the XDG desktop spec problems mentioned in the relevant issue (so people dont need the hacky workaround)
  • hearing from a couple people here that have tested this on a few systems and conform that it works - i.e. that theres nothing obviously/stupidly wrong about this setup, like missing a permission for something obvious. I will also start dogfooding this in case i catch anything that my initial impressions didnt

@MoralCode
Copy link

MoralCode commented Mar 3, 2025

oh another known issue: i need to fix the .desktop file so you have to use flatpak run i think

Edit: fixed, but its not in the v1 bundle

@AtmosphericIgnition
Copy link
Author

There is also a question of whether someone can actually get the Flatpak building from source. This would mean Flathub could distribute ARM64 binaries, which are currently missing from the official releases. I believe that building the Flatpak from source is a requirement for verification on Flathub (at least for FOSS applications).

@MoralCode
Copy link

yeah, since this is my first time packaging a flatpak start to finish, I figured id start on easy mode and use the zip so I wasn't trying to debug two unknowns at once.

Happy to help if someone else wants to take the lead on learning how to build from source!

@AtmosphericIgnition
Copy link
Author

I tried to build your repo, and I did get a window to open, but it's currently just a blank white, and is throwing errors about accessing my system's secret service provider.

I'm also a bit concerned about running anything Chromium-based with --no-sandbox. Chromium Flatpak apps do not get access to unprivileged user namespaces, or the chrome-sandbox SUID binary (one of these two is necessary for Chromium's Layer 1 sandbox to work correctly), and are instead expected to use Flatpak's sub-sandbox API. Currently, Chromium doesn't support this API. The only real solution right now is to use Zypak which works around this issue.

> $ flatpak run app.grayjay.Desktop
Directories:AppContext.BaseDirectory: /app/grayjay/
Directories:Base Directory: /home/user/.var/app/app.grayjay.Desktop/data/Grayjay
Directories:Temporary Directory: /home/user/.var/app/app.grayjay.Desktop/data/Grayjay/temp_files
Directories:Log file path: /home/user/.var/app/app.grayjay.Desktop/data/Grayjay/log.txt
ManagedThreadPool:New threadpool created (16)
ManagedThreadPool:New threadpool created (4)
T:PortFile path: /home/user/.var/app/app.grayjay.Desktop/data/Grayjay/port
T:StartingUpFile path: /home/user/.var/app/app.grayjay.Desktop/data/Grayjay/starting
T:Found StartingUpFile, waiting for PortFile and process
T:No PortFile after waiting, killing any lingering (stuck) process
T:Created StartingUpFile, removed PortFile
Program:Main: StateApp.Startup
StateApp:Startup: Initializing PluginEncryptionProvider
StateApp:Startup: Initializing DatabaseConnection
StateApp:Startup: Ensuring Table DBSubscriptionCache
StateApp:Startup: Ensuring Table DBHistory
StateApp:Startup: Initializing Download Cycle
StateDownloads:Started downloading cycle
StateDownloads:Ended downloading cycle
Program:Main: StateApp.Startup finished (91ms)
Program:Extra args:
Program:Main: Starting DotCefProcess
CEF:Searching for dotcefnative, search paths:
CEF: - /app/grayjay/cef/dotcefnative
CEF: - /app/grayjay/dotcefnative
CEF: - /home/user/.var/app/app.grayjay.Desktop/data/Grayjay/dotcefnative
CEF: - /home/user/.var/app/app.grayjay.Desktop/data/Grayjay/cef/dotcefnative
CEF:Working directory '/app/grayjay/cef'.
CEF:CEF exe path '/app/grayjay/cef/dotcefnative'.
--change-stack-guard-on-fork=disable --parent-to-child 107 --child-to-parent 110 --disable-web-security --use-alloy-style --use-native --no-sandbox
Program:Main: Starting DotCefProcess finished (7ms)
Program:Main: Starting window.
Receive loop started.
GrayjayServer:RunServerAsync: Called with (proxyUrl = ).
CEF:[0302/194627.990659:INFO:pipe.cc(149)] Pipe set handles readFd 107, writeFd 110
CEF:[0302/194627.990742:INFO:main_linux.cc(100)] Set handles.
CEF:[0302/194627.990792:INFO:main_linux.cc(180)] Cache path: /tmp/dotcef_1740962787990
CEF:[0302/194627.991415:ERROR:chrome_main_delegate.cc(1193)] Web security may only be disabled if '--user-data-dir' is also specified with a non-default value.
CEF:[36:36:0302/194628.060210:ERROR:object_proxy.cc(576)] Failed to call method: org.kde.KWallet.isEnabled: object_path= /modules/kwalletd6: org.freedesktop.DBus.Error.ServiceUnknown: org.freedesktop.DBus.Error.ServiceUnknown
CEF:[36:36:0302/194628.060231:ERROR:kwallet_dbus.cc(117)] Error contacting kwalletd6 (isEnabled)
CEF:[36:36:0302/194628.060320:ERROR:object_proxy.cc(576)] Failed to call method: org.kde.KLauncher.start_service_by_desktop_name: object_path= /KLauncher: org.freedesktop.DBus.Error.ServiceUnknown: org.freedesktop.DBus.Error.ServiceUnknown
CEF:[36:36:0302/194628.060326:ERROR:kwallet_dbus.cc(86)] Error contacting klauncher to start kwalletd6
CEF:[36:36:0302/194628.060406:ERROR:object_proxy.cc(576)] Failed to call method: org.kde.KWallet.close: object_path= /modules/kwalletd6: org.freedesktop.DBus.Error.ServiceUnknown: org.freedesktop.DBus.Error.ServiceUnknown
CEF:[36:36:0302/194628.060411:ERROR:kwallet_dbus.cc(412)] Error contacting kwalletd6 (close)
Received notification Ready
Client is ready.
GrayjayServer:RunServerAsync: Static files path '/home/user/.var/app/app.grayjay.Desktop/data/Grayjay/wwwroot'.
CEF:main with processType = 1.
CEF:Argument 0: '/app/grayjay/cef/dotcefnative'.
CEF:Argument 1: '--type=zygote'.
CEF:Argument 2: '--no-zygote-sandbox'.
CEF:Argument 3: '--no-sandbox'.
CEF:Argument 4: '--string-annotations'.
CEF:Argument 5: '--enable-crash-reporter=,'.
CEF:Argument 6: '--user-data-dir=/tmp/dotcef_1740962787990'.
CEF:[36:36:0302/194628.100034:ERROR:client_util_linux.cc(53)] Failed to load image from path: /home/user/.var/app/app.grayjay.Desktop/data/Grayjay/grayjay.png
Received notification WindowOpened
Window opened: 1
Program:Main: Unhandled error in RunServerAsync.
System.IO.DirectoryNotFoundException: /home/user/.var/app/app.grayjay.Desktop/data/Grayjay/wwwroot/
   at Microsoft.Extensions.FileProviders.PhysicalFileProvider..ctor(String root, ExclusionFilters filters)
   at Grayjay.ClientServer.GrayjayServer.RunServerAsync(String proxyUrl, CancellationToken cancellationToken)
   at Grayjay.Desktop.Program.<>c__DisplayClass14_0.<<EntryPoint>b__3>d.MoveNext()
Received notification WindowFocused
Program:Main: Starting window finished (148ms)
Program:Main: Waiting for ASP to start.
Received notification WindowLoadStart
Received notification WindowLoadEnd

Image

@MoralCode
Copy link

MoralCode commented Mar 3, 2025

i saw the secrets errors too when i got it running, those are not the problem causing this.

Per MoralCode/Grayjay-Flatpak#6, you need to copy two files from the installation directory (easiest to just download the zip fresh) into your flarpak user data directory.

I'm also a bit concerned about running anything Chromium-based with --no-sandbox.

This is not something I configured. it is part of the args passed in, which are provided at

cef.Start("--disable-web-security --use-alloy-style --use-native --no-sandbox " + extraArgs);

i dont know what specifically cef is for so i cant comment on the necessity of this but this is proably worth filing a new issue (or searching for an existing issue) for.

and is throwing errors about accessing my system's secret service provider.

filed at MoralCode/Grayjay-Flatpak#7

@AtmosphericIgnition
Copy link
Author

I made #416 to see what Futo's engineering team says about this.
Looking through the code, I couldn't find any comments in the source code about why the sandbox is disabled. If Futo decides to stop disabling Chromium's sandbox, the Flatpak will need to start using Zypak for the sandbox to run in a Flatpak environment.

@MoralCode
Copy link

Status update: I have build from source working now and have a set of patches pending integration into the upstream gitlab repo for removing the ugly hacks workaround.

Once the patches are in the right places, ill start the PR for getting this contributed to flathub

@MoralCode
Copy link

MoralCode commented Mar 10, 2025

submission has been made to the flathub repo, so we'll see how it goes from there!

(if anyone spots any issues with my submission based on your own flatpak experience, please let me know!)

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

No branches or pull requests

6 participants