gitlab-build-images/scripts/validate-binaries-architecture
Kamil Trzciński 384f6231b4 Update scripts to compile arm64 based images
This changes all binaries to be platform dependent
instead of being amd64 hardcoded.
2022-05-02 17:20:44 +02:00

24 lines
664 B
Bash
Executable file

#!/bin/bash
set -eo pipefail
# convert architecture of a system into
# - use `arch` to show current system architecture
# - do not use `uname -m` as this shows kernel architecture
# - the `arch != uname -m` will be different when doing cross-compilation using `qemu-user`
# x86_64 -> x86-64
# aarch64 -> aarch64
ARCH=$(arch | tr '_' '-')
# find all executables in $PATH
CMDs=$(compgen -c)
CMD_PATHs=$(which $CMDs || true) # some CMDs might be missing
if files=$(file $CMD_PATHs | grep "ELF " | grep -v "$ARCH")
then
echo "Found files of different architecture than $(ARCH):"
echo "$files"
exit 1
fi
echo "Validated $(echo $CMD_PATHs | wc -w) binaries."