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) {