-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(pkg/driverbuilder): properly export KERNELDIR in kernel-download scripts #330
Conversation
/cc @EXONER4TED |
…scripts. Signed-off-by: Federico Di Pierro <[email protected]> Co-authored-by: Aldo Lacuku <[email protected]>
/hold |
e794332
to
7a2fd7b
Compare
/unhold fixed |
export KERNELDIR=/tmp/kernel |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All kernel scripts will now export KERNELDIR at the end.
This way, they are also free to echo whatever they wish to stdout since stdout is no more used.
@@ -242,7 +249,8 @@ chmod +x /driverkit/download-headers.sh | |||
chmod +x /driverkit/driverkit.sh | |||
|
|||
/driverkit/download-libs.sh | |||
KERNELDIR=$(/driverkit/download-headers.sh) /driverkit/driverkit.sh | |||
. /driverkit/download-headers.sh |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Source the download-headers
script so that KERNELDIR
gets set.
// then finally runs the build script. | ||
res = fmt.Sprintf("%s\nexport KERNELDIR=$(%s)\n%s", libsDownloadScript, kernelDownloadScript, res) | ||
res = fmt.Sprintf("%s\n%s\n%s", libsDownloadScript, kernelDownloadScript, res) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since everything is put in a single bash script here, we don't even need to source kernel-download script.
@@ -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" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
local
executor needs to fetch KERNELDIR after exec.Command
runs.
The only way is to fallback at the old method of echoing KERNELDIR
at the end of the script; then we will parse script stdout line by line and the last one will be our KERNELDIR path.
…LDIR. Signed-off-by: Federico Di Pierro <[email protected]>
7a2fd7b
to
613fb9b
Compare
@@ -67,24 +67,35 @@ func (lbp *LocalBuildProcessor) Start(b *builder.Build) error { | |||
// if an unsupported target is passed. | |||
// Go on skipping automatic kernel headers download. | |||
if err == nil { | |||
slog.Info("Trying automatic kernel headers download.") | |||
slog.Info("Trying automatic kernel headers download") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dropped some .
at the end of log strings for local
executor, for consistency.
/unhold |
…adjust kernel-download script helper. Signed-off-by: Federico Di Pierro <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: EXONER4TED, FedeDP The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
What type of PR is this?
/kind bug
Any specific area of the project related to this PR?
/area pkg
What this PR does / why we need it:
Fix on top of #324 (this comment was highly specific: #324 (comment) :D)
It also fixes vanilla kernel builds; see libs CI that is badly failing since we released driverkit v0.18.0: https://github.com/falcosecurity/libs/actions/workflows/latest-kernel.yml
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Does this PR introduce a user-facing change?: