-
Notifications
You must be signed in to change notification settings - Fork 60
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,internal): multiple fixes related to cos and driver build. #383
Conversation
internal/utils/extract.go
Outdated
@@ -58,7 +58,7 @@ func ExtractTarGz(gzipStream io.Reader, destDir string, stripPathComponents int) | |||
switch header.Typeflag { | |||
case tar.TypeDir: | |||
d := filepath.Join(destDir, strippedName) | |||
if err = os.Mkdir(filepath.Clean(d), 0o750); err != nil { | |||
if err = os.MkdirAll(filepath.Clean(d), 0o750); err != nil { |
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.
Avoid failing when creating targz root folder (ie: when strippedName
is either empty or /
).
internal/utils/extract.go
Outdated
@@ -76,8 +76,23 @@ func ExtractTarGz(gzipStream io.Reader, destDir string, stripPathComponents int) | |||
if err = outFile.Close(); err != nil { | |||
return nil, err | |||
} | |||
if err = os.Chmod(filepath.Clean(f), header.FileInfo().Mode()); err != nil { |
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.
Properly set correct mode on created files.
internal/utils/extract.go
Outdated
files = append(files, f) | ||
|
||
case tar.TypeLink, tar.TypeSymlink: |
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.
Manage also soft links and hard links.
@@ -76,15 +77,15 @@ func (c *cos) customizeBuild(ctx context.Context, | |||
|
|||
currKernelDir := env[kernelDirEnv] | |||
|
|||
cosKernelDir := currKernelDir + "usr/src/" | |||
cosKernelDir := filepath.Join(currKernelDir, "usr", "src") |
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.
Small fixes.
if strings.HasSuffix(kernelConfigPath, ".gz") { | ||
src = tar.NewReader(f) | ||
src, err = gzip.NewReader(f) |
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.
We don't need a tar reader; we need a gzip reader.
} else { | ||
src = f | ||
} | ||
defer src.Close() |
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.
Properly close src.
@@ -87,6 +87,7 @@ func (b *bpf) Build(ctx context.Context, | |||
makeCmdArgs := fmt.Sprintf(`make -C %q`, filepath.Clean(srcPath)) | |||
makeCmd := exec.CommandContext(ctx, "bash", "-c", makeCmdArgs) //nolint:gosec // false positive | |||
// Append requested env variables to the command env | |||
makeCmd.Env = os.Environ() |
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.
If env gets set in the command, like we were doing, os.Environ
was not set.
/cc @LucaGuerra |
/milestone v0.7.1 |
Thanks @FedeDP ! I have tested these modifications and they worked for me, downloading the right headers for COS. |
2571108
to
22f906e
Compare
Signed-off-by: Federico Di Pierro <[email protected]>
22f906e
to
159486c
Compare
Signed-off-by: Federico Di Pierro <[email protected]>
c5e50d8
to
26fcdba
Compare
var files []string | ||
|
||
uncompressedStream, err := gzip.NewReader(gzipStream) | ||
func ExtractTarGz(ctx context.Context, gzipStream io.Reader, destDir string, stripPathComponents int) ([]string, error) { |
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.
The new signature takes the context too!
26fcdba
to
427e1c3
Compare
…e robust and safe. Signed-off-by: Federico Di Pierro <[email protected]>
427e1c3
to
a40ea45
Compare
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: FedeDP, leogr 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 library
What this PR does / why we need it:
See self review ;)
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer: