Handling discrepancies between /lib/modules and /boot
This commit is contained in:
parent
8029ad2185
commit
4570e9adbe
39
kernel.go
39
kernel.go
@ -513,32 +513,34 @@ func installKernel(sk config.KernelMask, pkgname string, force, headers bool) (e
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func genKernelPath(files []os.FileInfo, kname string) string {
|
func findKernelFile(files []os.FileInfo, kname string) (name string, err error) {
|
||||||
for _, file := range files {
|
for _, file := range files {
|
||||||
if strings.HasPrefix(file.Name(), "vmlinuz") {
|
if strings.HasPrefix(file.Name(), "vmlinuz") {
|
||||||
if strings.Contains(file.Name(), kname) {
|
if strings.Contains(file.Name(), kname) {
|
||||||
return file.Name()
|
name = file.Name()
|
||||||
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Fatal().Msgf("cannot find kernel %s", kname)
|
err = errors.New("cannot find kernel")
|
||||||
return ""
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func genInitrdPath(files []os.FileInfo, kname string) string {
|
func findInitrdFile(files []os.FileInfo, kname string) (name string, err error) {
|
||||||
for _, file := range files {
|
for _, file := range files {
|
||||||
if strings.HasPrefix(file.Name(), "initrd") ||
|
if strings.HasPrefix(file.Name(), "initrd") ||
|
||||||
strings.HasPrefix(file.Name(), "initramfs") {
|
strings.HasPrefix(file.Name(), "initramfs") {
|
||||||
|
|
||||||
if strings.Contains(file.Name(), kname) {
|
if strings.Contains(file.Name(), kname) {
|
||||||
return file.Name()
|
name = file.Name()
|
||||||
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Fatal().Msgf("cannot find initrd %s", kname)
|
err = errors.New("cannot find kernel")
|
||||||
return ""
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func genRootfsImage(d containerImageInfo, download bool) (rootfs string, err error) {
|
func genRootfsImage(d containerImageInfo, download bool) (rootfs string, err error) {
|
||||||
@ -640,16 +642,29 @@ func listContainersKernels(dii containerImageInfo, newkcfg *config.KernelConfig,
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, krel := range moddirs {
|
for _, krel := range moddirs {
|
||||||
|
log.Debug().Msgf("generate config entry for %s", krel.Name())
|
||||||
|
|
||||||
|
var kernelFile, initrdFile string
|
||||||
|
kernelFile, err = findKernelFile(bootfiles, krel.Name())
|
||||||
|
if err != nil {
|
||||||
|
log.Warn().Msgf("cannot find kernel %s", krel.Name())
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
initrdFile, err = findInitrdFile(bootfiles, krel.Name())
|
||||||
|
if err != nil {
|
||||||
|
log.Warn().Msgf("cannot find initrd %s", krel.Name())
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
ki := config.KernelInfo{
|
ki := config.KernelInfo{
|
||||||
DistroType: dii.DistroType,
|
DistroType: dii.DistroType,
|
||||||
DistroRelease: dii.DistroRelease,
|
DistroRelease: dii.DistroRelease,
|
||||||
KernelRelease: krel.Name(),
|
KernelRelease: krel.Name(),
|
||||||
ContainerName: dii.Name,
|
ContainerName: dii.Name,
|
||||||
|
|
||||||
KernelPath: c.Volumes.Boot + "/" +
|
KernelPath: c.Volumes.Boot + "/" + kernelFile,
|
||||||
genKernelPath(bootfiles, krel.Name()),
|
InitrdPath: c.Volumes.Boot + "/" + initrdFile,
|
||||||
InitrdPath: c.Volumes.Boot + "/" +
|
|
||||||
genInitrdPath(bootfiles, krel.Name()),
|
|
||||||
ModulesPath: c.Volumes.LibModules + "/" + krel.Name(),
|
ModulesPath: c.Volumes.LibModules + "/" + krel.Name(),
|
||||||
|
|
||||||
RootFS: rootfs,
|
RootFS: rootfs,
|
||||||
|
@ -37,7 +37,7 @@ func genHostKernels(download bool) (kcfg config.KernelConfig, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
kernelsBase := "/boot/"
|
kernelsBase := "/boot/"
|
||||||
files, err := ioutil.ReadDir(kernelsBase)
|
bootfiles, err := ioutil.ReadDir(kernelsBase)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -55,20 +55,35 @@ func genHostKernels(download bool) (kcfg config.KernelConfig, err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, k := range strings.Fields(string(rawOutput)) {
|
for _, krel := range strings.Fields(string(rawOutput)) {
|
||||||
|
log.Debug().Msgf("generate config entry for %s", krel)
|
||||||
|
|
||||||
|
var kernelFile, initrdFile string
|
||||||
|
kernelFile, err = findKernelFile(bootfiles, krel)
|
||||||
|
if err != nil {
|
||||||
|
log.Warn().Msgf("cannot find kernel %s", krel)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
initrdFile, err = findInitrdFile(bootfiles, krel)
|
||||||
|
if err != nil {
|
||||||
|
log.Warn().Msgf("cannot find initrd %s", krel)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
ki := config.KernelInfo{
|
ki := config.KernelInfo{
|
||||||
DistroType: distroType,
|
DistroType: distroType,
|
||||||
DistroRelease: si.OS.Version,
|
DistroRelease: si.OS.Version,
|
||||||
KernelRelease: k,
|
KernelRelease: krel,
|
||||||
|
|
||||||
KernelSource: "/lib/modules/" + k + "/build",
|
KernelSource: "/lib/modules/" + krel + "/build",
|
||||||
|
|
||||||
KernelPath: kernelsBase + genKernelPath(files, k),
|
KernelPath: kernelsBase + kernelFile,
|
||||||
InitrdPath: kernelsBase + genInitrdPath(files, k),
|
InitrdPath: kernelsBase + initrdFile,
|
||||||
RootFS: rootfs,
|
RootFS: rootfs,
|
||||||
}
|
}
|
||||||
|
|
||||||
vmlinux := "/usr/lib/debug/boot/vmlinux-" + k
|
vmlinux := "/usr/lib/debug/boot/vmlinux-" + krel
|
||||||
log.Print("vmlinux", vmlinux)
|
log.Print("vmlinux", vmlinux)
|
||||||
if exists(vmlinux) {
|
if exists(vmlinux) {
|
||||||
ki.VmlinuxPath = vmlinux
|
ki.VmlinuxPath = vmlinux
|
||||||
|
Loading…
Reference in New Issue
Block a user