I want to build an armhf package on an amd64 machine. My armhf machine is a lot slower than my amd64 one.
We first have to set up the multi-arch environment (more info):
sudo dpkg --add-architecture armhf sudo apt update
Download the source package (using less as an example):
apt-get source less
Navigate to the directory and, finally, build the package:
cd less-458 dpkg-buildpackage -us -uc -b --host-arch armhf
The special flag in the command above is
The other flags mean:
- We are not signing a source package
- We are not signing the .changes file
- We are doing a binary-only build
Those 3 are only relevant to those building public repositories, like Debian Developers/Maintainers.
If you care more about convenience than speed, you can use the following method, which uses qemu to emulate an ARM system.
Install package that got the tool we need, pbuilder-dist:
sudo apt install ubuntu-dev-tools
The following command creates a chroot to build on, and creates a tarball of it (in this case a Debian 8 system for armhf architecture):
pbuilder-dist jessie armhf create
Get sources of some package:
apt-get source bb
Build the package:
pbuilder-dist jessie armhf bb_1.3rc1-8.3.dsc
This took about 370 seconds on my machine, and about 250 seconds on the ARM system I was building on.
In Debian 9, with pbuilder:
pbuilder build --host-arch armhf foo.dsc
sbuild --host=armhf foo.dsc
No, you don't need to set up an extra chroot. The regular chroots for native building will work.
sbuild has supported
--host for a long time, using various approaches over time;
--host-arch in version 0.227, and Debian 8 users can find the required packages in Jessie backports.)