Created
February 26, 2025 19:26
-
-
Save drinkcat/a3e424b2f63db767e75ce783d751c73c to your computer and use it in GitHub Desktop.
printf %a behaviour across architectures
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Make sure to follow | |
# https://docs.docker.com/build/building/multi-platform/ | |
# to setup qemu with docker. | |
set -e -x | |
image=debian:bookworm-slim | |
cmd="" | |
# Manually copied from https://hub.docker.com/_/debian/tags?name=bookworm-slim | |
platforms="linux/386 linux/amd64 linux/arm/v5 linux/arm/v7 linux/arm64/v8 linux/mips64le linux/ppc64le linux/s390x" | |
mkdir -p out | |
for platform in $platforms; do | |
# Weirdly, running with `linux/arm/v7` then `linux/arm64/v8` | |
# does not make docker fetch a new image, prune docker... | |
# Not recommended if you use docker for some other purpose | |
yes | docker system prune -a | |
outfile="out/$(echo $platform | tr '/' '-')" | |
echo "$platform" > "$outfile" | |
docker run --platform "$platform" --rm -it "$image" \ | |
sh -c "arch; LANG=C env printf '%a %.6a\\n' 0.12544 0.12544" >> "$outfile" | |
done | |
dos2unix out/* |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment