Packaging Etcher as a snap

I am trying to pack Etcher as a snap using electron’s prepared files as a starting point (not sure how to use core20 with the electron-builder). I got the following error with confinement: strict (it works with classic on Ubuntu18.04 and 20.04):

/snap/balena-etcher-electron/x1/desktop-common.sh: line 339: /usr/lib/x86_64-linux-gnu/glib-2.0/gio-querymodules: Permission denied

Then I used the personal-files interface to create read/write plugs to $HOME/snap/balena-etcher-electron/common/.cache, added LD_LIBRARY_PATH: $SNAP/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH to the environment because it didn’t know where libnode.so is and ended up with this error message:

(balena-etcher-electron.bin:56244): GLib-GIO-CRITICAL **: 16:47:59.125: g_settings_schema_source_lookup: assertion ‘source != NULL’ failed
[56244:0516/164759.127014:FATAL:memory.cc(22)] Out of memory. size=131072
/snap/balena-etcher-electron/x7/app/balena-etcher-electron: line 10: 56244 Trace/breakpoint trap (core dumped) “${script_dir}”/balena-etcher-electron.bin “$@”

I am not sure how to proceed from here.

1 Like

Adding - browser-support to the list of plugs solved the issue above.

Now I am getting another error and the reason for it is that apparmor is not happy.

[ 2821.338495] audit: type=1400 audit(1589708221.309:3664): apparmor=“DENIED” operation=“exec” profile=“snap.balena-etcher-electron.balena-etcher-electron” name="/usr/bin/lsblk" pid=13514 comm=“balena-etcher-e” requested_mask=“x” denied_mask=“x” fsuid=1000 ouid=0

I tried adding hardware-observe to the list of plugs but it did not help.

did you connect the interface too ?

Oops… Thanks, connecting it to the interface helped. Now it wants to use pkexec or kdesudo when you click on ‘Flash!’. Can this work with confinement: strict?

rpi-imager migth be doing something similar …

1 Like

It looks like rpi-imager uses the udisks2 plug for writing. Etcher does not support that. At least based on the comments in this flatpak thread (they reach to the same stage Error: Unable to find pkexec or kdesudo.):

his application is (close to) impossible to run as Flatpak, right?

I guess so, unless the app supports some privileged helper running outside the sandbox, e.g. UDisks2. https://github.com/flathub/flathub/pull/1363#issuecomment-584319244

AFAIK Etcher doesn’t use dd or any other well-known utility to write images, so patching the app to do so wouldn’t be as easy as it may seem. https://github.com/flathub/flathub/pull/1363#issuecomment-584688627

It sounds like the best solution would be for upstream to use Udisks2, which wouldn’t just help Flatpak :slight_smile: https://github.com/flathub/flathub/pull/1363#issuecomment-585204907

It runs almost fine with confinement: classic. It also uses Firefox to open links for some reason (Chrome is my default browser and it uses Chrome in strict). And when you start the program for the first time it gives the following error:

Cannot load module /usr/lib/x86_64-linux-gnu/gtk-3.0/3.0.0/immodules/im-ibus.so: /usr/lib/x86_64-linux-gnu/gtk-3.0/3.0.0/immodules/im-ibus.so: undefined symbol: ibus_input_context_set_client_commit_preedit
/usr/lib/x86_64-linux-gnu/gtk-3.0/3.0.0/immodules/im-ibus.so does not export GTK+ IM module API: /usr/lib/x86_64-linux-gnu/gtk-3.0/3.0.0/immodules/im-ibus.so: undefined symbol: ibus_input_context_set_client_commit_preedit
ERROR: /snap/balena-etcher-electron/x2/usr/lib/x86_64-linux-gnu/libgtk-3-0/gtk-query-immodules-3.0 exited abnormally with status 1

The program still works and this is not shown on future launches. Based on this thread Cannot load module /usr/lib/x86_64-linux-gnu/gtk-3.0/3.0.0/immodules/im-ibus.so I see that I need to correct LD_LIBRARY_PATH but I am not sure what the correct path should be, is it something like:

LD_LIBRARY_PATH: '$SNAP/lib/x86_64-linux-gnu:$SNAP/opt/balenaEtcher:$SNAP/usr/lib/x86_64-linux-gnu:$SNAP/lib:$SNAP/usr/lib:$LD_LIBRARY_PATH