Create snap for feedreader #268

Closed
lightonflux opened this Issue Nov 20, 2016 · 32 comments

Comments

Projects
None yet
5 participants

lightonflux commented Nov 20, 2016

Here my first try getting a more complex application snapped. At the moment it compiles without complains but exits with an error.

Here the current snapcraft file which compiles well under Ubuntu 16.10.


name: feedreader-snap
version: '0.1'
summary: FeedReader is a desktop application to complement  RSS accounts.
description: |
  Mindblowing good description of feedreader the awesome feedreader app.

grade: devel # must be 'stable' to release into candidate/stable channels
confinement: devmode # use 'strict' once you have the right plugs and slots

apps:
  feedreader-snap:
    command: bin/feedreader
    plugs: [home, unity7, x11, gsettings, network]
  env: # for testing
    command: env

parts:
  feedreader:
    plugin: cmake
    configflags: ["-DUSE_WEBKIT_4=ON -DWITH_LIBUNITY=OFF"]
    source: https://github.com/jangernert/FeedReader.git
    build-packages:
      - build-essential
      - cmake
      - valac
      - pkg-config
      - libgirepository1.0-dev
      - libgtk-3-dev
      - libsoup2.4-dev
      - libjson-glib-dev
      - libwebkit2gtk-4.0-dev
      - libsqlite3-dev
      - libsecret-1-dev
      - libnotify-dev
      - libxml2-dev
      - librest-dev
      - libgee-0.8-dev
      - libcurl4-gnutls-dev
      - libgstreamer-plugins-base1.0-dev
      - libpeas-dev
      - libgoa-1.0-dev

The error when running:


$ feedreader-snap
(feedreader:2195): Gtk-WARNING **: Locale not supported by C library.
        Using the fallback 'C' locale.

(feedreader:2195): GLib-GIO-ERROR **: No GSettings schemas are installed on the system
Trace/breakpoint trap (core dumped)

Will investigate further later. But if you have an idea what the problem is please tell. Do we need to package the gsetting schemas? If so how do i generate the schemas?

Owner

jangernert commented Nov 21, 2016

Why are you still using "-DUSE_WEBKIT_4=ON -DWITH_LIBUNITY=OFF" ? This hasen't been necessary for a long time.

I have no idea how snap works. But FeedReader needs access to the gsettings. Don't know how that works in a container. Or are snaps even properly sandboxed?

lightonflux commented Nov 21, 2016

Just compied from my build function i setup a long time ago. I knew it worked so i tested with it just to be sure.

But FeedReader needs access to the gsettings

That why the plug gsettings is included. Plugs are like flatpaks portals. So the confined environment can access resources on the host.

Explanation

Or are snaps even properly sandboxed?

Yes, but only when enabled (required for publishing), when developing you can disable it with confinement: devmode so you know if you run in packaging or confinement issue.

Owner

jangernert commented Nov 21, 2016

Sorry, no idea what is wrong with the snap-package.
But No GSettings schemas are installed on the system leads me to believe that FeedReader can't "see" the gsettings on the system. How does compiling the gsettings work with a snap? Are the settings compiled inside the sandboxed snap and somehow made available to the executable like it was on the system? If so, how does a snap figure out if one of it's own gsettings-keys should be accessed or a system wide key?
Or are the settings still installed system-wide and only the executables are run inside the sandbox?

Owner

jangernert commented Nov 21, 2016

Googling brings up this:
http://askubuntu.com/questions/818708/how-to-execute-gsettings-within-a-snap-package-confinement

after: [desktop/gtk3]

I guess this somehow makes the technologies of a functional gtk3-desktop a dependency (like the flatpak gnome-runtime)

