Sort kernel paths to find the biggest version.

Note we can do better as this is an alpha sort, so 9 is always bigger than 10.
This commit is contained in:
Gregory Kurtzer
2022-02-24 22:10:28 -08:00
parent a72942590f
commit ca6a805731

View File

@@ -3,6 +3,7 @@ package container
import (
"path"
"path/filepath"
"sort"
"github.com/hpcng/warewulf/internal/pkg/util"
"github.com/hpcng/warewulf/internal/pkg/wwlog"
@@ -30,6 +31,11 @@ func KernelFind(container string) string {
if err != nil {
return ""
}
sort.Slice(kernelPaths, func(i, j int) bool {
return kernelPaths[i] > kernelPaths[j]
})
for _, kernelPath := range kernelPaths {
wwlog.Printf(wwlog.DEBUG, "Checking for kernel path: %s\n", kernelPath)
if util.IsFile(kernelPath) {