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

[Packaging] Add experimental Flatpak support #72

Closed
wants to merge 3 commits into from

Conversation

julianrichen
Copy link
Contributor

This pr adds an initial flatpak manifest and should close #71. I would recommend changing the gcolor3.svg, gcolor3.desktop, & gcolor3.appdata.xml file from gcolor.* to org.unia.gcolor3.* since flatpak automatically looks for those files based on the application id. It would also be needed since the the shell will look for org.unia.gcolor3.svg but your application will look for gcolor3.svg in the About modal window.

Things seem to be working and I added --socket=wayland but obviously because of #67 it won't work 100% on wayland. Didn't try x11 since I use wayland.

Build

flatpak --user remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
flatpak --user install flathub org.gnome.Platform//3.26
flatpak --user install flathub org.gnome.Sdk//3.26

flatpak-builder --force-clean --repo=repo gcolor3 org.unia.gcolor3.json
flatpak --user remote-add --no-gpg-verify --if-not-exists gcolor3 repo
flatpak --user install gcolor3 org.unia.gcolor3
flatpak --user update org.unia.gcolor3

flatpak run org.unia.gcolor3

Future

If you plan on following-up on #59 then you will need to add the following to finish-args:

"--env=DCONF_USER_CONFIG_DIR=.config/dconf",
"--filesystem=xdg-run/dconf",
"--filesystem=~/.config/dconf:ro",
"--talk-name=ca.desrt.dconf",

@Hjdskes
Copy link
Owner

Hjdskes commented Nov 10, 2017

Thanks! I'll take a look at this in the coming days!

Copy link
Owner

@Hjdskes Hjdskes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So those few days turned into a few months... sorry!

I have a few questions regarding some options, see below. It seems to run file, although it does not have access to ~/.rgb.ini (it creates its own in ~/.var/app/org.unia.gcolor3/config/gcolor3/config.ini) and seems to complain about DBus:

(gcolor3:3): GLib-GIO-CRITICAL **: g_dbus_proxy_new: assertion 'G_IS_DBUS_CONNECTION (connection)' failed

I'm also getting this:

(gcolor3:3): Gtk-WARNING **: Could not load a pixbuf from icon theme.
This may indicate that pixbuf loaders or the mime database could not be found.

Do you know how to get these resolved? I'd love to have a working Flatpak up on Flathub!

"--socket=x11",
"--socket=wayland",

"--filesystem=xdg-config/gcolor3/config.ini:ro"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this for? The colors are written to ~/.rgb.ini, not ~/.config/gcolor/config.ini, if that's what this is.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The flatpak is based off v2.2 which has this in the changelog:

  • Follow the XDG directory specification (d91dd06).
    This means that the configuration file has moved from ~/.rgb.ini to $XDG_CONFIG_HOME/gcolor3/config.ini

Or at least I think that was the reasoning, it's been a while since I wrote it

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops, you're 100% right! I forgot that PR.

],

"build-options": {
"cflags": "-O2 -g"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we distribute a debug build inside the Flatpak?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most, if not all of the flathub builds do:
https://github.com/search?q=org%3Aflathub+-g&type=Code

I'm not 100% sure why they agreed to this since flathub only accepts stable builds so it's not like you would be debugging a broken build.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strange, but if they all do it, let's do so too.

@Hjdskes
Copy link
Owner

Hjdskes commented Jan 19, 2018

I would recommend changing the gcolor3.svg, gcolor3.desktop, & gcolor3.appdata.xml file from gcolor.* to org.unia.gcolor3.* since flatpak automatically looks for those files based on the application id. It would also be needed since the the shell will look for org.unia.gcolor3.svg but your application will look for gcolor3.svg in the About modal window.

Thanks, I'll be sure to make those changes (or you can here directly, if you will). Since my GitHub handle changed to Hjdskes, I'm planning s/unia/hjdskes/ also.

@julianrichen
Copy link
Contributor Author

I would recommended releasing v2.3 before pulling this but after you do the rename. You seem to have a lot of quality of life fixes that wouldn't be included in the new flatpak sent to flathub. Also flathub doesn't accept flatpaks built from master so it needs to either be a logical "stable" commit or better yet a archive file. I would much rather change the source from git to archive with a url pointing to https://github.com/Hjdskes/gcolor3/archive/v2.2.tar.gz or similar.

Also flathub doesn't seem 100% sure what to do about apps that rename their app-id yet so they ask you don't change them after submitting. They can rename the repo but OSTree is a bit harder, so I would only submit after you s/unai/hjdskes/.

@Hjdskes
Copy link
Owner

Hjdskes commented Jan 19, 2018

Re v2.3, definitely on the planning. Time is the # 1 problem for me at the moment.

Also flathub doesn't accept flatpaks built from master so it needs to either be a logical "stable" commit or better yet a archive file.

Does what you did in 66147fe work for you, or do we need to switch to branches for releases?

@julianrichen
Copy link
Contributor Author

You just need to change the url to v2.3 or whichever version you are planning to upgrade to and generate a new sha256 checksum.

We could also have the local flatpak file point to the master branch for nightly testing and submit a stable version to flathub. I found developing using flatpak in GNOME Builder to be very nice since the builds are reproducible and independent from the current system.

Their might be some issue atm since the app-id passed into GApplicaition is the old one. I was writing another commit to change all the app-ids but ran into a linker issue and had to bolt to classes. I have some before class so I'm going to look into it.

Hjdskes added a commit that referenced this pull request Jan 24, 2018
To follow GNOME standards and to prevent necessary renaming in the
Flatpak manifest (see #72).
@Hjdskes
Copy link
Owner

Hjdskes commented Jan 24, 2018

I did the rename in https://github.com/Hjdskes/gcolor3/tree/rename, which currently is on top of this branch so I can easily test the Flatpak. Compiling and running works locally (i.e. not inside a Flatpak), however when rebuilding the Flatpak (with hjdskes instead of unia, of course) I get the following:

** (gcolor3:3): WARNING **: Error writing file: Failed to rename file ?/home/jente/.var/app/org.hjdskes.gcolor3/config/gcolor3/config.ini.VVREDZ? to ?/home/jente/.var/app/org.hjdskes.gcolor3/config/gcolor3/config.ini?: g_rename() failed: Device or resource busy

I am not sure if this is related to the renaming. Can you test this @julianrichen?

Hjdskes added a commit that referenced this pull request Jan 24, 2018
To follow GNOME standards and to prevent necessary renaming in the
Flatpak manifest (see #72).
@julianrichen
Copy link
Contributor Author

julianrichen commented Jan 25, 2018

It's building fine for me but I can't run it, probably because of some permissions with the color.ini

** (gcolor3:2): WARNING **: Error opening file: No such file or directory. Colors likely won't be saved
Failed to register: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: org.freedesktop.DBus.Error.ServiceUnknown

@Hjdskes Try deleting your .flatpak-builder directory, which is located in the directory you built the flatpak. I know OSTree has some issue with app-id renaming which is why flathub deson't want to change them after they are committed. That might be the reason.

@julianrichen
Copy link
Contributor Author

Oh... I set config.ini to :ro (read-only), probably should be :rw (read-write).

Allow read-write access to xdg-config/gcolor3/config.ini, instead of read-only.
@Hjdskes
Copy link
Owner

Hjdskes commented Jan 25, 2018

It built fine for me as well, but I got another error, even after rebuilding with the rw permissions:

** (gcolor3:3): WARNING **: Error writing file: Failed to rename file ?/home/jente/.var/app/org.hjdskes.gcolor3/config/gcolor3/config.ini.93SADZ? to ?/home/jente/.var/app/org.hjdskes.gcolor3/config/gcolor3/config.ini?: g_rename() failed: Device or resource busy

I'm not sure what's going on here. EDIT: This does not seem to happen on your branch, without the renaming.

@julianrichen
Copy link
Contributor Author

Weird, I still get

** (gcolor3:2): WARNING **: Error opening file: No such file or directory. Colors likely won't be saved
Failed to register: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: org.freedesktop.DBus.Error.ServiceUnknown

Which is only a warning and should not stop the application from running...

Question, when you build locally are you changing the manifest to build the local files instead of pulling the v2.2 archive? Example:

     ...
    "modules": [
        {
            "name": "gcolor3",
            "sources": [
                {
                    "type": "git",
		    "url": "file:///home/jente/Projects/gcolor3"
                }
            ]
        }
    ]
}

@julianrichen
Copy link
Contributor Author

I built the packages outside of flatpak using the rename branch and it builds fine and runs but I also get the following:

** (gcolor3:15690): WARNING **: Error reading keys: Key file does not have group “Colors”

After I built without flatpak and re-ran the flatpak run ... I'm now getting the same message as you:

Failed to register: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: org.freedesktop.DBus.Error.ServiceUnknown

** (gcolor3:2): WARNING **: Error writing file: Failed to rename file “/home/julian/.var/app/org.hjdskes.gcolor3/config/gcolor3/config.ini.BOMEDZ” to “/home/julian/.var/app/org.hjdskes.gcolor3/config/gcolor3/config.ini”: g_rename() failed: Device or resource busy

Which is strange, idk if it's a delay thing & a coincident because only stuff inside the flatpak should effect the flatpak.

Still looking into it.

@julianrichen
Copy link
Contributor Author

So changing

"--filesystem=xdg-config/gcolor3/config.ini"

to

"--filesystem=home"

Fixed the warning, I then tried

"--filesystem=xdg-config/gcolor3/"

and it removed the warning, I think because you have a function that checks that the .config/gcolor3 directory exists. ensure_user_dir()

I still can't get the application to launch, the dbus warning makes it seem like their is an application mismatch in GApplication...

Hjdskes added a commit that referenced this pull request Feb 25, 2018
To follow GNOME standards and to prevent necessary renaming in the
Flatpak manifest (see #72).
Hjdskes added a commit that referenced this pull request Feb 25, 2018
To follow GNOME standards and to prevent necessary renaming in the
Flatpak manifest (see #72).
@Hjdskes
Copy link
Owner

Hjdskes commented Feb 25, 2018

I got everything to work by using --filesystem=xdg-config/gcolor3:rw and actually building from the rename branch. I'll go ahead and merge that now, thank you for taking the initiative and helping solve the issues we ran into!

@Hjdskes Hjdskes closed this Feb 25, 2018
@bilelmoussaoui
Copy link
Contributor

@Hjdskes Can you push the flatpak file to flathub too? Thanks

@Hjdskes
Copy link
Owner

Hjdskes commented Feb 25, 2018

I will do that once I release a new version that I can point the manifest to. According to @julianrichen, Flathub does not accept Flatpaks that build from master, understandably so.

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

Successfully merging this pull request may close these issues.

3 participants