feat: add kernels list to distro interface
This commit is contained in:
@ -58,6 +58,15 @@ func (centos CentOS) Packages() (pkgs []string, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func (centos CentOS) Kernels() (kernels []distro.KernelInfo, err error) {
|
||||
c, err := container.New(centos.Distro())
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
return c.Kernels()
|
||||
}
|
||||
|
||||
func (centos CentOS) envs() (envs []string) {
|
||||
return
|
||||
}
|
||||
|
@ -276,9 +276,18 @@ func (d Debian) runs() (commands []string) {
|
||||
return
|
||||
}
|
||||
|
||||
func ContainerKernels(d container.Image, kcfg *config.KernelConfig) (err error) {
|
||||
cpath := config.Dir("volumes", d.Name)
|
||||
rootfs := config.File("images", d.Name+".img")
|
||||
func (d Debian) Kernels() (kernels []distro.KernelInfo, err error) {
|
||||
c, err := container.New(d.Distro())
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if !c.Exist() {
|
||||
return
|
||||
}
|
||||
|
||||
cpath := config.Dir("volumes", c.Name())
|
||||
rootfs := config.File("images", c.Name()+".img")
|
||||
|
||||
files, err := os.ReadDir(cpath)
|
||||
if err != nil {
|
||||
@ -321,10 +330,10 @@ func ContainerKernels(d container.Image, kcfg *config.KernelConfig) (err error)
|
||||
release := strings.Replace(pkgname, "linux-image-", "", -1)
|
||||
|
||||
ki := distro.KernelInfo{
|
||||
Distro: d.Distro,
|
||||
Distro: d.Distro(),
|
||||
KernelVersion: path.Base(modules),
|
||||
KernelRelease: release,
|
||||
ContainerName: d.Name,
|
||||
ContainerName: c.Name(),
|
||||
|
||||
KernelPath: vmlinuz,
|
||||
InitrdPath: initrd,
|
||||
@ -333,7 +342,7 @@ func ContainerKernels(d container.Image, kcfg *config.KernelConfig) (err error)
|
||||
RootFS: rootfs,
|
||||
}
|
||||
|
||||
kcfg.Kernels = append(kcfg.Kernels, ki)
|
||||
kernels = append(kernels, ki)
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -11,6 +11,7 @@ type distribution interface {
|
||||
Distro() Distro
|
||||
Equal(Distro) bool
|
||||
Packages() (packages []string, err error)
|
||||
Kernels() (kernels []KernelInfo, err error)
|
||||
}
|
||||
|
||||
func Register(d distribution) {
|
||||
@ -52,3 +53,12 @@ func (d Distro) Packages() (packages []string, err error) {
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (d Distro) Kernels() (kernels []KernelInfo, err error) {
|
||||
for _, dd := range distros {
|
||||
if dd.Equal(d) {
|
||||
return dd.Kernels()
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
@ -59,6 +59,15 @@ func (ol OracleLinux) Packages() (pkgs []string, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func (ol OracleLinux) Kernels() (kernels []distro.KernelInfo, err error) {
|
||||
c, err := container.New(ol.Distro())
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
return c.Kernels()
|
||||
}
|
||||
|
||||
func (ol OracleLinux) envs() (envs []string) {
|
||||
return
|
||||
}
|
||||
|
@ -63,6 +63,15 @@ func (u Ubuntu) Packages() (pkgs []string, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func (u Ubuntu) Kernels() (kernels []distro.KernelInfo, err error) {
|
||||
c, err := container.New(u.Distro())
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
return c.Kernels()
|
||||
}
|
||||
|
||||
func (u Ubuntu) envs() (envs []string) {
|
||||
envs = append(envs, "DEBIAN_FRONTEND=noninteractive")
|
||||
return
|
||||
|
Reference in New Issue
Block a user