Build process can not find icon

The build process can not find my app icon.

Icon 'art.taunoerik.tauno-monitor' specified in desktop file 'usr/share/applications/art.taunoerik.tauno-monitor.desktop' not found in prime directory.
Build failed

I read this, but it doesn’t work either:

 WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
:: + sed -i.bak -e 's|Icon=art.taunoerik.tauno-monitore|Icon=/usr/share/icons/hicolor/scalable/apps/art.taunoerik.tauno-monitor.svg|g' data/art.taunoerik.tauno-monitor.desktop.in
:: sed: can't read data/art.taunoerik.tauno-monitor.desktop.in: No such file or directory
'override-build' in part 'tauno-monitor' failed with code 2.

I don’t understand what I’m doing wrong anymore. The code is here

Hi @taunoe,

Thanks for posting the source. I believe I found two problems:

  1. In the override-build script, the desktop.in file should be modified before craftctl default (which calls meson to process that file).
  2. There is a typo in the sed call (an extra e on the end of monitor).
  3. Since the sed call is in override-build, I used $CRAFT_PART_SRC to point to the desktop.in file. If this call was in override-pull, I don’t think this wouldn’t have been needed.
diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml
index 103ccea..60218f7 100644
--- a/snap/snapcraft.yaml
+++ b/snap/snapcraft.yaml
@@ -30,17 +30,15 @@ apps:
 parts:
   tauno-monitor:
     plugin: meson
-    source-type: git
-    source: https://github.com/taunoe/tauno-monitor
+    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
       pip3 install --target=$SNAPCRAFT_PART_INSTALL/ pyserial
-
-      # Point icon to the correct location
-      #sed -i.bak -e 's|Icon=art.taunoerik.tauno-monitore|Icon=/usr/share/icons/hicolor/scalable/apps/art.taunoerik.tauno-monitor.svg|g' data/art.taunoerik.tauno-monitor.desktop.in

Also, since your snapcraft.yaml lives in the same repository as the source code, why not use source: .? (You can see I had to make that change to test my fix)

1 Like

Thank You, it fixed this error!

It needs $CRAFT_PART_SRC Can’t find a desktop file without it.

But now I got a new error:

Cannot pack snap file: Command '['snap', 'pack', '--check-skeleton', PosixPath('/build/tauno-monitor/prime')]' returned non-zero exit status 1. (container.go:177: in snap "tauno-monitor": "usr/bin/tauno-monitor" should be world-readable and executable, and isn't: -r-xr--r--
error: snap is unusable due to bad permissions)

Just add a line below the pip3 install call:

chmod +x $CRAFT_PART_INSTALL/usr/bin/tauno-monitor

That should suffice… (if not, we might need to add a separate override-prime block, but i think the above should be enough)

1 Like

Thank You, it now builds!