From 2da562dad094cd3f39f62287f63206547ad07064 Mon Sep 17 00:00:00 2001
From: Aaron Kling <webgeek1234@gmail.com>
Date: Mon, 25 Mar 2024 15:04:20 -0500
Subject: [PATCH] packpack: Pass platform to docker if cross-compiling

---
 utils/packpack/startpackpack.sh | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/utils/packpack/startpackpack.sh b/utils/packpack/startpackpack.sh
index ea64e2e6d..97a06675a 100755
--- a/utils/packpack/startpackpack.sh
+++ b/utils/packpack/startpackpack.sh
@@ -263,6 +263,18 @@ execpackpack () {
         parms=""
     fi
 
+    HOST_ARCH="$(uname -m)"
+    if [ "${ARCH}" != "${HOST_ARCH}" ] && [ "${HOST_ARCH}" == "x86_64" ]; then
+        case "${ARCH}" in
+            "armhf")
+                export PACKPACK_EXTRA_DOCKER_RUN_PARAMS="--platform=linux/arm"
+                ;;
+            "aarch64")
+                export PACKPACK_EXTRA_DOCKER_RUN_PARAMS="--platform=linux/arm64"
+                ;;
+        esac
+    fi
+
     if [ "${TRAVIS}" == "true"  ]; then
         # Travis will fail the build if the output gets too long
         # To mitigate that, use grep to filter out some of the noise