Snapping GTK3 app

I have a dotnet core app that uses GTK3 which I am trying to snap.

I gave up on the dotnet plugin, because it’s broken. see snapcraft 1812500 (sorry new users are only allowed 2 links :disappointed: )

Instead I am pre-building as a selfcontained app and then using the dump plugin.

I tried following Desktop App Support - GTK but there was not enough detail Then I saw the comment linking to https://hackmd.io/0I09MG1FRKqO0ehIdLHpoQ#

But when I try that I get:

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

You can do this with those commands: snap install gnome-3-28-1804 snap connect poc-sharp:gnome-3-28-1804 gnome-3-28-1804

Sorry what? my users have to run a second command after install my snap to get it to work? What did I do wrong?

here is my snapcraft.yaml

name: poc-sharp # you probably want to 'snapcraft register <name>'
base: core18 # the base snap is the execution environment for this snap
version: '0.1' # just for humans, typically '1.2+git' or '1.3.2'
summary: GUI for Tait PoC User Agent # 79 char long summary
description: |
  Poc Sharp is a graphical interface and libarary for controlling a Tait
  PoC User Agent. It does not include the PoC User Agent that must be 
  obtained seperately.

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

slots:
  # for GtkApplication registration
  sharp:
    interface: dbus
    bus: session
    name: org.gnome.poc-sharp

apps:
  poc-sharp:
    command: bin/desktop-launch $SNAP/PocSharpGui
    plugs:
      - desktop
      - desktop-legacy
      - wayland
      - x11
      - unity7
      - gsettings

parts:
  poc-sharp:
    # See 'snapcraft plugins'
    after: [desktop-gnome-platform]
    source: PocSharpGui/Install
    source-type: local
    plugin: dump
    stage-packages:
      - libasn1-8-heimdal
      - libcurl4
      - libgssapi3-heimdal
      - libhcrypto4-heimdal
      - libheimbase1-heimdal
      - libheimntlm0-heimdal
      - libhx509-5-heimdal
      - libkrb5-26-heimdal
      - libldap-2.4-2
      - libnghttp2-14
      - libpsl5
      - libroken18-heimdal
      - librtmp1
      - libsasl2-2
      - libwind0-heimdal
      - libgtk3.0-cil

  desktop-gnome-platform:
    source: https://github.com/ubuntu/snapcraft-desktop-helpers.git
    source-depth: 1
    source-subdir: gtk

    plugin: make
    build-packages:
    - build-essential
    - libgtk-3-dev
    override-build: |
      snapcraftctl build
      mkdir -pv $SNAPCRAFT_PART_INSTALL/gnome-platform

plugs:
  gnome-3-28-1804:
    interface: content
    target: $SNAP/gnome-platform
    default-provider: gnome-3-28-1804
  gtk-3-themes:
    interface: content
    target: $SNAP/data-dir/themes
    default-provider: gtk-common-themes
  icon-themes:
    interface: content
    target: $SNAP/data-dir/icons
    default-provider: gtk-common-themes
  sound-themes:
    interface: content
    target: $SNAP/data-dir/sounds
    default-provider: gtk-common-themes

I managed to get it working (ish) by removing the

$SNAP/ 

from the

target: $SNAP/gnome-platform 

line.

The problem I have now is that running the snap requires sudo.

/snap/poc-sharp/x19/bin/desktop-launch: line 573: /snap/poc-sharp/x19/PocSharpGui: Permission denied
/snap/poc-sharp/x19/bin/desktop-launch: line 573: exec: /snap/poc-sharp/x19/PocSharpGui: cannot execute: Permission denied

I thought maybe I was doing sometime in my code that required root, so I commented it all out and just printed hello world, but this still required root. The same app run outside of snap does not require root.

Google says there is a known issue with non standard home directory locations, but mine is default from a vanilla Ubuntu 18.04 install

Looking at the dotnet plugin there is the following code:

# Workaround to set the right permission for the executable.
    appname = os.path.join(self.installdir, self._get_appname())
    if os.path.exists(appname):
        os.chmod(appname, 0o755)

Seems that dotnet publish does not produce the correct permissions. How can I run change the permissions from the .yml file?

This is possibly because your plug definitions do not specify the slot to plug into. Try adjusting your plugs to:

plugs:
  gnome-3-28-1804:
    default-provider: gnome-3-28-1804:gnome-3-28-1804
    interface: content
    target: $SNAP/gnome-platform
  gtk-3-themes:
    default-provider: gtk-common-themes:gtk-3-themes
    interface: content
    target: $SNAP/data-dir/themes
  icon-themes:
    default-provider: gtk-common-themes:icon-themes
    interface: content
    target: $SNAP/data-dir/icons
  sound-themes:
    default-provider: gtk-common-themes:sounds-themes
    interface: content
    target: $SNAP/data-dir/sounds
1 Like

What are the permissions on the PocSharpGui file?

Permissions are:
-rwxrw-r-- 1 daniel daniel 106912 Aug 6 10:07 PocSharpGui

You need to add the executable permission bit to group and world.

Yeah that’s what I figured, can that be done with the .yml file?

You’re using the dump plugin so the easiest way to achieve it is to set it on the file in PocSharpGui/Install and then the snap will pick it up from there.

Yep can do, Thanks for the help. Hopefully the dotnet plugin gets fixed at some point and I can switch to that.