12

I want to build an armhf package on an amd64 machine. My armhf machine is a lot slower than my amd64 one.

tshepang
  • 64,472
  • 86
  • 223
  • 290

3 Answers3

8

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 --host-arch. 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.

tshepang
  • 64,472
  • 86
  • 223
  • 290
  • Tested on a Debian 8 amd64 system – tshepang May 18 '15 at 20:14
  • **coreutils** also builds – tshepang May 18 '15 at 21:23
  • 2
    You might want to take a look at `sbuild`, I find it much better for cross-builds. It also avoids having to add a foreign architecture to your development system... – Stephen Kitt May 18 '15 at 21:25
  • But it's so complex to set up. Maybe I'll try at some point. – tshepang May 20 '15 at 09:18
  • 2
    Note that `debuild` can be used instead of `dpkg-buildpackage` in order to have a sanitized environment for the build. But in this case, one must use `-a` (with no spaces between `-a` and its value) instead of `--host-arch `. I've just reported the following bug about this: [#898706 - devscripts: debuild dpkg-buildpackage option support is buggy or not properly documented](https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=898706). – vinc17 May 15 '18 at 11:59
5

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.

tshepang
  • 64,472
  • 86
  • 223
  • 290
2

In Debian 9, with pbuilder:

pbuilder build --host-arch armhf foo.dsc

or sbuild:

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; pbuilder added --host-arch in version 0.227, and Debian 8 users can find the required packages in Jessie backports.)

Stephen Kitt
  • 411,918
  • 54
  • 1,065
  • 1,164
  • 1
    Welcome @Helmut ;-). Given the age of the question, I thought it worth mentioning when these options became available. – Stephen Kitt Jan 07 '19 at 08:32