feat: show amount of kernels failed to install
This commit is contained in:
parent
603f1c3654
commit
022ced0eba
35
kernel.go
35
kernel.go
@ -7,7 +7,6 @@ package main
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math"
|
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@ -31,6 +30,7 @@ type KernelCmd struct {
|
|||||||
Retries int `help:"amount of tries for each kernel" default:"2"`
|
Retries int `help:"amount of tries for each kernel" default:"2"`
|
||||||
Threads int `help:"threads for parallel installation" default:"1"`
|
Threads int `help:"threads for parallel installation" default:"1"`
|
||||||
Update bool `help:"update container"`
|
Update bool `help:"update container"`
|
||||||
|
Max int `help:"maximum kernels to download" default:"100500"`
|
||||||
|
|
||||||
List KernelListCmd `cmd:"" help:"list kernels"`
|
List KernelListCmd `cmd:"" help:"list kernels"`
|
||||||
ListRemote KernelListRemoteCmd `cmd:"" help:"list remote kernels"`
|
ListRemote KernelListRemoteCmd `cmd:"" help:"list remote kernels"`
|
||||||
@ -41,9 +41,20 @@ type KernelCmd struct {
|
|||||||
|
|
||||||
shutdown bool
|
shutdown bool
|
||||||
kcfg config.KernelConfig
|
kcfg config.KernelConfig
|
||||||
|
|
||||||
|
stats struct {
|
||||||
|
overall int
|
||||||
|
success int
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cmd KernelCmd) UpdateConfig() (err error) {
|
func (cmd KernelCmd) UpdateConfig() (err error) {
|
||||||
|
if cmd.stats.success != cmd.stats.overall {
|
||||||
|
log.Warn().Msgf("%d kernels failed to install",
|
||||||
|
cmd.stats.overall-cmd.stats.success)
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Info().Msgf("updating kernels.toml")
|
||||||
kcfg := config.KernelConfig{}
|
kcfg := config.KernelConfig{}
|
||||||
|
|
||||||
if cmd.UseHost {
|
if cmd.UseHost {
|
||||||
@ -78,7 +89,7 @@ func (cmd KernelCmd) UpdateConfig() (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cmd *KernelCmd) GenKernel(km config.Target, pkg string, max *int) {
|
func (cmd *KernelCmd) GenKernel(km config.Target, pkg string) {
|
||||||
flog := log.With().
|
flog := log.With().
|
||||||
Str("kernel", pkg).
|
Str("kernel", pkg).
|
||||||
Str("distro", km.Distro.String()).
|
Str("distro", km.Distro.String()).
|
||||||
@ -119,7 +130,7 @@ func (cmd *KernelCmd) GenKernel(km config.Target, pkg string, max *int) {
|
|||||||
|
|
||||||
err := km.Distro.Install(pkg, !cmd.NoHeaders)
|
err := km.Distro.Install(pkg, !cmd.NoHeaders)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
*max--
|
cmd.stats.success += 1
|
||||||
flog.Info().Msg("success")
|
flog.Info().Msg("success")
|
||||||
break
|
break
|
||||||
} else if attempt >= cmd.Retries {
|
} else if attempt >= cmd.Retries {
|
||||||
@ -134,7 +145,7 @@ func (cmd *KernelCmd) GenKernel(km config.Target, pkg string, max *int) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cmd *KernelCmd) Generate(g *Globals, km config.Target, max int) (err error) {
|
func (cmd *KernelCmd) Generate(g *Globals, km config.Target) (err error) {
|
||||||
if cmd.Update {
|
if cmd.Update {
|
||||||
container.Update = true
|
container.Update = true
|
||||||
}
|
}
|
||||||
@ -180,17 +191,19 @@ func (cmd *KernelCmd) Generate(g *Globals, km config.Target, max int) (err error
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if max <= 0 {
|
if cmd.stats.success >= cmd.Max {
|
||||||
log.Print("Max is reached")
|
log.Print("Max is reached")
|
||||||
swg.Done()
|
swg.Done()
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cmd.stats.overall += 1
|
||||||
|
|
||||||
log.Info().Msgf("%d/%d %s", i+1, len(pkgs), pkg)
|
log.Info().Msgf("%d/%d %s", i+1, len(pkgs), pkg)
|
||||||
|
|
||||||
go func(p string) {
|
go func(p string) {
|
||||||
defer swg.Done()
|
defer swg.Done()
|
||||||
cmd.GenKernel(km, p, &max)
|
cmd.GenKernel(km, p)
|
||||||
}(pkg)
|
}(pkg)
|
||||||
}
|
}
|
||||||
swg.Wait()
|
swg.Wait()
|
||||||
@ -251,9 +264,7 @@ func (cmd *KernelListRemoteCmd) Run(kernelCmd *KernelCmd, g *Globals) (err error
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
type KernelAutogenCmd struct {
|
type KernelAutogenCmd struct{}
|
||||||
Max int `help:"download kernels from set defined by regex in release_mask, but no more than X for each of release_mask" default:"100500"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (cmd KernelAutogenCmd) Run(kernelCmd *KernelCmd, g *Globals) (err error) {
|
func (cmd KernelAutogenCmd) Run(kernelCmd *KernelCmd, g *Globals) (err error) {
|
||||||
ka, err := config.ReadArtifactConfig(g.WorkDir + "/.out-of-tree.toml")
|
ka, err := config.ReadArtifactConfig(g.WorkDir + "/.out-of-tree.toml")
|
||||||
@ -269,7 +280,7 @@ func (cmd KernelAutogenCmd) Run(kernelCmd *KernelCmd, g *Globals) (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err = kernelCmd.Generate(g, sk, cmd.Max)
|
err = kernelCmd.Generate(g, sk)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -308,7 +319,7 @@ func (cmd *KernelGenallCmd) Run(kernelCmd *KernelCmd, g *Globals) (err error) {
|
|||||||
Kernel: config.Kernel{Regex: ".*"},
|
Kernel: config.Kernel{Regex: ".*"},
|
||||||
}
|
}
|
||||||
|
|
||||||
err = kernelCmd.Generate(g, target, math.MaxUint32)
|
err = kernelCmd.Generate(g, target)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -335,7 +346,7 @@ func (cmd *KernelInstallCmd) Run(kernelCmd *KernelCmd, g *Globals) (err error) {
|
|||||||
Distro: distro.Distro{ID: distroType, Release: cmd.Ver},
|
Distro: distro.Distro{ID: distroType, Release: cmd.Ver},
|
||||||
Kernel: config.Kernel{Regex: cmd.Kernel},
|
Kernel: config.Kernel{Regex: cmd.Kernel},
|
||||||
}
|
}
|
||||||
err = kernelCmd.Generate(g, km, math.MaxUint32)
|
err = kernelCmd.Generate(g, km)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
3
pack.go
3
pack.go
@ -48,10 +48,11 @@ func (cmd *PackCmd) Run(g *Globals) (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if cmd.Autogen {
|
if cmd.Autogen {
|
||||||
err = KernelAutogenCmd{Max: cmd.Max}.Run(
|
err = KernelAutogenCmd{}.Run(
|
||||||
&KernelCmd{
|
&KernelCmd{
|
||||||
NoDownload: cmd.NoDownload,
|
NoDownload: cmd.NoDownload,
|
||||||
UseHost: cmd.UseHost,
|
UseHost: cmd.UseHost,
|
||||||
|
Max: cmd.Max,
|
||||||
},
|
},
|
||||||
&Globals{
|
&Globals{
|
||||||
Config: g.Config,
|
Config: g.Config,
|
||||||
|
Loading…
Reference in New Issue
Block a user