Skip to content

Commit

Permalink
fix: Force PLATFORMS environment variable when we build Elastic Agent…
Browse files Browse the repository at this point in the history
… dependencies on arm64 (#26415) (#26602)

* fix: build elastic agent dependencies on the architecture you are running

* fix: format

* fix: build ARM on ARM

* fix: format

* chore: backup the platforms env var

(cherry picked from commit 5488dcf)

Co-authored-by: Ivan Fernandez Calvo <[email protected]>
  • Loading branch information
mergify[bot] and kuisathaverat committed Jun 30, 2021
1 parent 46e0064 commit 93af1c8
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions x-pack/elastic-agent/magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 93af1c8

Please sign in to comment.