Skip to content

Commit

Permalink
Remove librpm installation from auditbeat build
Browse files Browse the repository at this point in the history
It fails for some platforms, and the requested packages are already
provided by the base images.
  • Loading branch information
jsoriano committed Sep 23, 2020
1 parent d2a8922 commit a920de6
Showing 1 changed file with 0 additions and 89 deletions.
89 changes: 0 additions & 89 deletions x-pack/auditbeat/magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ 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 @@ -44,9 +42,6 @@ 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 @@ -124,87 +119,3 @@ 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": installLinuxARMLE,
"linux/armv6": installLinuxARMLE,
"linux/armv7": installLinuxARMHF,
"linux/mips": installLinuxMIPS,
"linux/mipsle": installLinuxMIPSLE,
"linux/mips64le": installLinuxMIPS64LE,
"linux/ppc64le": installLinuxPPC64LE,
"linux/s390x": installLinuxS390X,

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

const (
librpmDevPkgName = "librpm-dev"
)

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

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

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

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

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

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

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

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

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

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

func installDependencies(pkg, arch string) error {
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
}

return sh.Run("apt-get", "install", "-y", "--no-install-recommends", pkg)
}

0 comments on commit a920de6

Please sign in to comment.