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

Package as Flatpak for elementary OS 6 #143

Open
danirabbit opened this issue Jul 7, 2021 · 12 comments
Open

Package as Flatpak for elementary OS 6 #143

danirabbit opened this issue Jul 7, 2021 · 12 comments

Comments

@danirabbit
Copy link

As you might have heard, AppCenter is going Flatpak! For elementary OS 6, we will not longer be accepting Debian packaging, so your app will need to be updated.

We have documentation on our developer guide for writing your Flatpak manifest here: https://docs.elementary.io/develop/writing-apps/our-first-app/packaging#flatpak-manifest

Also, in case you missed it, elementary OS 6 beta 2 is now available. This is a great time to get your app packaged up as Flatpak and test that everything is working before the final release. AppCenter submission for OS 6 will be open soon, so don't delay :)

@iguys
Copy link

iguys commented Jan 1, 2022

Please make a flatpak app for Elementary OS 6 , we are really missing this app in the app store. Thanks

@dcowan-london
Copy link

dcowan-london commented Jan 9, 2022

I've been trying to get WebPin working in a FlatPak for the past few days.

See #145.

I think it's best for me to move to this issue.

I currently have two issues:

  1. WebPin keeps track of apps by getting the full list of installed apps (GLib.AppInfo.get_all () - https://github.com/artemanufrij/webpin/blob/master/src/Services/DesktopFilesManager.vala#L55). This list is not available in the FlatPak container. The solution would be to switch to just looking in $XDG_DATA_HOME/applications (where WebPin stores the .desktop files).

  2. WebPin uses GLib.DesktopAppInfo to parse the .desktop file. GLib.DesktopAppInfo fails if the path in Exec doesn't exist. Since FlatPak applications are launched with flatpak run (which doesn't exist in the FlatPak container), WebPin sees no apps. This could be fixed by either some kind of symlink (so that flatpak run does exist in the container - possibly just make flatpak run com.github.artemanufrij.webpin an alias for /app/bin/com.github.artemanufrij.webpin?), or go the AppEditor route, and patch GLib so it still parses .desktop files even if the path in Exec doesn't exist (https://github.com/donadigo/appeditor/blob/master/external/glib-appinfo.patch#L1).

On a separate note, the icon picker needs to switch to using the FileChooser portal.

@dcowan-london
Copy link

As far as two, above, I've put a bash script which just echos "flatpak" in /app/bin/flatpak (in the container). Everything now works flawlessly. Probably not the "correct" method, but it works.

@dcowan-london
Copy link

I've pushed what I have so far to https://github.com/dcowan-london/webpin/tree/flatpak.

@dcowan-london
Copy link

When testing on another device, I got this error when I attempted to start a webapp:

Cannot get default EGL display: EGL_BAD_PARAMETER
Cannot create EGL sharing context: invalid display (last error: EGL_SUCCESS)

(WebKitWebProcess:18): Gdk-WARNING **: 17:19:35.736: The program 'WebKitWebProcess' received an X Window System error.
This probably reflects a bug in the program.
The error was '167'.
  (Details: serial 179 error_code 167 request_code 152 (unknown) minor_code 21)
  (Note to programmers: normally, X errors are reported asynchronously;
   that is, you will receive the error a while after causing it.
   To debug your program, run it with the GDK_SYNCHRONIZE environment
   variable to change this behavior. You can then get a meaningful
   backtrace from your debugger if you break on the gdk_x_error() function.)

This error repeats on every attempted reload.

@dcowan-london
Copy link

Well, after updating to SDK version 6.1 (from 6), this error is gone

@dcowan-london
Copy link

I now have a working build at https://github.com/dcowan-london/webpin/tree/flatpak

Note that currently the file picker dialogue doesn't have access to the filesystem, and so there's no way to set an app icon from with the filepicker. My next step is to integrate the filepicker portal.

@dcowan-london
Copy link

dcowan-london commented Feb 17, 2022

I've temporarily allowed access to xdg-pictures/webpin, to allow testing until the portal is integrated.
dcowan-london@3e33791

@dcowan-london
Copy link

Well, that was pretty simple! Switched to FileChooserNative - tested and working. dcowan-london@e8f2501

@dcowan-london
Copy link

OK, issue I'm having now is downloads. When downloading something from a pinned website, it attempts to go directly into the xdg-download directory. I could give rw access to the downloads folder, but I'd prefer to avoid that if possible.

Hoping I can somehow allow just writing new files to a directory without giving read/modify access.

@dcowan-london
Copy link

So it turns out that WebKit, by default, tries to save downloads to xdg-download, but there's an API (WebKit.WebContext.download_started ()) which lets you capture a WebKit.Download object and redirect the download (WebKit.Download.set_destination ()).

I've been able to catch the signal and open a FileChooser Portal, and set_destination ().

The problem is that after that, none of the progress signals (created_destination (), finished () or failed ()) seem to fire, and the download doesn't get saved. And there's nothing in the console.

The only thing which might possibly be helpful is this error, which appears when the FileChooser is opened (file_chooser.run ()):

(com.github.artemanufrij.webpin:20): GVFS-WARNING **: 18:55:59.995: The peer-to-peer connection failed: Error when getting information for file “/run/user/1000/gvfsd”: No such file or directory. Falling back to the session bus. Your application is probably missing --filesystem=xdg-run/gvfsd privileges.

(com.github.artemanufrij.webpin:20): GVFS-WARNING **: 18:55:59.998: The peer-to-peer connection failed: Error when getting information for file “/run/user/1000/gvfsd”: No such file or directory. Falling back to the session bus. Your application is probably missing --filesystem=xdg-run/gvfsd privileges.

(com.github.artemanufrij.webpin:20): GVFS-WARNING **: 18:55:59.999: The peer-to-peer connection failed: Error when getting information for file “/run/user/1000/gvfsd”: No such file or directory. Falling back to the session bus. Your application is probably missing --filesystem=xdg-run/gvfsd privileges.

(com.github.artemanufrij.webpin:20): GVFS-WARNING **: 18:55:59.999: The peer-to-peer connection failed: Error when getting information for file “/run/user/1000/gvfsd”: No such file or directory. Falling back to the session bus. Your application is probably missing --filesystem=xdg-run/gvfsd privileges.

These errors appear even when --filesystem=xdg-run/gvfsd is explicitly in the FlatPak manifest.

Leaving this here for now - I plan to come back at some point!

@jtrees
Copy link

jtrees commented Jul 4, 2022

@dcowan-london Just wanted to say thanks for tackling this. I look forward to seeing this come to fruition.

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

4 participants