12

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

1

3 Answers 3

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.

5
  • Tested on a Debian 8 amd64 system
    – tshepang
    May 18, 2015 at 20:14
  • coreutils also builds
    – tshepang
    May 18, 2015 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... May 18, 2015 at 21:25
  • But it's so complex to set up. Maybe I'll try at some point.
    – tshepang
    May 20, 2015 at 9: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<arch> (with no spaces between -a and its value) instead of --host-arch <arch>. I've just reported the following bug about this: #898706 - devscripts: debuild dpkg-buildpackage option support is buggy or not properly documented.
    – vinc17
    May 15, 2018 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.

3

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.)

1
  • 1
    Welcome @Helmut ;-). Given the age of the question, I thought it worth mentioning when these options became available. Jan 7, 2019 at 8:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .