1
0

Implements build on host and support for custom kernels

Resolves #6
This commit is contained in:
2019-08-16 05:05:26 +00:00
parent 15a8c6b1e4
commit d035e4f8ad
4 changed files with 102 additions and 18 deletions

29
pew.go
View File

@ -72,10 +72,33 @@ func build(tmp string, ka config.Artifact, ki config.KernelInfo,
}
kernel := "/lib/modules/" + ki.KernelRelease + "/build"
if ki.KernelSource != "" {
kernel = ki.KernelSource
}
output, err = dockerRun(dockerTimeout, ki.ContainerName,
tmpSourcePath, "make KERNEL="+kernel+" TARGET="+target+
" && chmod -R 777 /work")
if ki.ContainerName != "" {
output, err = dockerRun(dockerTimeout, ki.ContainerName,
tmpSourcePath, "make KERNEL="+kernel+" TARGET="+target+
" && chmod -R 777 /work")
} else {
command := "make KERNEL=" + kernel + " TARGET=" + target
cmd := exec.Command("bash", "-c", "cd "+tmpSourcePath+" && "+command)
timer := time.AfterFunc(dockerTimeout, func() {
cmd.Process.Kill()
})
defer timer.Stop()
var raw []byte
raw, err = cmd.CombinedOutput()
if err != nil {
e := fmt.Sprintf("error `%v` for cmd `%v` with output `%v`",
err, command, string(raw))
err = errors.New(e)
return
}
output = string(raw)
}
return
}