aboutsummaryrefslogtreecommitdiffstats
path: root/pkg
diff options
context:
space:
mode:
Diffstat (limited to 'pkg')
-rw-r--r--pkg/build/build.go17
1 files changed, 11 insertions, 6 deletions
diff --git a/pkg/build/build.go b/pkg/build/build.go
index b84adb20b..c9a5b038f 100644
--- a/pkg/build/build.go
+++ b/pkg/build/build.go
@@ -49,6 +49,15 @@ type ImageDetails struct {
CompilerID string
}
+func sanitize(params *Params) {
+ if params.Tracer == nil {
+ params.Tracer = &debugtracer.NullTracer{}
+ }
+ if params.BuildCPUs == 0 {
+ params.BuildCPUs = runtime.NumCPU()
+ }
+}
+
// Image creates a disk image for the specified OS/ARCH/VM.
// Kernel is taken from KernelDir, userspace system is taken from UserspaceDir.
// If CmdlineFile is not empty, contents of the file are appended to the kernel command line.
@@ -71,12 +80,7 @@ type ImageDetails struct {
// the version of the compiler/toolchain that was used to build the kernel.
// The CompilerID field is not guaranteed to be non-empty.
func Image(params Params) (details ImageDetails, err error) {
- if params.Tracer == nil {
- params.Tracer = &debugtracer.NullTracer{}
- }
- if params.BuildCPUs == 0 {
- params.BuildCPUs = runtime.NumCPU()
- }
+ sanitize(&params)
var builder builder
builder, err = getBuilder(params.TargetOS, params.TargetArch, params.VMType)
if err != nil {
@@ -114,6 +118,7 @@ func Image(params Params) (details ImageDetails, err error) {
}
func Clean(params Params) error {
+ sanitize(&params)
builder, err := getBuilder(params.TargetOS, params.TargetArch, params.VMType)
if err != nil {
return err