Skip to content

Commit

Permalink
Revert "[packaging] Bump golang-crossbuild version debian8 (#23872) (#…
Browse files Browse the repository at this point in the history
…29686)" (#30184)

This reverts commit 16b0da7.
  • Loading branch information
v1v authored Feb 3, 2022
1 parent 29e1efd commit 13c9079
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 2 deletions.
4 changes: 2 additions & 2 deletions dev-tools/mage/crossbuild.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,8 @@ func CrossBuildImage(platform string) (string, error) {
tagSuffix = "s390x"
case strings.HasPrefix(platform, "linux"):
// Use an older version of libc to gain greater OS compatibility.
// Debian 8 uses glibc 2.19.
tagSuffix = "main-debian8"
// Debian 7 uses glibc 2.13.
tagSuffix = "main-debian7"
}

goVersion, err := GoVersion()
Expand Down
97 changes: 97 additions & 0 deletions x-pack/auditbeat/magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import (
"time"

"github.com/magefile/mage/mg"
"github.com/magefile/mage/sh"
"github.com/pkg/errors"

auditbeat "github.com/elastic/beats/v7/auditbeat/scripts/mage"
devtools "github.com/elastic/beats/v7/dev-tools/mage"
Expand Down Expand Up @@ -43,6 +45,9 @@ func Build() error {
// GolangCrossBuild build the Beat binary inside of the golang-builder.
// Do not use directly, use crossBuild instead.
func GolangCrossBuild() error {
if d, ok := deps[devtools.Platform.Name]; ok {
mg.Deps(d)
}
return devtools.GolangCrossBuild(devtools.DefaultGolangCrossBuildArgs())
}

Expand Down Expand Up @@ -120,3 +125,95 @@ func ExportDashboard() error {
func Dashboards() error {
return devtools.KibanaDashboards(devtools.OSSBeatDir("module"), "module")
}

// -----------------------------------------------------------------------------
// - Install the librpm-dev package
var (
deps = map[string]func() error{
"linux/386": installLinux386,
"linux/amd64": installLinuxAMD64,
"linux/arm64": installLinuxARM64,
"linux/armv5": installLinuxARMEL,
"linux/armv6": installLinuxARMEL,
"linux/armv7": installLinuxARMHF,
"linux/mips": installLinuxMIPS,
"linux/mipsle": installLinuxMIPSEL,
"linux/mips64le": installLinuxMIPS64EL,
"linux/ppc64le": installLinuxPPC64EL,
"linux/s390x": installLinuxS390X,

//"linux/ppc64": installLinuxPpc64,
//"linux/mips64": installLinuxMips64,
}
)

const (
librpmDevPkgName = "librpm-dev"

// Dependency of librpm-dev in ARM architectures, that needs to be explicitly
// installed to replace other conflicting packages pre-installed in the image.
libicuDevPkgName = "libicu-dev"
)

func installLinuxAMD64() error {
return installDependencies("", librpmDevPkgName)
}

func installLinuxARM64() error {
return installDependencies("arm64", librpmDevPkgName+":arm64")
}

func installLinuxARMHF() error {
return installDependencies("armhf", librpmDevPkgName+":armhf", libicuDevPkgName+":armhf")
}

func installLinuxARMEL() error {
return installDependencies("armel", librpmDevPkgName+":armel", libicuDevPkgName+":armel")
}

func installLinux386() error {
return installDependencies("i386", librpmDevPkgName+":i386")
}

func installLinuxMIPS() error {
return installDependencies("mips", librpmDevPkgName+":mips")
}

func installLinuxMIPS64EL() error {
return installDependencies("mips64el", librpmDevPkgName+":mips64el")
}

func installLinuxMIPSEL() error {
return installDependencies("mispel", librpmDevPkgName+":mipsel")
}

func installLinuxPPC64EL() error {
return installDependencies("ppc64el", librpmDevPkgName+":ppc64el")
}

func installLinuxS390X() error {
return installDependencies("s390x", librpmDevPkgName+":s390x")
}

func installDependencies(arch string, pkgs ...string) error {
if len(pkgs) == 0 {
return nil
}
if arch != "" {
err := sh.Run("dpkg", "--add-architecture", arch)
if err != nil {
return errors.Wrap(err, "error while adding architecture")
}
}

// TODO: This is only for debian 7 and should be removed when move to a newer OS. This flag is
// going to be used unnecessary when building using non-debian7 images
// (like when making the linux/arm binaries) and we should remove it soonish.
// See https://github.com/elastic/beats/v7/issues/11750 for more details.
if err := sh.Run("apt-get", "update", "-o", "Acquire::Check-Valid-Until=false"); err != nil {
return err
}

args := append([]string{"install", "-y", "--no-install-recommends"}, pkgs...)
return sh.Run("apt-get", args...)
}

0 comments on commit 13c9079

Please sign in to comment.