Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package warewulf4 for openSUSE:Factory 
checked in at 2024-03-25 21:13:13
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/warewulf4 (Old)
 and      /work/SRC/openSUSE:Factory/.warewulf4.new.1905 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "warewulf4"

Mon Mar 25 21:13:13 2024 rev:18 rq:1161450 version:4.5.0

Changes:
--------
--- /work/SRC/openSUSE:Factory/warewulf4/warewulf4.changes      2024-02-29 
21:50:32.802410791 +0100
+++ /work/SRC/openSUSE:Factory/.warewulf4.new.1905/warewulf4.changes    
2024-03-25 21:20:29.528513154 +0100
@@ -1,0 +2,19 @@
+Mon Mar 25 11:34:23 UTC 2024 - Christian Goll <cg...@suse.com>
+
+- updated to 4.5.0 which has no functional changes to rc2
+- added fixed-ShimFind-for-aarch64.patch to fix (bsc#1221133)
+
+-------------------------------------------------------------------
+Fri Mar 22 20:23:04 UTC 2024 - Egbert Eich <e...@suse.com>
+
+- Allow to install dnsmasq as an alternative to dhcp-server.
+- Set minimum UID value for user UIDs to 1000 (boo#1221886).
+- Make dependencies warewulf package version dependent. This
+  helps to keep the resolver to mix different packages from
+  different versions.
+- On upgrade from older versions move files from
+  `/usr/share/warewulf/overlays/` to
+  `/var/lib/warewulf/overlays/*/rootfs/`
+  * Added: adjust_overlays.sh.
+
+-------------------------------------------------------------------
@@ -14 +33 @@
-    /var/lib/warewulf/host/rootfs
+    `/var/lib/warewulf/host/rootfs`
@@ -17 +36 @@
-    show up in the rendered overlays
+    show up in the rendered overlays.

Old:
----
  warewulf4-v4.5.0~rc2.tar.gz

New:
----
  adjust_overlays.sh
  fixed-ShimFind-for-aarch64.patch
  warewulf4-v4.5.0.tar.gz

BETA DEBUG BEGIN:
  New:- updated to 4.5.0 which has no functional changes to rc2
- added fixed-ShimFind-for-aarch64.patch to fix (bsc#1221133)
BETA DEBUG END:

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ warewulf4.spec ++++++
--- /var/tmp/diff_new_pack.CKCe6I/_old  2024-03-25 21:20:30.524549786 +0100
+++ /var/tmp/diff_new_pack.CKCe6I/_new  2024-03-25 21:20:30.528549934 +0100
@@ -17,10 +17,6 @@
 
 
 %global vers 4.5.0
-%global rls_cndt rc2
-%if "0%{?rls_cndt}" != "0"
-%global rls_char ~
-%endif
 %global tftpdir /srv/tftpboot
 %global srvdir %{_sharedstatedir}
 #%%global githash 5b0de8ea5397ca42584335517fd4959d7ffe3da5
@@ -28,17 +24,19 @@
 ExclusiveArch:  x86_64 aarch64
 
 Name:           warewulf4
-Version:        %{vers}%{?rls_char}%{?rls_cndt}
+Version:        %{vers}
 Release:        0
 Summary:        A suite of tools for clustering
 License:        BSD-3-Clause
 Group:          Productivity/Clustering/Computing
 URL:            https://warewulf.org
-Source0:        
https://github.com/warewulf/warewulf/releases/download/v%{vers}%{?rls_cndt}/warewulf-%{vers}%{rls_cndt}.tar.gz#/warewulf4-v%{version}.tar.gz
+Source0:        
https://github.com/warewulf/warewulf/releases/download/v%{vers}/warewulf-%{vers}.tar.gz#/warewulf4-v%{version}.tar.gz
 #Source1:        vendor.tar.gz
 Source5:        warewulf4-rpmlintrc
 Source10:       config-ww4.sh
+Source11:       adjust_overlays.sh
 Source20:       README.dnsmasq
+Patch01:        fixed-ShimFind-for-aarch64.patch
 
 # no firewalld in sle12
 %if 0%{?sle_version} >= 150000 || 0%{?suse_version} > 1500
@@ -58,10 +56,11 @@
 BuildRoot:      %{_tmppath}/%{name}-%{version}-build
 %sysusers_requires
 Requires:       %{name}-overlay = %{version}
-Requires:       dhcp-server
 Requires:       ipxe-bootimgs
 Requires:       pigz
 Requires:       tftp
+Requires:       ( dhcp-server or dnsmasq )
+Suggests:       dhcp-server
 Recommends:     bash-completion
 Recommends:     ipmitool
 Recommends:     nfs-kernel-server
@@ -77,7 +76,7 @@
 %package overlay
 # Smells like a circular dependcy, but needed in this case as the
 # files belong to the warewulf user
-Requires(pre):  %{name}
+Requires(pre):  %{name} = %version
 Summary:        Default overlay for warewulf
 Group:          Productivity/Clustering/Computing
 
@@ -85,7 +84,7 @@
 Includes the default overlays so that they can be updated seprately.
 
 %package api
-Requires:       %{name}
+Requires:       %{name} = %version
 Summary:        Contains the services for the warewulf rest API
 Conflicts:      warewulf-provision-x86_64-initramfs
 
@@ -94,9 +93,7 @@
 the commandline from an external host.
 
 %package man
-Supplements:    %{name}
-Provides:       warewulf4-doc = %version
-Obsoletes:      warewulf4-doc < %version
+Supplements:    %{name} = %version
 Summary:        Warewulf4 Man Pages
 BuildArch:      noarch
 
@@ -108,7 +105,7 @@
 Requires:       %{name} = %{version}
 Requires:       slurm
 BuildArch:      noarch
-Obsoletes:      warewulf4-slurm < 4.4.0
+Obsoletes:      warewulf4-slurm <= 4.4.0
 Provides:       warewulf4-slurm = %version
 
 %description overlay-slurm
@@ -116,7 +113,7 @@
 cluster on the configured warewulf nodes.
 
 %prep
-%setup -q -n warewulf-%{vers}%{rls_cndt}
+%setup -q -n warewulf-%{vers}
 %autopatch -p1
 # tar xzf %{S:1}
 
@@ -187,6 +184,8 @@
   .["container mounts"] += {"source": 
"/etc/zypp/credentials.d/SCCcredentials", "dest": 
"/etc/zypp/credentials.d/SCCcredentials", "readonly": true}' \
   -i %{buildroot}%{_sysconfdir}/warewulf/warewulf.conf
 #sed -i -e 's@\(^\s*\)\(.*:.*\):@\1"\2":@' 
%%{buildroot}%%{_sysconfdir}/warewulf/warewulf.conf
+# SUSE starts user UIDs at 1000
+sed -i -e 's@\(.* \$_UID \(>\|-ge\) \)500\(.*\)@\11000\3@' 
%{buildroot}%{_localstatedir}/lib/warewulf/overlays/host/rootfs/etc/profile.d/ssh_setup.*sh
 # fix dhcp for SUSE
 mv 
%{buildroot}%{_localstatedir}/lib/warewulf/overlays/host/rootfs/etc/dhcp/dhcpd.conf.ww
 
%{buildroot}%{_localstatedir}/lib/warewulf/overlays/host/rootfs/etc/dhcpd.conf.ww
 rmdir %{buildroot}%{_localstatedir}/lib/warewulf/overlays/host/rootfs/etc/dhcp
@@ -197,6 +196,7 @@
 %sysusers_generate_pre system-user-%{name}.conf %{name} 
system-user-%{name}.conf
 install -D -m 644 system-user-%{name}.conf 
%{buildroot}%{_sysusersdir}/system-user-%{name}.conf
 install -D -m 755 %{S:10} 
%{buildroot}%{_datadir}/warewulf/scripts/config-warewulf.sh
+install -D -m 755 %{S:11} 
%{buildroot}%{_datadir}/warewulf/scripts/%{basename:S:11}
 
 # get the slurm package ready
 mkdir -p 
%{buildroot}%{_localstatedir}/lib/warewulf/overlays/host/rootfs/etc/slurm
@@ -227,6 +227,9 @@
 %postun
 %service_del_postun warewulfd.service
 
+%posttrans overlay
+%{_datadir}/warewulf/scripts/%{basename:S:11}
+
 %files
 %defattr(-,root,root)
 %doc README.md
@@ -242,6 +245,7 @@
 %{_defaultdocdir}/%{name}/example-templates
 %{_prefix}/lib/firewalld/services/warewulf.xml
 %exclude %{_datadir}/warewulf/overlays
+%exclude %{_datadir}/warewulf/scripts/%{basename:S:11}
 %{_bindir}/wwctl
 %{_sbindir}/rcwarewulfd
 %{_unitdir}/warewulfd.service
@@ -267,6 +271,7 @@
 %{_localstatedir}/lib/warewulf/overlays
 %dir %{_localstatedir}/lib/warewulf
 %config(noreplace) %{_localstatedir}/lib/warewulf/overlays
+%{_datadir}/warewulf/scripts/%{basename:S:11}
 %exclude %{_localstatedir}/lib/warewulf/overlays/host/rootfs/etc/slurm
 %exclude %{_localstatedir}/lib/warewulf/overlays/generic/rootfs/etc/slurm
 %exclude %{_localstatedir}/lib/warewulf/overlays/generic/rootfs/etc/munge

++++++ adjust_overlays.sh ++++++
#! /bin/sh
# when updating from an older version of the overlay package
# move added/modified overlay files to the new location.
error=0

src=/usr/share/warewulf/overlays
dst=/var/lib/warewulf/overlays

test -d $src || exit 0

for i in $(find -P $src -maxdepth 1 -mindepth 1 -type d)
do
    d=$(basename -s "" $i)
    if [ ! -d $dst/$d ]
    then
        mkdir -p /var/lib/warewulf/overlays/$d/rootfs || { error=1; continue; }
    elif [ ! -d $dst/$d/rootfs ]
    then
        mkdir -p $dst/$d/rootfs || { error=1; continue; }
    fi
    for j in $(find -P $src/$d -not -type d)
    do
        D=$(dirname $j)
        D=${D##$src/$d}
        f=$(basename -s ".rpmsave" $j)
        if [ ! -d $dst/$d/rootfs/$D ]
        then
            mkdir -p $dst/$d/rootfs/$D || { error=1; continue; }
        fi
        if [ ! -e $dst/$d/rootfs/$D/$f ]
        then
            mv $j $dst/$d/rootfs/$D/$f
        elif [ ! -e $dst/$d/rootfs/$D/$f.rpmsave ]
        then
            mv $j $dst/$d/rootfs/$D/$f.rpmsave
        else
            error=1
        fi
    done
done
if [ $error -gt 0 ]
then
    echo "Cannot copy all files - check $src manually" >&2
else
    find -P $src -type d -delete
fi


++++++ fixed-ShimFind-for-aarch64.patch ++++++
diff --git a/internal/app/wwctl/kernel/imprt/main.go 
b/internal/app/wwctl/kernel/imprt/main.go
index 2e2cbe41..55fd57f7 100644
--- a/internal/app/wwctl/kernel/imprt/main.go
+++ b/internal/app/wwctl/kernel/imprt/main.go
@@ -37,10 +37,9 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
        if len(args) > 0 {
                kernelVersion = args[0]
        } else {
-               kernelVersion, err = kernel.FindKernelVersion(OptRoot)
+               _, kernelVersion, err = kernel.FindKernel(OptRoot)
                if err != nil {
-                       wwlog.Error("could not detect kernel under %s", OptRoot)
-                       os.Exit(1)
+                       return err
                }
        }
        kernelName := kernelVersion
diff --git a/internal/pkg/api/apiconfig/container/container.go 
b/internal/pkg/api/apiconfig/container/container.go
index 9e440a08..3ca6de12 100644
--- a/internal/pkg/api/apiconfig/container/container.go
+++ b/internal/pkg/api/apiconfig/container/container.go
@@ -11,6 +11,7 @@ import (
        "github.com/pkg/errors"
        "github.com/warewulf/warewulf/internal/pkg/api/routes/wwapiv1"
        "github.com/warewulf/warewulf/internal/pkg/container"
+       "github.com/warewulf/warewulf/internal/pkg/kernel"
        "github.com/warewulf/warewulf/internal/pkg/node"
        "github.com/warewulf/warewulf/internal/pkg/util"
        "github.com/warewulf/warewulf/internal/pkg/warewulfd"
@@ -272,7 +273,7 @@ func ContainerList() (containerInfo 
[]*wwapiv1.ContainerInfo, err error) {
                }
 
                wwlog.Debug("Finding kernel version for: %s", source)
-               kernelVersion := container.KernelVersion(source)
+               _, kernelVersion, _ := 
kernel.FindKernel(container.RootFsDir(source))
 
                containerInfo = append(containerInfo, &wwapiv1.ContainerInfo{
                        Name:          source,
diff --git a/internal/pkg/api/container/container.go 
b/internal/pkg/api/container/container.go
index e9336038..480bbd57 100644
--- a/internal/pkg/api/container/container.go
+++ b/internal/pkg/api/container/container.go
@@ -12,6 +12,7 @@ import (
        "github.com/pkg/errors"
        "github.com/warewulf/warewulf/internal/pkg/api/routes/wwapiv1"
        "github.com/warewulf/warewulf/internal/pkg/container"
+       "github.com/warewulf/warewulf/internal/pkg/kernel"
        "github.com/warewulf/warewulf/internal/pkg/node"
        "github.com/warewulf/warewulf/internal/pkg/util"
        "github.com/warewulf/warewulf/internal/pkg/warewulfd"
@@ -324,7 +325,7 @@ func ContainerList() (containerInfo 
[]*wwapiv1.ContainerInfo, err error) {
                }
 
                wwlog.Debug("Finding kernel version for: %s", source)
-               kernelVersion := container.KernelVersion(source)
+               _, kernelVersion, _ := 
kernel.FindKernel(container.RootFsDir(source))
                var creationTime uint64
                sourceStat, err := os.Stat(container.SourceDir(source))
                if err != nil {
@@ -376,7 +377,7 @@ func ContainerShow(csp *wwapiv1.ContainerShowParameter) 
(response *wwapiv1.Conta
                err = fmt.Errorf("%s is not a valid container", containerName)
                return
        }
-       kernelVersion := container.KernelVersion(containerName)
+       _, kernelVersion, _ := 
kernel.FindKernel(container.RootFsDir(containerName))
 
        nodeDB, err := node.New()
        if err != nil {
diff --git a/internal/pkg/container/kernel.go b/internal/pkg/container/kernel.go
deleted file mode 100644
index 6205991b..00000000
--- a/internal/pkg/container/kernel.go
+++ /dev/null
@@ -1,78 +0,0 @@
-package container
-
-import (
-       "path"
-       "path/filepath"
-       "sort"
-       "strings"
-
-       "github.com/warewulf/warewulf/internal/pkg/wwlog"
-)
-
-var (
-       kernelNames = []string{
-               `vmlinux`,
-               `vmlinuz`,
-               `vmlinux-*`,
-               `vmlinuz-*`,
-               `vmlinuz.gz`}
-
-       kernelDirs = []string{
-               `/lib/modules/*/`,
-               `/boot/`}
-)
-
-func KernelFind(container string) string {
-       wwlog.Debug("Finding kernel")
-       container_path := RootFsDir(container)
-       if container_path == "" {
-               return ""
-       }
-
-       for _, kdir := range kernelDirs {
-               wwlog.Debug("Checking kernel directory: %s", kdir)
-               for _, kname := range kernelNames {
-                       wwlog.Debug("Checking for kernel name: %s", kname)
-                       kernelPaths, err := 
filepath.Glob(path.Join(container_path, kdir, kname))
-                       if err != nil {
-                               return ""
-                       }
-
-                       if len(kernelPaths) == 0 {
-                               continue
-                       }
-
-                       sort.Slice(kernelPaths, func(i, j int) bool {
-                               return kernelPaths[i] > kernelPaths[j]
-                       })
-
-                       for _, kernelPath := range kernelPaths {
-                               wwlog.Debug("Checking for kernel path: %s", 
kernelPath)
-                               // Only succeeds if kernelPath exists and, if a
-                               // symlink, links to a path that also exists
-                               kernelPath, err = 
filepath.EvalSymlinks(kernelPath)
-                               if err == nil {
-                                       wwlog.Debug("found kernel: %s", 
kernelPath)
-                                       return kernelPath
-                               }
-                       }
-               }
-       }
-
-       return ""
-}
-
-func KernelVersion(container string) string {
-       wwlog.Debug("Finding kernel version inside container: %s", container)
-       kernel := KernelFind(container)
-       if kernel == "" {
-               return ""
-       }
-
-       ret := path.Base(path.Dir(kernel))
-       if ret == "boot" {
-               ret = path.Base(kernel)
-       }
-
-       return strings.TrimPrefix(ret, "vmlinuz-")
-}
diff --git a/internal/pkg/container/shimgrub.go 
b/internal/pkg/container/shimgrub.go
index eceee4ba..95a7b590 100644
--- a/internal/pkg/container/shimgrub.go
+++ b/internal/pkg/container/shimgrub.go
@@ -10,7 +10,7 @@ import (
 
 func shimDirs() []string {
        return []string{
-               `/usr/share/efi/x86_64/`,
+               `/usr/share/efi/*/`,
                `/usr/lib64/efi/`,
                `/boot/efi/EFI/*/`,
        }
@@ -53,7 +53,7 @@ func ShimFind(container string) string {
        } else {
                container_path = "/"
        }
-       wwlog.Debug("Finding grub under paths: %s", container_path)
+       wwlog.Debug("Finding shim under paths: %s", container_path)
        return BootLoaderFindPath(container_path, shimNames, shimDirs)
 }
 
@@ -76,10 +76,13 @@ find the path of the shim binary in container
 */
 func BootLoaderFindPath(cpath string, names func() []string, paths func() 
[]string) string {
        for _, bdir := range paths() {
-               wwlog.Debug("Checking shim directory: %s", bdir)
+               wwlog.Debug("Checking directory: %s", bdir)
                for _, bname := range names() {
-                       wwlog.Debug("Checking for bootloader name: %s", bname)
-                       shimPaths, _ := filepath.Glob(path.Join(cpath, bdir, 
bname))
+                       wwlog.Debug("Checking for bootloader name: %s", 
path.Join(cpath, bdir, bname))
+                       shimPaths, err := filepath.Glob(path.Join(cpath, bdir, 
bname))
+                       if err != nil {
+                               wwlog.Debug("Got error when globing %s: %s", 
path.Join(cpath, bdir, bname), err)
+                       }
                        for _, shimPath := range shimPaths {
                                wwlog.Debug("Checking for bootloader path: %s", 
shimPath)
                                // Only succeeds if shimPath exists and, if a
diff --git a/internal/pkg/container/shimgrub_test.go 
b/internal/pkg/container/shimgrub_test.go
new file mode 100644
index 00000000..0ff207f1
--- /dev/null
+++ b/internal/pkg/container/shimgrub_test.go
@@ -0,0 +1,61 @@
+package container
+
+import (
+       "os"
+       "path"
+       "testing"
+
+       "github.com/stretchr/testify/assert"
+       warewulfconf "github.com/warewulf/warewulf/internal/pkg/config"
+       "github.com/warewulf/warewulf/internal/pkg/testenv"
+       "github.com/warewulf/warewulf/internal/pkg/wwlog"
+)
+
+func Test_Find_ShimX86(t *testing.T) {
+       testenv.New(t)
+       conf := warewulfconf.Get()
+       wwlog.SetLogLevel(wwlog.DEBUG)
+       _ = os.MkdirAll(path.Join(conf.Paths.WWChrootdir, 
"suse/rootfs/usr/lib64/efi/"), 0755)
+       shimF, err := os.Create(path.Join(conf.Paths.WWChrootdir, 
"suse/rootfs/usr/lib64/efi/shim.efi"))
+       assert.NoError(t, err)
+       _, _ = shimF.WriteString("shim.efi")
+       assert.FileExists(t, path.Join(conf.Paths.WWChrootdir, 
"suse/rootfs/usr/lib64/efi/shim.efi"))
+       shimPath := ShimFind("suse")
+       assert.Equal(t, path.Join(conf.Paths.WWChrootdir, 
"suse/rootfs/usr/lib64/efi/shim.efi"), shimPath)
+}
+func Test_Find_ShimArch64(t *testing.T) {
+       testenv.New(t)
+       conf := warewulfconf.Get()
+       wwlog.SetLogLevel(wwlog.DEBUG)
+       _ = os.MkdirAll(path.Join(conf.Paths.WWChrootdir, 
"suse/rootfs/usr/share/efi/aarch64"), 0755)
+       shimF, err := os.Create(path.Join(conf.Paths.WWChrootdir, 
"suse/rootfs/usr/share/efi/aarch64/shim.efi"))
+       assert.NoError(t, err)
+       _, _ = shimF.WriteString("shim.efi")
+       assert.FileExists(t, path.Join(conf.Paths.WWChrootdir, 
"suse/rootfs/usr/share/efi/aarch64/shim.efi"))
+       shimPath := ShimFind("suse")
+       assert.Equal(t, path.Join(conf.Paths.WWChrootdir, 
"suse/rootfs/usr/share/efi/aarch64/shim.efi"), shimPath)
+}
+func Test_Find_GrubX86(t *testing.T) {
+       testenv.New(t)
+       conf := warewulfconf.Get()
+       wwlog.SetLogLevel(wwlog.DEBUG)
+       _ = os.MkdirAll(path.Join(conf.Paths.WWChrootdir, 
"suse/rootfs/usr/share/efi/x86_64"), 0755)
+       shimF, err := os.Create(path.Join(conf.Paths.WWChrootdir, 
"suse/rootfs/usr/share/efi/x86_64/grub.efi"))
+       assert.NoError(t, err)
+       _, _ = shimF.WriteString("grub.efi")
+       assert.FileExists(t, path.Join(conf.Paths.WWChrootdir, 
"suse/rootfs//usr/share/efi/x86_64/grub.efi"))
+       shimPath := GrubFind("suse")
+       assert.Equal(t, path.Join(conf.Paths.WWChrootdir, 
"suse/rootfs/usr/share/efi/x86_64/grub.efi"), shimPath)
+}
+func Test_Find_GrubAarch64(t *testing.T) {
+       testenv.New(t)
+       conf := warewulfconf.Get()
+       wwlog.SetLogLevel(wwlog.DEBUG)
+       _ = os.MkdirAll(path.Join(conf.Paths.WWChrootdir, 
"suse/rootfs/usr/share/efi/aarch64/"), 0755)
+       shimF, err := os.Create(path.Join(conf.Paths.WWChrootdir, 
"suse/rootfs/usr/share/efi/aarch64/grub.efi"))
+       assert.NoError(t, err)
+       _, _ = shimF.WriteString("grub.efi")
+       assert.FileExists(t, path.Join(conf.Paths.WWChrootdir, 
"suse/rootfs/usr/share/efi/aarch64/grub.efi"))
+       shimPath := GrubFind("suse")
+       assert.Equal(t, path.Join(conf.Paths.WWChrootdir, 
"suse/rootfs/usr/share/efi/aarch64/grub.efi"), shimPath)
+}
diff --git a/internal/pkg/kernel/kernel.go b/internal/pkg/kernel/kernel.go
index a40a3296..40ee7321 100644
--- a/internal/pkg/kernel/kernel.go
+++ b/internal/pkg/kernel/kernel.go
@@ -8,6 +8,7 @@ import (
        "path"
        "path/filepath"
        "regexp"
+       "strings"
 
        "github.com/pkg/errors"
 
@@ -19,12 +20,18 @@ import (
 var (
        kernelSearchPaths = []string{
                // This is a printf format where the %s will be the kernel 
version
+               "/boot/Image-%s", // this is the aarch64 for SUSE, vmlinux 
which is also present won't boot
                "/boot/vmlinuz-linux%.s",
                "/boot/vmlinuz-%s",
                "/boot/vmlinuz-%s.gz",
                "/lib/modules/%s/vmlinuz",
                "/lib/modules/%s/vmlinuz.gz",
        }
+       kernelDrivers = []string{
+               "lib/modules/%s/*",
+               "lib/firmware/*",
+               "lib/modprobe.d",
+               "lib/modules-load.d"}
 )
 
 func KernelImageTopDir() string {
@@ -117,15 +124,9 @@ kernel version. A name for this kernel and were to find 
has also to be
 supplied
 */
 func Build(kernelVersion, kernelName, root string) error {
-       kernelDrivers := []string{path.Join("lib/modules/",
-               kernelVersion, "*"),
-               "lib/firmware/*",
-               "lib/modprobe.d",
-               "lib/modules-load.d"}
        kernelDestination := KernelImage(kernelName)
        driversDestination := KmodsImage(kernelName)
        versionDestination := KernelVersionFile(kernelName)
-       var kernelSource string
 
        // Create the destination paths just in case it doesn't exist
        err := os.MkdirAll(path.Dir(kernelDestination), 0755)
@@ -143,18 +144,11 @@ func Build(kernelVersion, kernelName, root string) error {
                return fmt.Errorf("failed to create version dest: %s", err)
        }
 
-       for _, searchPath := range kernelSearchPaths {
-               testPath := fmt.Sprintf(path.Join(root, searchPath), 
kernelVersion)
-               wwlog.Verbose("Looking for kernel at: %s", testPath)
-               if util.IsFile(testPath) {
-                       kernelSource = testPath
-                       break
-               }
-       }
-
-       if kernelSource == "" {
-               wwlog.Error("Could not locate kernel image")
-               return errors.New("could not locate kernel image")
+       kernelSource, kernelVersFound, err := FindKernel(root)
+       if err != nil {
+               return err
+       } else if kernelVersFound != kernelVersion {
+               return fmt.Errorf("requested %s and found kernel version %s 
differ", kernelVersion, kernelVersFound)
        } else {
                wwlog.Info("Found kernel at: %s", kernelSource)
        }
@@ -193,13 +187,21 @@ func Build(kernelVersion, kernelName, root string) error {
        }
 
        name := kernelName + " drivers"
+       var kernelDriversSpecific []string
+       for _, kPath := range kernelDrivers {
+               if strings.Contains(kPath, "%s") {
+                       kernelDriversSpecific = append(kernelDriversSpecific, 
fmt.Sprintf(kPath, kernelVersion))
+               } else {
+                       kernelDriversSpecific = append(kernelDriversSpecific, 
kPath)
+               }
+       }
+       wwlog.Debug("kernelDriversSpecific: %v", kernelDriversSpecific)
        wwlog.Verbose("Creating image for %s: %s", name, root)
-
        err = util.BuildFsImage(
                name,
                root,
                driversDestination,
-               kernelDrivers,
+               kernelDriversSpecific,
                []string{},
                // ignore cross-device files
                true,
@@ -235,27 +237,32 @@ func DeleteKernel(name string) error {
        return os.RemoveAll(fullPath)
 }
 
-func FindKernelVersion(root string) (string, error) {
+/*
+Searches for kernel under a given path. First return result is the
+full path, second the version and an error if the kernel couldn't be found.
+*/
+func FindKernel(root string) (kPath string, version string, err error) {
+       wwlog.Debug("root: %s", root)
        for _, searchPath := range kernelSearchPaths {
                testPattern := fmt.Sprintf(path.Join(root, searchPath), `*`)
-               wwlog.Verbose("Looking for kernel version with pattern at: %s", 
testPattern)
+               wwlog.Debug("Looking for kernel version with pattern at: %s", 
testPattern)
                potentialKernel, _ := filepath.Glob(testPattern)
                if len(potentialKernel) == 0 {
                        continue
                }
                for _, foundKernel := range potentialKernel {
-                       wwlog.Verbose("Parsing out kernel version for %s", 
foundKernel)
+                       wwlog.Debug("Parsing out kernel version for %s", 
foundKernel)
                        re := regexp.MustCompile(fmt.Sprintf(path.Join(root, 
searchPath), `([\w\d-\.]*)`))
                        version := re.FindAllStringSubmatch(foundKernel, -1)
                        if version == nil {
-                               return "", fmt.Errorf("could not parse kernel 
version")
+                               return foundKernel, "", fmt.Errorf("could not 
parse kernel version")
                        }
-                       wwlog.Verbose("found kernel version %s", version)
-                       return version[0][1], nil
+                       wwlog.Verbose("found kernel version %s", 
strings.TrimSuffix(version[0][1], ".gz"))
+                       return foundKernel, strings.TrimSuffix(version[0][1], 
".gz"), nil
 
                }
 
        }
-       return "", fmt.Errorf("could not find kernel version")
+       return "", "", fmt.Errorf("could not find kernel version")
 
 }
diff --git a/internal/pkg/warewulfd/provision.go 
b/internal/pkg/warewulfd/provision.go
index 8fc508f7..035cd95e 100644
--- a/internal/pkg/warewulfd/provision.go
+++ b/internal/pkg/warewulfd/provision.go
@@ -108,10 +108,9 @@ func ProvisionSend(w http.ResponseWriter, req 
*http.Request) {
                if node.Kernel.Override.Defined() {
                        stage_file = 
kernel.KernelImage(node.Kernel.Override.Get())
                } else if node.ContainerName.Defined() {
-                       stage_file = 
container.KernelFind(node.ContainerName.Get())
-
-                       if stage_file == "" {
-                               wwlog.Error("No kernel found for container %s", 
node.ContainerName.Get())
+                       stage_file, _, err = 
kernel.FindKernel(container.RootFsDir(node.ContainerName.Get()))
+                       if err != nil {
+                               wwlog.Error("No kernel found for container %s: 
%s", node.ContainerName.Get(), err)
                        }
                } else {
                        wwlog.Warn("No kernel version set for node %s", 
node.Id.Get())

++++++ warewulf4-v4.5.0~rc2.tar.gz -> warewulf4-v4.5.0.tar.gz ++++++
/work/SRC/openSUSE:Factory/warewulf4/warewulf4-v4.5.0~rc2.tar.gz 
/work/SRC/openSUSE:Factory/.warewulf4.new.1905/warewulf4-v4.5.0.tar.gz differ: 
char 12, line 1

Reply via email to