Commit e121d14b authored by Josip Sokcevic's avatar Josip Sokcevic Committed by LUCI CQ

[cipd] Detect Mac ARM running under Rosetta

If a user has git for x64, `git cl` results in downloading x64 cipd
packages. Other operations, such as gclient or git-cl will result in
downloading arm64. This flip-flopping between architectures causes
unexpected behavior:
(1) slows down commands since packages are wiped and new ones are
downloaded.
(2) long running processes, such as goma may crash.

This change adds additional check for all macs running on x86 to check
if is running under Rosetta and sets ARCH=arm64 if true.

R=bryner@google.com, masonf@chromium.org

Bug: 1311733
Change-Id: I65b127467d5c47d5bf07952d2ecdcb93630c7c87
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3573068Reviewed-by: 's avatarBrian Ryner <bryner@google.com>
Reviewed-by: 's avatarMason Freed <masonf@chromium.org>
Commit-Queue: Josip Sokcevic <sokcevic@google.com>
parent 05381726
......@@ -36,11 +36,19 @@ case "${UNAME}" in
exit 1
esac
if [ -z $ARCH ]; then
UNAME=`uname -m | tr '[:upper:]' '[:lower:]'`
case "${UNAME}" in
x86_64|amd64)
ARCH=amd64
# Check if Mac ARM running under Rosetta
if [ $OS == 'mac' ]; then
TRANSLATED=`/usr/sbin/sysctl -n sysctl.proc_translated 2> /dev/null || echo 0`
if [ $TRANSLATED == "1" ]; then
ARCH="arm64"
fi
fi
;;
s390x|ppc64|ppc64le) # best-effort support
ARCH="${UNAME}"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment