Skip to content

Instantly share code, notes, and snippets.

@ljfranklin
Last active April 4, 2024 10:24
Show Gist options
  • Save ljfranklin/f6a7dfcfb2c573d4a276dad59e58db82 to your computer and use it in GitHub Desktop.
Save ljfranklin/f6a7dfcfb2c573d4a276dad59e58db82 to your computer and use it in GitHub Desktop.
Steps to build glibc for alpine ARM64

Steps

One-time setup

# Enable emulation for cross-platform images
sudo apt-get install -y binfmt-support qemu-user-static

# Enable cross-build commands in docker
docker buildx create --use

Build glibc binaries for ARM64

git clone https://github.com/sgerrand/docker-glibc-builder
cd docker-glibc-builder
docker buildx build --platform linux/arm64,linux/amd64 -t ljfranklin/glibc-builder:latest --push .
docker run --platform linux/arm64 --rm --env STDOUT=1 ljfranklin/glibc-builder:latest 2.32 /usr/glibc-compat > glibc-bin-2.32-0-aarch64.tar.gz
cd ..

Build glibc APK for ARM64

git clone https://github.com/andyshinn/docker-alpine-abuild
cd docker-alpine-abuild
docker buildx build --platform linux/arm64,linux/amd64 -t ljfranklin/alpine-abuild:latest --push .
cd ..

mkdir keys
openssl genrsa -out keys/ljfranklin-glibc 2048
openssl rsa -in keys/ljfranklin-glibc -pubout > keys/ljfranklin-glibc.pub

git clone --branch arm64 https://github.com/ljfranklin/alpine-pkg-glibc
cd alpine-pkg-glibc
docker run -it \
	-e RSA_PRIVATE_KEY="$(cat ../keys/ljfranklin-glibc)" \
	-e RSA_PRIVATE_KEY_NAME="ljfranklin-glibc" \
	-v "$PWD:/home/builder/package" \
	-v "$HOME/.abuild/packages:/packages" \
	-v "../keys/ljfranklin-glibc.pub:/etc/apk/keys/ljfranklin-glibc.pub" \
	--platform linux/arm64 \
	ljfranklin/alpine-abuild:latest
ls ~/.abuild/packages/builder/aarch64/*.apk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment