Skip to content

Commit

Permalink
Commonize uname -m results for aarch64 in docker runner
Browse files Browse the repository at this point in the history
`uname -m` on Linux reports `aarch64`, but on MacOS reports `arm64`.
Commonize this to `aarch64`.

With this fix, it is now possible to run aarch64 CI docker images on Arm
MacOS.
  • Loading branch information
tgross35 committed Jul 16, 2024
1 parent 5c84886 commit fd3c486
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/ci/docker/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,14 @@ do
shift
done

machine="$(uname -m)"
if [ "$machine" = "arm64" ]; then
# MacOS reports "arm64" while Linux reports "aarch64". Commonize this.
machine="aarch64"
fi

script_dir="`dirname $script`"
docker_dir="${script_dir}/host-$(uname -m)"
docker_dir="${script_dir}/host-${machine}"
ci_dir="`dirname $script_dir`"
src_dir="`dirname $ci_dir`"
root_dir="`dirname $src_dir`"
Expand Down Expand Up @@ -68,7 +74,7 @@ if [ -f "$docker_dir/$image/Dockerfile" ]; then

# Include the architecture in the hash key, since our Linux CI does not
# only run in x86_64 machines.
uname -m >> $hash_key
echo "$machine" >> $hash_key

# Include cache version. Can be used to manually bust the Docker cache.
echo "2" >> $hash_key
Expand Down Expand Up @@ -178,7 +184,7 @@ elif [ -f "$docker_dir/disabled/$image/Dockerfile" ]; then
build \
--rm \
-t rust-ci \
-f "host-$(uname -m)/$image/Dockerfile" \
-f "host-${machine}/$image/Dockerfile" \
-
else
echo Invalid image: $image
Expand All @@ -201,7 +207,7 @@ else
else
continue
fi
echo "Note: the current host architecture is $(uname -m)"
echo "Note: the current host architecture is $machine"
done

exit 1
Expand Down

0 comments on commit fd3c486

Please sign in to comment.