diff options
| author | Aleksandr Nogikh <nogikh@google.com> | 2021-07-20 09:51:49 +0000 |
|---|---|---|
| committer | Aleksandr Nogikh <wp32pw@gmail.com> | 2021-07-20 13:39:45 +0200 |
| commit | 1d0d9801861138705e655de691d7bb9c8b3aac4b (patch) | |
| tree | dd34c41d4d900e7aed2df6b2f90f6b3cdc612797 /pkg/build/linux.go | |
| parent | 2fe31df39f956886ef214b5b028362964aa07a53 (diff) | |
pkg/build: modify builder interface
Modify the `builder` interface in such a way that build method also
returns a struct containing extra information about the build process.
This allows to fetch compiler ID from individual builders. Also, this
makes the `signer` interface obsolete, as this information can also go
into that structure.
Diffstat (limited to 'pkg/build/linux.go')
| -rw-r--r-- | pkg/build/linux.go | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/pkg/build/linux.go b/pkg/build/linux.go index 7aedaef16..7632712f2 100644 --- a/pkg/build/linux.go +++ b/pkg/build/linux.go @@ -24,31 +24,36 @@ import ( type linux struct{} -var _ signer = linux{} - -func (linux linux) build(params Params) error { +func (linux linux) build(params Params) (ImageDetails, error) { if err := linux.buildKernel(params); err != nil { - return err + return ImageDetails{}, err } kernelPath := filepath.Join(params.KernelDir, filepath.FromSlash(kernelBin(params.TargetArch))) if fileInfo, err := os.Stat(params.UserspaceDir); err == nil && fileInfo.IsDir() { // The old way of assembling the image from userspace dir. // It should be removed once all syzbot instances are switched. - return linux.createImage(params, kernelPath) - } - if params.VMType == "qemu" { + if err := linux.createImage(params, kernelPath); err != nil { + return ImageDetails{}, err + } + } else if params.VMType == "qemu" { // If UserspaceDir is a file (image) and we use qemu, we just copy image and kernel to the output dir // assuming that qemu will use injected kernel boot. In this mode we also assume password/key-less ssh. if err := osutil.CopyFile(kernelPath, filepath.Join(params.OutputDir, "kernel")); err != nil { - return err + return ImageDetails{}, err } - return osutil.CopyFile(params.UserspaceDir, filepath.Join(params.OutputDir, "image")) + if err := osutil.CopyFile(params.UserspaceDir, filepath.Join(params.OutputDir, "image")); err != nil { + return ImageDetails{}, err + } + } else if err := embedLinuxKernel(params, kernelPath); err != nil { + return ImageDetails{}, err } - return embedLinuxKernel(params, kernelPath) -} - -func (linux linux) sign(params Params) (string, error) { - return elfBinarySignature(filepath.Join(params.OutputDir, "obj", "vmlinux")) + signature, err := elfBinarySignature(filepath.Join(params.OutputDir, "obj", "vmlinux")) + if err != nil { + return ImageDetails{}, err + } + return ImageDetails{ + Signature: signature, + }, nil } func (linux linux) buildKernel(params Params) error { |
