Stage-Packages with --target-arch

Hi,

I encountered a similar problem, and the way I solved it is by using the deb syntax for specifying the packages, i.e. rsync:armhf, but becuase the colon has special meaning inside YAML, you have to enclose the entire package name inside quotes. Also note that in recent versions of snapcraft you need to use the snapcraft advanced grammar to work with cross-compiling using on and to. For example to install the armhf package version when cross-compiling to armhf, you would do:

    stage-packages:
      - on amd64 to armhf:
          - "rsync:armhf"
      - else:
        - "rsync"

which admittedly looks rather awkward but does work. Also note that I needed to cxhange /etc/apt/sources.list similarly to you on my amd64 xenial system, but for every line that was in there previously I had to add the arch for example

deb http://archive.ubuntu.com/ubuntu/ xenial main restricted

to

deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ xenial main restricted

and add the following additional lines for armhf:

deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports xenial main universe
deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports xenial-security main universe
deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports xenial-updates main universe
deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports xenial-backports main universe

This was necessary because snapcraft will run apt update (or some equivalent), and if any of the cache hits fail, as they did for me without the [arch=amd64] changes, snapcraft will fail. I did not need to add any of the deb-src lines like you have in your sources.list file.

Hope this helps!

(also note that I added arm64 to the deb sources so that the above can just be pasted in and you get arm64 support too if needed)

4 Likes