Make snap from pre(x-)built executable

Hello everyone!

I want to make a snap out of an executable.

The executable itself is for ARM architecture, so I am doing a x-build with cmake on my ubuntu 20.04 host system.

If I copy over the executable to my embedded target system, it starts and works.

My knowledge so far is, I could make a snap by giving the right cmake parameters etc. to the snapcraft.yaml file OR to somehow throw the already built executable in the snap. For the last one there is this documentation: https://snapcraft.io/docs/pre-built-apps which I try to stick to.

So I figured out all the *.so dependencies and simply put all of them together with the executable itself into a tar.gz file and gave the path to it into the source of the part:

parts:
  my-test-app1:
    plugin: dump
    source: ./alltogether.tar.gz

apps:
  my-test-executable:
    command: my-test

It is unable to pull the source if I simply execute “snapcraft” from the directory withing the snapcraft.yaml and the mentioned archive.

Can you help me spot the errors?

Anyone? Is there a way to merge pre built and locally accessible binaries together to one snap?

What does your project directory layout look like? I suspect you have snapcraft.yaml inside a folder called snap and the .tar.gz file somewhere else?

You want your project tree to look like this:

|
|- alltogether.tar.gz
`- snap
  `- snapraft.yaml

I believe with this layout your dump part should work as-is.

1 Like

@lucyllewy you were right, it was an issue like you described. Just had to place the archive in the right directory

Additionaly, I had problems with the cross compilation which were described and solved already here: Cross compile snap on amd64 to arm

In the end I had to add

architectures:
  - build-on:amd64
  - run-on:all

to the snapcraft.yaml and needed to execute
snapcraft --target-arch arm64 --destructive-mode
instead. That worked for me