diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2018-07-24 14:30:05 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2018-07-24 14:30:05 +0200 |
| commit | 375a3e31e12965ce58d8853c310a4e7e655853d4 (patch) | |
| tree | adaa33da1c0d91bdac0732d3da1addee574608fb /pkg | |
| parent | 9b6bfa3fe89656f7eccf0bf094770d29be0c8c6a (diff) | |
pkg/build: save kernel config early
Currently we don't capture kernel config for broken builds
because the config is saved as the last step.
Save it as early as possible.
Diffstat (limited to 'pkg')
| -rw-r--r-- | pkg/build/build.go | 6 | ||||
| -rw-r--r-- | pkg/build/linux.go | 9 |
2 files changed, 11 insertions, 4 deletions
diff --git a/pkg/build/build.go b/pkg/build/build.go index 4d0489a63..615cc7ad7 100644 --- a/pkg/build/build.go +++ b/pkg/build/build.go @@ -33,6 +33,12 @@ func Image(targetOS, targetArch, vmType, kernelDir, outputDir, compiler, userspa if err := osutil.MkdirAll(filepath.Join(outputDir, "obj")); err != nil { return err } + if len(config) != 0 { + // Write kernel config early, so that it's captured on build failures. + if err := osutil.WriteFile(filepath.Join(outputDir, "kernel.config"), config); err != nil { + return fmt.Errorf("failed to write config file: %v", err) + } + } return builder.build(targetArch, vmType, kernelDir, outputDir, compiler, userspaceDir, cmdlineFile, sysctlFile, config) } diff --git a/pkg/build/linux.go b/pkg/build/linux.go index ccceeec82..f2bc4e0fe 100644 --- a/pkg/build/linux.go +++ b/pkg/build/linux.go @@ -54,6 +54,11 @@ func (linux) buildKernel(kernelDir, outputDir, compiler string, config []byte) e if _, err := osutil.Run(10*time.Minute, cmd); err != nil { return err } + // Write updated kernel config early, so that it's captured on build failures. + outputConfig := filepath.Join(outputDir, "kernel.config") + if err := osutil.CopyFile(configFile, outputConfig); err != nil { + return err + } // We build only bzImage as we currently don't use modules. cpu := strconv.Itoa(runtime.NumCPU()) cmd = osutil.Command("make", "bzImage", "-j", cpu, "CC="+compiler) @@ -64,10 +69,6 @@ func (linux) buildKernel(kernelDir, outputDir, compiler string, config []byte) e if _, err := osutil.Run(time.Hour, cmd); err != nil { return extractRootCause(err) } - outputConfig := filepath.Join(outputDir, "kernel.config") - if err := osutil.CopyFile(configFile, outputConfig); err != nil { - return err - } vmlinux := filepath.Join(kernelDir, "vmlinux") outputVmlinux := filepath.Join(outputDir, "obj", "vmlinux") if err := os.Rename(vmlinux, outputVmlinux); err != nil { |
