feat: introduce kernel version
This commit is contained in:
parent
de5ebd6455
commit
1b2d636410
@ -276,6 +276,8 @@ type KernelInfo struct {
|
||||
DistroRelease string // 18.04/7.4.1708/9.1
|
||||
|
||||
// Must be *exactly* same as in `uname -r`
|
||||
KernelVersion string
|
||||
|
||||
KernelRelease string
|
||||
|
||||
// Build-time information
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strings"
|
||||
@ -228,10 +229,10 @@ func ContainerCommands(km config.KernelMask) (commands []string) {
|
||||
}
|
||||
|
||||
func ContainerKernels(d container.Image, kcfg *config.KernelConfig) (err error) {
|
||||
path := config.Dir("volumes", d.Name)
|
||||
cpath := config.Dir("volumes", d.Name)
|
||||
rootfs := config.File("images", d.Name+".img")
|
||||
|
||||
files, err := os.ReadDir(path)
|
||||
files, err := os.ReadDir(cpath)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@ -243,7 +244,7 @@ func ContainerKernels(d container.Image, kcfg *config.KernelConfig) (err error)
|
||||
|
||||
pkgname := file.Name()
|
||||
|
||||
kpkgdir := filepath.Join(path, pkgname)
|
||||
kpkgdir := filepath.Join(cpath, pkgname)
|
||||
|
||||
bootdir := filepath.Join(kpkgdir, "boot")
|
||||
|
||||
@ -269,10 +270,13 @@ func ContainerKernels(d container.Image, kcfg *config.KernelConfig) (err error)
|
||||
|
||||
log.Debug().Msgf("%s %s %s", vmlinuz, initrd, modules)
|
||||
|
||||
release := strings.Replace(pkgname, "linux-image-", "", -1)
|
||||
|
||||
ki := config.KernelInfo{
|
||||
DistroType: d.DistroType,
|
||||
DistroRelease: d.DistroRelease,
|
||||
KernelRelease: pkgname,
|
||||
KernelVersion: path.Base(modules),
|
||||
KernelRelease: release,
|
||||
ContainerName: d.Name,
|
||||
|
||||
KernelPath: vmlinuz,
|
||||
|
@ -603,6 +603,7 @@ func listContainersKernels(dii container.Image, newkcfg *config.KernelConfig,
|
||||
ki := config.KernelInfo{
|
||||
DistroType: dii.DistroType,
|
||||
DistroRelease: dii.DistroRelease,
|
||||
KernelVersion: krel.Name(),
|
||||
KernelRelease: krel.Name(),
|
||||
ContainerName: dii.Name,
|
||||
|
||||
|
6
pew.go
6
pew.go
@ -258,7 +258,11 @@ func build(flog zerolog.Logger, tmp string, ka config.Artifact,
|
||||
outpath += ".ko"
|
||||
}
|
||||
|
||||
kernel := "/lib/modules/" + ki.KernelRelease + "/build"
|
||||
if ki.KernelVersion == "" {
|
||||
ki.KernelVersion = ki.KernelRelease
|
||||
}
|
||||
|
||||
kernel := "/lib/modules/" + ki.KernelVersion + "/build"
|
||||
if ki.KernelSource != "" {
|
||||
kernel = ki.KernelSource
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user