I've got a snap that I'd like to build for multiple architectures. Right now, in the
snapcraft.yaml file I define a wrapper as the binary to execute, which sets up environment variables required for the app to run.
One piece of script code that it contains is the following:
#!/bin/sh ARCH='x86_64-linux-gnu' export LD_LIBRARY_PATH=$SNAP/usr/lib/$ARCH:$LD_LIBRARY_PATH
ARCH is not optimal, as non-amd64 builds will not work correctly. However, arch detection using
dpkg-architecture will not work when using Snapcraft.
How can I dynamically detect the host's architecture in my wrapper to set the correct library paths while building the snap with Snapcraft?
Code is available as part of the snappy desktop examples.