paleozogt/arch-map
script utility for mapping architecture names to various standards
1.3K
From https://github.com/paleozogt/arch-map
Architecture names are all over the place.
Take 32-bit arm:
arm32v7
arm
armhf
arm-linux-gnueabi
If you're cross-compiling for multiple arches, managing all these names becomes complicated. This script does that mapping, with input Docker style (e.g., arm32v7
).
The script is meant to be sourced, so that it can load env vars. It uses the ARCH
env var as its input.
You can source it directly:
$ ARCH=arm32v7 . ./arch-map
$ echo DOCKER_ARCH=$DOCKER_ARCH
$ echo GOARCH=$GOARCH
$ echo DPKG_ARCH=$DPKG_ARCH
$ echo TRIPLET=$TRIPLET
DOCKER_ARCH=arm32v7
GOARCH=arm
DPKG_ARCH=armhf
TRIPLET=arm-linux-gnueabi
It's also really useful in Dockerfiles. Here we source the script to let us know what cross-compiler (if any) to install:
FROM paleozogt/arch-map as archmap
FROM ubuntu
COPY --from=archmap /bin/arch-map /bin/arch-map
ARG ARCH
RUN . /bin/arch-map \
&& if [ "$(dpkg --print-architecture)" = "$DPKG_ARCH" ]; then \
apt-get update && apt-get install -y \
g++ \
&& rm -rf /var/lib/apt/lists/* \
; else \
apt-get update && apt-get install -y \
g++-$TRIPLET \
&& rm -rf /var/lib/apt/lists/* \
; fi
See the test folder for more examples of how the script can be used.
You can also source it using Docker:
$ docker run --rm -it paleozogt/arch-map:0.1-arm32v7 | source /dev/stdin
$ echo DOCKER_ARCH=$DOCKER_ARCH
$ echo GOARCH=$GOARCH
$ echo DPKG_ARCH=$DPKG_ARCH
$ echo TRIPLET=$TRIPLET
DOCKER_ARCH=arm32v7
GOARCH=arm
DPKG_ARCH=armhf
TRIPLET=arm-linux-gnueabi
docker pull paleozogt/arch-map