origin: https://github.com/ubuntu/snapcraft-desktop-helpers.git
maintainer: Snapcraft community snapcraft@lists.snapcraft.io
description: |
Helpers for gtk2, gtk3, qt4 and qt5 or glib minimal launchers.
It brings the necessary code and exports for binding and using those
desktop technologies in a relocatable fashion, enabling binding with
global desktop theme, icon theme, image caching, fonts, mimetype handlers
application global menu and gsettings integration.
It also brings basics ubuntu dependency packages.
Usage :
1. add "after: [desktop/]" to your launcher:
- gtk2, gtk3, qt4 and qt5 corresponds to their respective toolkit
main dependencies and default choices.
- glib-only enables to compile mime types and gsettings infos. If you
added your own graphical drivers, it will link them as well.
2. prepend your command with "desktop-launch", like:
commands: "desktop-launch foo" if foo is in $PATH. You can as well
specify: "desktop-launch $SNAP/foo".
3. add needed plugs to your application:
- for graphical application:
plugs: [x11 (or unity7 for appmenu integration)]. Think about adding
opengl if you need hw acceleration.
- if your application needs access to sound:
plugs: [pulseaudio]
- accessing to user's home directory:
plugs: [home]
- read/write to gsettings:
plugs: [gsettings, home]
(note that the home plug is needed to read new value)
parts: [desktop/gtk2, desktop/gtk3, desktop/qt4, desktop/qt5, desktop/glib-only]

https://wiki.ubuntu.com/snapcraft/parts

This hasen't been necessary for a long time.

Does the make script autodetect or how does it work if you want to compile on a system without the libunity dependency?

Owner

jangernert commented Nov 21, 2016

Yes, cmake detects libunity and the webkit-version now.

I fixed a few smaller issues with the yml file for the snap. But i still have a hard time to understand how to install the gsettings schemas (in general).

Basically we need to do the same as in cmake install.

I looked for examples but so far only found plank with a custome launcher that makes sure to install the schemas deliver within the snap are installed in the users …/glib-2.0/schemas folder ($SNAP = the root of the feedreader-snap hierarchy).

The about dialogue and cli options work. It lacks some other things, like images and a desktop starter.

The current snapcraft file:

snapcraft.txt (it is a yml file but gh does not support yml).

Owner

jangernert commented Nov 22, 2016

The about-dialogue and the cli options do not access the gsettings.

I know. Just wanted to mention that the snap works so far. Only 3 things to fix.

lightonflux commented Dec 7, 2016

Found out why it did not work. The schemas land in the wrong folder. $SNAP/share/glib-2.0/schema instead of $SNAP/usr/share. So i added the install prefix again. Works now.

Still some things are lacking.

  • Some assets like tt-rss logo
    • Do feedreader load the icon from the server?
  • GDBus.Error:org.freedesktop.DBus.Error.UnknownMethod: No such method 'supportFeedManipulation'
    • Does this mean feedreader can't connect to feedreader-daemon?
Owner

jangernert commented Dec 7, 2016

Nice work!
All the bundled icons are a gresource. (Only the feed-favicons are loaded from the server)
Yes, seems like the dbus-stuff needs some special treatment as well running sandboxed =\

Thanks. At the moment the snapped feedreader starts the the daemon from /usr/local/bin which can't be in the snap because local does not exist there. The reason being that snap is the last item in my path. So without looking into the feereader code i guess the daemon is called by command name not path.

I will get there and the daemon will be started from within the snap.

I opened a small repo here. (The newest version is not yet online. But it works just as good as my local copy).

Owner

jangernert commented Dec 7, 2016

The daemon was started via command in older versions. But calling a dbus-function starts up the server automatically, so I rely on that now.

Can you tell me more about the dbus-function? The problem persists with current master.

Current situation:
bildschirmfoto von 2016-12-08 00-44-39

And I updated the repo.

Owner

jangernert commented Dec 7, 2016

There is a file called "feedreader.service" that tells the system about the "org.gnome.feedreader"-dbus-server and what binary supplies the service. So once the UI calls a dbus-function of org.gnome.feedreader the system checks if the server is already running and if not it starts up the feedreader-daemon binary.

I see. On my system i have two files:

/usr/share/dbus-1/services/feedreader.service
/usr/local/share/dbus-1/services/feedreader.service

One with local in the path one without. So feedreader-snap calls dbus, and dbus starts the daemon from local. I have no idea how to fix that. Would be nice if you can use feedreader from a snap and local copy at the same time.

@bil-elmoussaoui bil-elmoussaoui added bug enhancement and removed bug labels Dec 12, 2016

There's work on new dbus-related interfaces (plugs) for snap packages that will allow this, but it probably won't be ready until after the first of the year. For now you can use "confinement: devmode" or install with the --devmode flag and it should let it run, you can even publish it to the edge and beta channels of the Snap store that way, you'll just need to wait for the new interfaces before you can publish to the stable channel.

Owner

jangernert commented Dec 29, 2016

So I just built the snap inside a 16.10 VM. Building went fine. But installing reported following error:

