Help porting GWE (Nvidia info and overclock app) to Snap


#1

Hi, I am the developer of GWE, a GTK application that provides information, controls the fans and allows to overclock an NVIDIA video card (screenshot).

I recently finished supporting Flatpak, thanks to the help of several people from the IRC channel, and I was wondering if I could find here some people willing to do the same for Snap.

The app is written in Python 3.6 and requires GTK 3.24 (Gnome 3.30) because of libdazzle. Beside dazzle and appindicator3, the app has several Python dependencies all available on PyPI.

The tricky part with Flatpak was to dial with the sandbox: the app needs to load the system library libnvidia-ml.so.1 and run the binaries nvidia-settings and nvidia-smi. And finally it needs to access X11 to communicate with the extension NV-CONTROL.

The app is built with meson (if you check repo, look for the branch feature/mason, master is still using setup.py).

I started reading the doc for Snap but it would be really great if some one could give some help, especially at the beginning.


Support for GTK 3.24
#2

Firstly, that app looks amazing!

I know @kenvandine has built a lot of GTK applications, so may have some great examples he can throw your way.

There may well be interesting issues to overcome with confinement in snaps too, as you’ve seen in flatpak. What I’d recommend is using confinement: devmode initially, and testing out the snap (once built) to see what apparmor errors appear.

This is obviously one for later, once you get the snap built, but once you get to that point you can snap install snappy-debug which provides a great debugging utility. Then run snappy-debug.security scanlog in a terminal, then launch your snap in another terminal. It will output useful debug info detailing what the snap is trying to do, and what interfaces or other changes may be required. Once we get to that point, we can talk to the security experts about steps forward.


#3

Hi @popey, thanks a lot for your message. I would really appreciate some help to get at least started with Snap because so far my tries were not successful.
A good start would be to get some example of an already working snapcraft.yaml for similar applications (GTK/Python built with meson).
I went through all the apps listed here but it seems no one is supporting snap yet or, at least, I was not able to find any snapcraft.yaml for those apps.

This is how my current snapcraft.yaml looks, which is based on the one used by gnome-calculator.

I would really like to launch GWE in parallel on Flathub and Snap Store but currently I have almost done with Flathub (Flatpak seems to work fine, I just need make the PR to publish it) but basically not even started with Snap.

I tried to ask for help also on the IRC channel but I got no answer. Do you have any advice on where I could find willing to help to at least start a basic snap support?


#4

Ok. I understand. Unfortunately you picked a good (bad) week for this as much of the company is at a sprint so will be mostly heads down there. Typically I would say the irc channel #snapcraft might be good, but with everyone afk that might not be so useful. This forum is just as good (if not better as your conversation will be archived and useful to future visitors) for support.

I’d also like to help but am about to step on a plane too! I know @diddledan has also done some gnome stuff recently so may be able to help if @kenvandine isn’t around.


#5

I see, I’ll ask again on IRC when I get home. Btw is the username “diddledan” spelled correctly? I can’t find it and also in your message is not highlighted/linked like @kenvandine.

Fly safe :slight_smile:


#6

i think “diddledan” goes as @daniel in this forum :slight_smile: (diddledan is an IRC nick)


#7

Hi everyone, sorry if I have disappeared but I was not able to work on GWE for the last 2 weeks.

Anyway this weekend I have some time and I am trying again to create a Snap for the app.

Currently the snapcraft.yaml looks like this.

I am able to build and install the Snap, but when I try to run the app I get this error:

$ gwe
You need to connect this snap to the gnome platform snap.

You can do this with those commands:
snap install gnome-3-26-1604
snap connect gwe:gnome-3-26-1604 gnome-3-26-1604

(the '3-26-1604' number defines the platform version and might change)

I don’t get why is requiring gnome-3-26-1604. The app requires gnome 3.30 and inside the snapcraft.yaml I have added this:

plugs:
  gnome-3-30-1804:
    interface: content
    target: $SNAP/gnome-platform
    default-provider: gnome-3-30-1804

Do I need to specify somewhere else the gnome version that I need?


Support for GTK 3.24
#8

For any observers. We had a chat on IRC, and the current problem is building on core18, but needing gtk =>3.24 due to libdazzle requirement. Do we build the entire world of gtk like this or some other option? Going to discuss this week and see what we can come up with.


#9

From my brief dive into gwe it doesn’t look like it should require gtk >= 3.24. It looks to me like it should work with 3.22. I patched the meson.build file to reduce the dep.

--- a/data/meson.build
+++ b/data/meson.build
@@ -23,7 +23,7 @@ else
 endif
 dependency('glib-2.0')
 dependency('gobject-introspection-1.0', version: '>=1.35.9')
-dependency('gtk+-3.0', version :'>=3.24')
+dependency('gtk+-3.0', version :'>=3.22')

And I hacked on the snapcraft.yaml a bit and this builds and mostly runs, but does have a matplotlib issue.

Here’s my yaml file: http://paste.ubuntu.com/p/BXKWdBKjZk/

I hope that helps get you further.


#10

Hi @kenvandine, thanks for taking the time to look at this issue.
I am not sure if GTK 3.24 is strictly required to build GWE, but I am 100% sure is required to enable all the features: currently I am allowing users to run it on 3.22 by disabling the Historical data section when the right version of libdazzle is not available but for snap I would like to publish the app with 100% of the features on.

I also asked directly on the dazzle issue tracker if is possible to use it (from Python) on GTK < 3.4 and the answer is no.

I will try to see if I can use libdazzle from core18 with gnome-3-30-1804 and report back here, unless you have another suggestions.

I have also one question about the python dependencies: I saw on your yaml file that you are getting some of the python dependencies using the stage-packages (for example python3-xdg and python3-matplotlib) and I was wondering if it would be better to get all of them with pydeps so that I can get the exact version that I need and not being stuck with the version available on 18.04 (not sure if the matpolotlib issue is related to this).


#11

@kenvandine, I’m trying to build the snap using your yaml file but keeping gnome-3-30-1804 (to see if libdazzle works) but I am getting this error:

$ gwe
main.go:224: cannot change mount namespace of snap "gwe" according to change mount (/snap/gtk-common-themes/818/share/icons/Suru /snap/gwe/x1/data-dir/icons/Suru none bind,ro 0 0): cannot use "/snap/gtk-common-themes/818/share/icons/Suru" as bind-mount source: not a directory
You need to connect this snap to the gnome platform snap.

You can do this with those commands:
snap install gnome-3-26-1604
snap connect gwe:gnome-3-26-1604 gnome-3-26-1604

(the '3-26-1604' number defines the platform version and might change)

I don’t understand why is asking for gnome-3-26-1604, I would expect to ask at least for the 1804 since I’m using core18.

Do you have any advise?


#12

Hey @popey, maybe you have an idea of what should I do?


#13

This looks like a bug in the gtk-common-themes snap, the mount point must be a directory, it is probably a symbolic link instead.

The gnome-3-26-1604 is clearly 16.04 based, perhaps that’s some of the logic buried in the desktop helpers. I cannot help with that aspect.


#14

Hi @zyga, thanks for the reply. Should I bring this to the attention of someone? Maybe open an issue somewhere?


#15

The gtk-common-themes snap is built from code hosted and bugs tracked here and here.


#16

Thanks, I will open an issue as soon as I get home. Is there a way around this for now? Would removing the references to the gtk theme help with this issue? For now it would be enough to just have the stock GTK theme, I just want to move forward and be able to at least run the app.


#17

Ok, I have reported the bug here.

I’ve also removed the references to the gtk-common-themes from the snapcraft.yaml but I still get the error regarding gnome-3-26-1604 when I try to start the app:

$ gwe
You need to connect this snap to the gnome platform snap.

You can do this with those commands:
snap install gnome-3-26-1604
snap connect gwe:gnome-3-26-1604 gnome-3-26-1604

(the '3-26-1604' number defines the platform version and might change)

Should I report this other issue somewhere else? @popey @zyga @kenvandine any advice?


#18

I think this is great! Thank you.


#19

Hi @zyga, what about my issue with gnome-3-26-1604 that seems to be not related to the theme issue, do you have any advice for that?


#20

I think that it is a question to @kenvandine as well - perhaps there is a 18.04 based GTK content snap to use but I’m not up-to-date on those things.