phusion / passenger_apt_automation

Tools for automatically building a Debian APT repository for Phusion Passenger
MIT License
20 stars 20 forks source link

Support cross-compilation through emulation #34

Closed maths22 closed 1 year ago

maths22 commented 4 years ago

This has been used to successfully produce arm64 packages of passenger OSS and passenger enterprise for ubuntu bionic and focal. No other packages have been tested nor have test scripts been updated to support multiple architectures.

This took about an hour to build on a 2017 macbook pro inside vagrant (2.9 ghz, 16gb RAM) so it isn't exactly speedy. But the resulting debs have been validated on an aws gravitron2 instance.

felixbuenemann commented 3 years ago

I think you should check dpkg --print-architecture and/or uname -m to detect if cross compile is needed.

When building on a native aarch64/arm64 system you need to cross-compile for i386/amd64, so the logic is inverted.

felixbuenemann commented 3 years ago

Btw. you can compile natively on a Graviton2 Ubuntu Focal instance:

#!/bin/sh
set -ex
sudo apt install -y git make docker.io
# if docker permission is denied run this and start a new session:
# sudo usermod -G docker -a $USER
# build base image for arm64
git clone https://github.com/phusion/baseimage-docker.git
cd baseimage-docker
git checkout 0.11
make build
cd ..
git clone https://github.com/phusion/passenger.git
cd passenger
git checkout release-6.0.7
git submodule update --init
cd ..
git clone https://github.com/phusion/passenger_apt_automation.git
cd passenger_apt_automation
# build buildbox image for arm64
curl -L https://github.com/phusion/passenger_apt_automation/pull/35.diff | patch -Np1
docker build -t phusion/passenger_apt_automation_buildbox:1.1.8 --rm docker-images/buildbox
# build packages
curl -L https://github.com/phusion/passenger_apt_automation/pull/36.diff | patch -Np1
mkdir work cache output
./build -p ../passenger -w work -c cache -o output -j `nproc` -a arm64 -d focal pkg:all

Make sure you have at least 2 GiB RAM or build will fail due to OOM or cause excessive swapping.

See #35 and #36 for the fixes.

The build including docker images takes about 18min on a t4g.small instance, without those about 11min.

samip5 commented 3 years ago

Hi, @maths22. I'm thinking of making a new PR that has the changes that were suggested so I would like to ask if you have the time to fix this or should I go ahead with a new one?

CamJN commented 1 year ago

we produce arm packages now, and this PR has merge-conflicts so i'm closing it.