Skip to content
coslyk edited this page Mar 31, 2020 · 4 revisions

Cross compiling

The automation script uses cross compiling to build packages for non-amd64 platforms, so it is important to make the package cross-build friendly. You can follow the official guideline from Debian.

In general:

  • If you don't overwrite any building rules in debian-template/rules, great! You don't need to care anything. The script will set up the cross compiling environment and all parameters for you.
  • If you overwrite something in debian-template/rules, then you need to care about the architecture-specific commands.

In debian-template, you can use ##ARCH to refer the CPU architecture. It will be replaced with the architecture name like amd64 armhf.

How to test the cross compiling

The building steps are very similar to the normal buiding, except that we use a different Docker image for cross compiling.

You need to build the Docker image first:

docker run --rm --privileged multiarch/qemu-user-static:register --reset
docker build -t docker-deb-builder:buster-armhf -f docker-deb-builder/Dockerfile-debian-buster-armhf .

Then run the building script:

DEBIAN_ARCH=armhf ./build-deb.sh recipes/your-package-name

What if the package does not support specific architectures?

Just add the only_arches to the YAML file like the following:

only_arches:
  - amd64
  - i386

Known issues (Pull request welcome!)

  1. Rust projects are not supported.
  2. Electron apps are only supported under amd64 i386 arm64 and armhf.
  3. npm install may fail when compiling native node modules. (Yarn is OK)