added option for automatic kernel detection
This commit is contained in:
@@ -14,13 +14,15 @@ import (
|
||||
)
|
||||
|
||||
func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
|
||||
// Checking if container flag was set, then overwriting OptRoot
|
||||
kernelVersion := args[0]
|
||||
kernelName := kernelVersion
|
||||
if len(args) > 1 {
|
||||
kernelName = args[1]
|
||||
if len(args) == 0 && !OptDetect {
|
||||
wwlog.Printf(wwlog.ERROR, "the '--detect' flag is needed, if no kernel version is suppiled")
|
||||
os.Exit(1)
|
||||
}
|
||||
if OptDetect && (OptRoot == "" || OptContainer == "") {
|
||||
wwlog.Printf(wwlog.ERROR, "the '--detect flag needs the '--container' or '--root' flag")
|
||||
os.Exit(1)
|
||||
}
|
||||
// Checking if container flag was set, then overwriting OptRoot
|
||||
if OptContainer != "" {
|
||||
if container.ValidSource(OptContainer) {
|
||||
OptRoot = container.RootFsDir(OptContainer)
|
||||
@@ -29,6 +31,24 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
var kernelVersion string
|
||||
var err error
|
||||
if len(args) > 0 {
|
||||
kernelVersion = args[0]
|
||||
} else {
|
||||
kernelVersion, err = kernel.FindKernelVersion(OptRoot)
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "could not detect kernel under %s\n", OptRoot)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
kernelName := kernelVersion
|
||||
if len(args) > 1 {
|
||||
kernelName = args[1]
|
||||
} else if OptDetect && (OptContainer != "") {
|
||||
kernelName = OptContainer
|
||||
}
|
||||
output, err := kernel.Build(kernelVersion, kernelName, OptRoot)
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "Failed building kernel: %s\n", err)
|
||||
|
||||
Reference in New Issue
Block a user