Skip to content

Commit

Permalink
fix(pkg/driverbuilder): fix local executor to correctly fetch KERNE…
Browse files Browse the repository at this point in the history
…LDIR.

Signed-off-by: Federico Di Pierro <[email protected]>
  • Loading branch information
FedeDP committed Mar 29, 2024
1 parent a7cdeb5 commit 7a2fd7b
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions pkg/driverbuilder/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package driverbuilder

import (
"bufio"
"bytes"
"context"
_ "embed"
"errors"
Expand All @@ -13,7 +14,6 @@ import (
"os/exec"
"os/user"
"path/filepath"
"strings"
"time"
)

Expand Down Expand Up @@ -69,10 +69,21 @@ func (lbp *LocalBuildProcessor) Start(b *builder.Build) error {
if err == nil {
slog.Info("Trying automatic kernel headers download.")
kernelDownloadScript, err := builder.KernelDownloadScript(realBuilder, nil, kr)
// Patch kernel download script to echo KERNELDIR.
// We need to capture KERNELDIR to later pass it as env variable to the build.
kernelDownloadScript += "\necho $KERNELDIR"
if err == nil {
out, err := exec.Command("bash", "-c", kernelDownloadScript).Output()
if err == nil {
path := strings.TrimSuffix(string(out), "\n")
// Scan all stdout line by line and
// store last line as KERNELDIR path.
reader := bytes.NewReader(out)
scanner := bufio.NewScanner(reader)
var path string
for scanner.Scan() {
path = scanner.Text()
}
slog.Warn("Setting KERNELDIR", "path", path)
// add the kerneldir path to env
lbp.envMap[kernelDirEnv] = path
defer func() {
Expand Down

0 comments on commit 7a2fd7b

Please sign in to comment.