Mount snap "feedreader-snap" (unset) (snap "feedreader-snap" requires devmode or confinement override)

even though the yaml states "confinement: devmode".
Worked around it by adding "--devmode" to the install command.
Running the snap only starts the UI but the daemon and the dbus-server are not launched. So the programm is not functioning correctly.
So far flatpak seems like the more mature sandboxed package =/

Owner

jangernert commented Dec 29, 2016

snap install f.snap --dangerous --devmode

I just don't understand why the second parameter has to be added since the yaml-file already specifies 'devmode'.
Is that a bug or intended behavior?

edit:
Since launchpad.net is causing troubles with the build-system recently (launchpad messes up some paths) I would like to discontinue the Ubuntu-ppa for everything >= Ubuntu 16.10 and FeedReader > 1.6.2. Do you think there is a chance to get the snap working and published to the store (edge or beta channels of the Snap store) for a first beta of 2.0 some time soon?

snap defaults to only installing things with "confinement: strict". Using "confinement: devmode" is just a signal that this app will not ever work under strict confinement, but it won't transparently override snap's default behavior.

Snapd 2.20 is out now for Ubuntu 16.04 and newer, so the dbus interface should be available now. If you need help you can find a lot of us in the #snapcraft channel on rocket.ubuntu.com

Owner

jangernert commented Jan 18, 2017

@lightonflux did you manage to test the snap on an updated ubuntu with the new snapd yet?

Just tried. Newest issue is:

(feedreader:26336): GStreamer-WARNING **: External plugin loader failed. This most likely means that the plugin loader helper binary was not found or could not be run. You might need to set the GST_PLUGIN_SCANNER environment variable if your setup is unusual. This should normally not be required though.

That's new. In my local install there is no new binary after compiling from newest git. So i assume i have to add some variables to the wrapper?! Or is it a binary by gstreamer?

@jangernert Thanks for any pointers.

This is "gst-plugin-scanner" right? Not sure if we want to include this in the snap. It is already 3 times as big as local installs.

Owner

jangernert commented Jan 19, 2017

Does all the basic functionality (other than playing podcasts) work at this point?
Regarding gstreamer: maybe there is a way to let it scan the system for plugins? Or something like a run-time like flatpaks has. Would be weird if every snap had to ship all the plugins every time.

Owner

jangernert commented Jan 24, 2017

Does all the basic functionality (other than playing podcasts) work at this point?

You will need to include whatever gstreamer plugins you need in your snap, that way you know it always has them available. To tell gstreamer where to find them in your snap, you'll need to set some environment variables like those in https://github.com/ubuntu/snapcraft-desktop-helpers/blob/master/common/desktop-exports#L43

At this point you might want to just use the desktop-gtk3 remote part, which pulls in the gtk stage-packages and provides a desktop-launch script that sets all the needed environment variables, gsettings schemas, etc for you.

Collaborator

jscurtu commented Feb 19, 2017

Sad to see less progress on this. @lightonflux is this something you are still working on? Last commit was 2 months https://github.com/lightonflux/feedreader-snap
If anyone noticed, there are no install instructions for Ubuntu anymore and the traditional way of building FeedReader (starting with 2.0.1) is not supported on Ubuntu due to outdated Gtk, if anyone wants to give Ubuntu some love then it would be great to have a snap in place.

lightonflux commented Feb 26, 2017

@jscurtu It is still on my list. But i hadn't any chance to work on it in the last weeks. And i don't have build/test machines at the moment. I only run Debian which makes snap development with snapcraft a bit cumbersome (as it's only released for Ubuntu so far).

I am super open to pull requests. And at the moment there is no offline progress your PRs could conflict with.

Edit: And i haven't looked into 2.0.1 compiling on Ubuntu so far.

After the recent news around Ubuntu adapting the vanilla Gnome stack and some unrelated personal things i decided to cross off the snap from my todo list.

My initial intention when starting to snap feedreader was that installing a snap would be a better user experience for Ubuntu users. Flatpak being only focused on desktop apps and it being part of the Gnome UX for third party application, i think it is not worth to have feedreader in two new package formats.

I also stopped working on snaps that involve smaller GUI programs.

@jscurtu jscurtu self-assigned this Jun 2, 2017

@jscurtu jscurtu added this to the 2.2 milestone Jun 2, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment