diff --git a/x-pack/elastic-agent/magefile.go b/x-pack/elastic-agent/magefile.go index b270e2f4fda7..01131c07d525 100644 --- a/x-pack/elastic-agent/magefile.go +++ b/x-pack/elastic-agent/magefile.go @@ -566,6 +566,16 @@ func packageAgent(requiredPackages []string, packagingFn func()) { } os.Setenv(agentDropPath, dropPath) + if runtime.GOARCH == "arm64" { + const platformsVar = "PLATFORMS" + oldPlatforms := os.Getenv(platformsVar) + os.Setenv(platformsVar, runtime.GOOS+"/"+runtime.GOARCH) + if oldPlatforms != "" { + defer os.Setenv(platformsVar, oldPlatforms) + } else { + defer os.Unsetenv(oldPlatforms) + } + } // cleanup after build defer os.RemoveAll(dropPath)