Yeah, this is unfortunate and needs documenting.
Do this:- (note the sed line is removing reference to the core18
base which causes snapcraft to run in ‘legacy’ mode, which will mean the snapcraft define
line works (which won’t work if the base is there, causing snapcraft to work in 3.0 mode
)).
alan@KinkPad-K450:~$ mkdir ~/snapcraft_legacy
alan@KinkPad-K450:~$ cd ~/snapcraft_legacy/
alan@KinkPad-K450:~/snapcraft_legacy$ snapcraft init
Created snap/snapcraft.yaml.
Go to https://docs.snapcraft.io/the-snapcraft-format/8337 for more information about the snapcraft.yaml format.
alan@KinkPad-K450:~/snapcraft_legacy$ sed -i '/core18/d' snap/snapcraft.yaml
alan@KinkPad-K450:~/snapcraft_legacy$ snapcraft define desktop-gtk3
Maintainer: 'Snapcraft community (https//forum.snapcraft.io)'
Description: Helpers for gtk2, gtk3, qt4 and qt5 or gnome-platform and 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-<technology>]" to your launcher:
- gtk2, gtk3, qt4 and qt5 corresponds to their respective toolkit
main dependencies and default choices.
- gnome-platform is similar to gtk3 without the extra depends, it's
meant to be used with the gnome platform which already includes those.
- 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]
- use of the shared platform snap content, first define the plug:
plugs:
gnome-3-26-1604:
interface: content
target: gnome-platform
default-provider: gnome-3-26-1604:gnome-3-26-1604
and then make your apps use it:
plugs: [gnome-3-26-1604]
Note that an empty "gnome-platform" directory will be created for you
in your snap.
desktop-gtk3:
build-packages:
- build-essential
- libgtk-3-dev
make-parameters:
- FLAVOR=gtk3
plugin: make
source: https://github.com/ubuntu/snapcraft-desktop-helpers.git
source-subdir: gtk
stage-packages:
- libxkbcommon0
- ttf-ubuntu-font-family
- dmz-cursor-theme
- light-themes
- adwaita-icon-theme
- gnome-themes-standard
- shared-mime-info
- libgtk-3-0
- libgdk-pixbuf2.0-0
- libglib2.0-bin
- libgtk-3-bin
- unity-gtk3-module
- libappindicator3-1
- locales-all
- xdg-user-dirs
- ibus-gtk3
- libibus-1.0-5
- fcitx-frontend-gtk3
Take that bit at the end and paste it in as a part in your snap. Here’s that specific bit.
desktop-gtk3:
build-packages:
- build-essential
- libgtk-3-dev
make-parameters:
- FLAVOR=gtk3
plugin: make
source: https://github.com/ubuntu/snapcraft-desktop-helpers.git
source-subdir: gtk
stage-packages:
- libxkbcommon0
- ttf-ubuntu-font-family
- dmz-cursor-theme
- light-themes
- adwaita-icon-theme
- gnome-themes-standard
- shared-mime-info
- libgtk-3-0
- libgdk-pixbuf2.0-0
- libglib2.0-bin
- libgtk-3-bin
- unity-gtk3-module
- libappindicator3-1
- locales-all
- xdg-user-dirs
- ibus-gtk3
- libibus-1.0-5
- fcitx-frontend-gtk3