Skip to content

Commit

Permalink
fix(pkg/driverbuilder): fixed local builder template.
Browse files Browse the repository at this point in the history
Fix on top of #342.

Signed-off-by: Federico Di Pierro <[email protected]>
  • Loading branch information
FedeDP authored and poiana committed May 10, 2024
1 parent 5be1caf commit 4c7df39
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion pkg/driverbuilder/builder/templates/local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# looking for it in a bunch of ways. Convenient when running Falco inside
# a container or in other weird environments.
#
set -xeuo pipefail
set -xeo pipefail

{{ if or .BuildProbe (and .BuildModule (not .UseDKMS)) }}
cd {{ .DriverBuildDir }}
Expand Down
16 changes: 8 additions & 8 deletions pkg/driverbuilder/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func (lbp *LocalBuildProcessor) Start(b *builder.Build) error {
// if an unsupported target is passed.
// Go on skipping automatic kernel headers download.
if err == nil {
lbp.Logger.Info("Trying automatic kernel headers download")
lbp.Logger.Info("Trying automatic kernel headers download.")
kernelDownloadScript, err := builder.KernelDownloadScript(realBuilder, nil, kr, lbp.Printer)
// Patch kernel download script to echo KERNELDIR.
// We need to capture KERNELDIR to later pass it as env variable to the build.
Expand All @@ -90,19 +90,19 @@ func (lbp *LocalBuildProcessor) Start(b *builder.Build) error {
for scanner.Scan() {
path = scanner.Text()
}
lbp.Logger.Info("Setting KERNELDIR env var", lbp.Logger.Args("path", path))
lbp.Logger.Info("Setting KERNELDIR env var.", lbp.Logger.Args("path", path))
// add the kerneldir path to env
lbp.envMap[kernelDirEnv] = path
defer func() {
_ = os.RemoveAll("/tmp/kernel-download")
_ = os.RemoveAll(path)
}()
} else {
lbp.Logger.Warn("Failed to download headers", lbp.Logger.Args("err", err))
lbp.Logger.Warn("Failed to download headers.", lbp.Logger.Args("err", err))
}
}
} else {
lbp.Logger.Info("Skipping kernel headers automatic download", lbp.Logger.Args("err", err))
lbp.Logger.Info("Skipping kernel headers automatic download.", lbp.Logger.Args("err", err))
}
}

Expand Down Expand Up @@ -202,7 +202,7 @@ func (lbp *LocalBuildProcessor) Start(b *builder.Build) error {
if err = copyDataToLocalPath(srcProbePath, c.ProbeFilePath); err != nil {
return err
}
lbp.Logger.Info("eBPF probe available", lbp.Logger.Args("path", c.ProbeFilePath))
lbp.Logger.Info("eBPF probe available.", lbp.Logger.Args("path", c.ProbeFilePath))
c.ProbeFilePath = ""
}
}
Expand All @@ -218,15 +218,15 @@ func (lbp *LocalBuildProcessor) Start(b *builder.Build) error {
if err = copyDataToLocalPath(koFiles[0], c.ModuleFilePath); err != nil {
return err
}
lbp.Logger.Info("kernel module available", lbp.Logger.Args("path", b.ModuleFilePath))
lbp.Logger.Info("kernel module available.", lbp.Logger.Args("path", b.ModuleFilePath))
c.ModuleFilePath = ""
break
} else {
// print dkms build log
dkmsLogFile := fmt.Sprintf("/var/lib/dkms/%s/%s/build/make.log", c.DriverName, c.DriverVersion)
logs, err := os.ReadFile(filepath.Clean(dkmsLogFile))
if err != nil {
lbp.Logger.Warn("Running dkms build failed, couldn't find dkms log", lbp.Logger.Args("file", dkmsLogFile))
lbp.Logger.Warn("Running dkms build failed, couldn't find dkms log.", lbp.Logger.Args("file", dkmsLogFile))
} else {
lbp.Logger.Warn("Running dkms build failed. Dumping dkms log.", lbp.Logger.Args("file", dkmsLogFile))
logBuf := bytes.NewBuffer(logs)
Expand All @@ -241,7 +241,7 @@ func (lbp *LocalBuildProcessor) Start(b *builder.Build) error {
}

if c.ModuleFilePath != "" || c.ProbeFilePath != "" {
return fmt.Errorf("Failed to build all requested drivers.")
return errors.New("failed to build all requested drivers")
}
return nil
}
Expand Down

0 comments on commit 4c7df39

Please sign in to comment.