From 7e050d9e9914c224e468af47b8df2f30100666bb Mon Sep 17 00:00:00 2001 From: Mikhail Klementev Date: Wed, 22 Mar 2023 18:21:21 +0000 Subject: [PATCH] Add command to install specific kernel --- kernel.go | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/kernel.go b/kernel.go index 226e4b3..917f214 100644 --- a/kernel.go +++ b/kernel.go @@ -32,6 +32,7 @@ type KernelCmd struct { List KernelListCmd `cmd:"" help:"list kernels"` Autogen KernelAutogenCmd `cmd:"" help:"generate kernels based on the current config"` Genall KernelGenallCmd `cmd:"" help:"generate all kernels for distro"` + Install KernelInstallCmd `cmd:"" help:"install specific kernel"` } type KernelListCmd struct{} @@ -108,6 +109,37 @@ func (cmd *KernelGenallCmd) Run(kernelCmd *KernelCmd, g *Globals) (err error) { return updateKernelsCfg(kernelCmd.UseHost, !kernelCmd.NoDownload) } +type KernelInstallCmd struct { + Distro string `required:"" help:"distribution"` + Ver string `required:"" help:"distro version"` + Kernel string `required:"" help:"kernel release mask"` +} + +func (cmd *KernelInstallCmd) Run(kernelCmd *KernelCmd, g *Globals) (err error) { + distroType, err := config.NewDistroType(cmd.Distro) + if err != nil { + return + } + + km := config.KernelMask{ + DistroType: distroType, + DistroRelease: cmd.Ver, + ReleaseMask: cmd.Kernel, + } + err = generateKernels(km, + g.Config.Docker.Registry, + g.Config.Docker.Commands, + math.MaxUint32, + !kernelCmd.NoDownload, + kernelCmd.Force, + ) + if err != nil { + return + } + + return updateKernelsCfg(kernelCmd.UseHost, !kernelCmd.NoDownload) +} + func matchDebianHeadersPkg(container, mask string, generic bool) ( pkgs []string, err error) {