fixed kmod creation

Signed-off-by: Christian Goll <cgoll@suse.com>
This commit is contained in:
Christian Goll
2023-09-29 09:37:12 +02:00
committed by Jonathon Anderson
parent 67e526d726
commit 36686d4455
3 changed files with 21 additions and 35 deletions

View File

@@ -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

View File

@@ -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")

View File

@@ -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,