Snap builds without errors. When I run it I get this message and no GUI:
$ /snap/bin/tauno-monitor
/snap/tauno-monitor/18/gnome-platform/command-chain/desktop-launch: /snap/tauno-monitor/18/usr/bin/tauno-monitor: /snap/gnome-42-2204-sdk/current/usr/bin/python3: bad interpreter: No such file or directory
/snap/tauno-monitor/18/gnome-platform/command-chain/desktop-launch: line 616: /snap/tauno-monitor/18/usr/bin/tauno-monitor: Success
As I understand there is still missing some gnome-42-2204-sdk components. So I added this
sed -i -e 's|/snap/gnome-42-2204-sdk/current/usr/bin/python3|/usr/bin/env python3|g' $CRAFT_PART_INSTALL/usr/bin/tauno-monitor
resulting different error:
$ /snap/bin/tauno-monitor
Traceback (most recent call last):
File "/snap/tauno-monitor/15/usr/bin/tauno-monitor", line 42, in <module>
resource = Gio.Resource.load(os.path.join(pkgdatadir, 'tauno-monitor.gresource'))
gi.repository.GLib.GError: g-file-error-quark: Failed to open file “/usr/share/tauno-monitor/tauno-monitor.gresource”: open() failed: No such file or directory (4)
Not sure how I add all the missing components. My current snapcraft.yaml file and full code
name: tauno-monitor
base: core22
version: '0.1.2'
summary: Simple stand-alone serial port monitor
description: |
Simple a stand-alone serial port monitor for the GNOME desktop.
It aims to be beginner-friendly, small and easy to use.
Not feature-rich and professional.
grade: stable
confinement: strict
architectures:
- build-on: amd64
- build-on: arm64
- build-on: armhf
#slots:
# for GtkApplication registration
#drawing:
#interface: dbus
#bus: session
#name: art.taunoerik.tauno-monitor
apps:
tauno-monitor:
extensions: [ gnome ]
command: usr/bin/tauno-monitor
desktop: usr/share/applications/art.taunoerik.tauno-monitor.desktop
common-id: art.taunoerik.tauno-monitor
plugs:
- home
- raw-usb
- serial-port
#- hardware-observe
parts:
tauno-monitor:
plugin: meson
source: .
parse-info: [ usr/share/appdata/art.taunoerik.tauno-monitor.appdata.xml ]
meson-parameters:
- --prefix=/usr
- --buildtype=release
override-build: |
# Point icon to the correct location
sed -i.bak -e 's|Icon=art.taunoerik.tauno-monitor|Icon=/usr/share/icons/hicolor/scalable/apps/art.taunoerik.tauno-monitor.svg|g' $CRAFT_PART_SRC/data/art.taunoerik.tauno-monitor.desktop.in
craftctl default
#sed -i -e 's|/snap/gnome-42-2204-sdk/current/usr/bin/python3|/usr/bin/env python3|g' $CRAFT_PART_INSTALL/usr/bin/tauno-monitor
pip3 install --target=$SNAPCRAFT_PART_INSTALL/ pyserial
chmod +x $CRAFT_PART_INSTALL/usr/bin/tauno-monitor
here is a proper snapcraft.yaml that should build and run (never ever set the prefix in a binary to /snap/foo/bar, names can change etc, this is bound to fail and fall apart eventually):
name: tauno-monitor
base: core22
version: '0.1.2'
summary: Simple stand-alone serial port monitor
description: |
Simple a stand-alone serial port monitor for the GNOME desktop.
It aims to be beginner-friendly, small and easy to use.
Not feature-rich and professional.
grade: stable
confinement: strict
architectures:
- build-on: amd64
- build-on: arm64
- build-on: armhf
slots:
# for GtkApplication registration
drawing:
interface: dbus
bus: session
name: art.taunoerik.tauno-monitor
apps:
tauno-monitor:
extensions: [ gnome ]
command: usr/bin/tauno-monitor
desktop: usr/share/applications/art.taunoerik.tauno-monitor.desktop
common-id: art.taunoerik.tauno-monitor
environment:
PYTHONPATH: $SNAP/usr/lib/python3.10/dist-packages:$SNAP/lib/python3.10/site-packages:$SNAP/usr/lib/python3/dist-packages
plugs:
- home
- raw-usb
- serial-port
#- hardware-observe
layout:
/usr/share/tauno-monitor:
bind: $SNAP/usr/share/tauno-monitor
parts:
tauno-monitor:
plugin: meson
source: .
parse-info: [ usr/share/metainfo/art.taunoerik.tauno-monitor.metainfo.xml ]
meson-parameters:
- --prefix=/usr
- --buildtype=release
override-build: |
# Point icon to the correct location
sed -i.bak -e 's|Icon=art.taunoerik.tauno-monitor|Icon=/usr/share/icons/hicolor/scalable/apps/art.taunoerik.tauno-monitor.svg|g' $CRAFT_PART_SRC/data/art.taunoerik.tauno-monitor.desktop.in
craftctl default
sed -i -e 's|/snap/gnome-42-2204-sdk/current/usr/bin/python3|/usr/bin/env python3|g' $CRAFT_PART_INSTALL/usr/bin/tauno-monitor
chmod +x $CRAFT_PART_INSTALL/usr/bin/tauno-monitor
pyserial:
plugin: python
source: .
after: [tauno-monitor]
python-packages:
- pyserial
EDIT: Note that due to the dbus slot your first store upload will go into manual review, the reviewers will usually just allow the dbus slots for gtk apps once it shows up in their queue … if it isnt granted fast enough, you can create a post in the store-requests category here in the forum…
EDIT2: you should really consider to change tauno-monitor.in from #!@PYTHON@ to simply use #! /usr/bin/env python3, it should work on all distros at runtime and saves you from that awful sed hack in snapcraft.yaml (and there must be a way to make your meson build create /usr/bin/tauno-monitor with the proper executable bits too so you wouldnt need the chmod hack either)
I agree that changing prefixes may hurt, if they hard-code it for other things too. But this is clearly a gtk app and he is using this prefix just for his datadir’s location. I have all my snaps working in this way for a lot of versions till now, and they all works smoothly.
BTW, the metadatas should be adopted by his appstream metadata file. Those things can be removed.
They don’t increase startup times in any noticeable way for the user unless you use a ton of them, a single bind layout should be in the fraction of nanoseconds …