diff --git a/dev-tools/mage/crossbuild.go b/dev-tools/mage/crossbuild.go index b3cc26bf7e4..972531c25a8 100644 --- a/dev-tools/mage/crossbuild.go +++ b/dev-tools/mage/crossbuild.go @@ -335,16 +335,6 @@ func (b GolangCrossBuilder) Build() error { "-w", workDir, ) - // Ensure the proper platform is passed - // This fixes an issue where during arm64 linux build for the currently used docker image - // docker.elastic.co/beats-dev/golang-crossbuild:1.22.5-arm the image for amd64 arch is pulled - // and causes problems when using native arch tools on the binaries that are built for arm64 arch. - if strings.HasPrefix(b.Platform, "linux/") { - args = append(args, - "--platform", b.Platform, - ) - } - args = append(args, image, diff --git a/x-pack/osquerybeat/magefile.go b/x-pack/osquerybeat/magefile.go index d8a9dee310b..ef846eccbb0 100644 --- a/x-pack/osquerybeat/magefile.go +++ b/x-pack/osquerybeat/magefile.go @@ -96,7 +96,7 @@ func Clean() error { func execCommand(ctx context.Context, name string, args ...string) error { ps := strings.Join(append([]string{name}, args...), " ") - fmt.Println(ps) + fmt.Println("Executing command: ", ps) output, err := command.Execute(ctx, name, args...) if err != nil { fmt.Println(ps, ", failed: ", err) @@ -130,13 +130,13 @@ func stripLinuxOsqueryd() error { osArchs := osquerybeat.OSArchs(devtools.Platforms) - strip := func(oquerydPath string) error { + strip := func(oquerydPath string, target distro.OSArch) error { ok, err := fileutil.FileExists(oquerydPath) if err != nil { return err } if ok { - if err := execCommand(ctx, "strip", oquerydPath); err != nil { + if err := execCommand(ctx, stripCommand(target), oquerydPath); err != nil { return err } } @@ -160,13 +160,13 @@ func stripLinuxOsqueryd() error { // Checking and stripping osqueryd binary and both paths osquerybeat/build and agentbeat/build // because at the moment it's unclear if this step was initiated from osquerybeat or agentbeat build osquerybeatPath := filepath.Clean(filepath.Join(cwd, "../..", querydRelativePath)) - err = strip(osquerybeatPath) + err = strip(osquerybeatPath, osarch) if err != nil { return err } agentbeatPath := filepath.Clean(filepath.Join(cwd, "../../../agentbeat", querydRelativePath)) - err = strip(agentbeatPath) + err = strip(agentbeatPath, osarch) if err != nil { return err } @@ -260,3 +260,18 @@ func Fields() { mg.Deps(osquerybeat.Update.Fields) } // Config is an alias for update:config. This is a workaround for // https://github.com/magefile/mage/issues/217. func Config() { mg.Deps(osquerybeat.Update.Config) } + +func stripCommand(target distro.OSArch) string { + if target.OS != "linux" { + return "strip" // fallback + } + + switch target.Arch { + case "arm64": + return "aarch64-linux-gnu-strip" + case "amd64": + return "x86_64-linux-gnu-strip" + } + + return "strip" +}