From 36686d44558a26e4bfce6d9d2732e923df803646 Mon Sep 17 00:00:00 2001 From: Christian Goll Date: Fri, 29 Sep 2023 09:37:12 +0200 Subject: [PATCH] fixed kmod creation Signed-off-by: Christian Goll --- CHANGELOG.md | 1 + internal/pkg/kernel/kernel.go | 40 ++++++++++++++--------------------- internal/pkg/util/util.go | 15 ++++--------- 3 files changed, 21 insertions(+), 35 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ae2be947..7385aa9e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -136,6 +136,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 has a container these binaries are extracted from the container image. - overlays from different profiles for one node are now merged, overlays can be excluded with ~ prefix and in listings are listed as !{excluded_profile} #885 +- modules are now correctly included ## [4.4.0] 2023-01-18 diff --git a/internal/pkg/kernel/kernel.go b/internal/pkg/kernel/kernel.go index 2145bc9e..91a8fe7e 100644 --- a/internal/pkg/kernel/kernel.go +++ b/internal/pkg/kernel/kernel.go @@ -117,7 +117,7 @@ kernel version. A name for this kernel and were to find has also to be supplied */ func Build(kernelVersion, kernelName, root string) error { - kernelDrivers := path.Join(root, "/lib/modules/", kernelVersion) + kernelDrivers := []string{path.Join("lib/modules/", kernelVersion, "*"), "lib/firmware/*"} kernelDestination := KernelImage(kernelName) driversDestination := KmodsImage(kernelName) versionDestination := KernelVersionFile(kernelName) @@ -155,10 +155,6 @@ func Build(kernelVersion, kernelName, root string) error { wwlog.Info("Found kernel at: %s", kernelSource) } - if !util.IsDir(kernelDrivers) { - return errors.New("Could not locate kernel drivers") - } - wwlog.Verbose("Setting up Kernel") if _, err := os.Stat(kernelSource); err == nil { kernel, err := os.Open(kernelSource) @@ -192,27 +188,23 @@ func Build(kernelVersion, kernelName, root string) error { } - if _, err := os.Stat(kernelDrivers); err == nil { - name := kernelName + " drivers" - wwlog.Verbose("Creating image for %s: %s", name, root) + name := kernelName + " drivers" + wwlog.Verbose("Creating image for %s: %s", name, root) - err = util.BuildFsImage( - name, - root, - driversDestination, - []string{ - "." + kernelDrivers, - "./lib/firmware"}, - []string{}, - // ignore cross-device files - true, - "newc", - // dereference symbolic links - "-L") + err = util.BuildFsImage( + name, + root, + driversDestination, + kernelDrivers, + []string{}, + // ignore cross-device files + true, + "newc", + // dereference symbolic links + "-L") - if err != nil { - return err - } + if err != nil { + return err } wwlog.Verbose("Creating version file") diff --git a/internal/pkg/util/util.go b/internal/pkg/util/util.go index a213e384..62add2aa 100644 --- a/internal/pkg/util/util.go +++ b/internal/pkg/util/util.go @@ -289,6 +289,7 @@ func FindFilterFiles( includeDirs := []string{} ignoreDirs := []string{} err = filepath.Walk(".", func(location string, info os.FileInfo, err error) error { + wwlog.Debug(location) if err != nil { return err } @@ -344,6 +345,8 @@ func FindFilterFiles( ofiles = append(ofiles, location) if info.IsDir() { includeDirs = append(includeDirs, file) + } else { + wwlog.Debug("No matched (%d): %s", i, file) } return nil } @@ -690,17 +693,7 @@ func BuildFsImage( if err != nil { return errors.Wrapf(err, "Failed to create image directory for %s: %s", name, imagePath) } - wwlog.Debug("Created image directory for %s: %s", name, imagePath) - - // TODO: why is this done if the container must already exist? - err = os.MkdirAll(path.Dir(rootfsPath), 0755) - if err != nil { - return errors.Wrapf(err, "Failed to create fs directory for %s: %s", name, rootfsPath) - } - - wwlog.Debug("Created fs directory for %s: %s", name, rootfsPath) - cwd, err := os.Getwd() if err != nil { return err @@ -713,7 +706,7 @@ func BuildFsImage( if err != nil { return errors.Wrapf(err, "Failed chdir to fs directory for %s: %s", name, rootfsPath) } - + wwlog.Verbose("changed to: %s", rootfsPath) files, err := FindFilterFiles( ".", include,