feat: parameter to refetch kbuild
This commit is contained in:
parent
9271d69bc6
commit
e141f46892
2
.github/workflows/debian-cache.yml
vendored
2
.github/workflows/debian-cache.yml
vendored
@ -25,7 +25,7 @@ jobs:
|
|||||||
run: go build
|
run: go build
|
||||||
|
|
||||||
- name: Cache
|
- name: Cache
|
||||||
run: ./out-of-tree --log-level=trace distro debian cache --refetch=0 --limit=128 --update-release
|
run: ./out-of-tree --log-level=trace distro debian cache --refetch=0 --limit=128 --update-release --update-kbuild
|
||||||
|
|
||||||
- name: Install s3cmd
|
- name: Install s3cmd
|
||||||
run: sudo apt install s3cmd
|
run: sudo apt install s3cmd
|
||||||
|
@ -39,6 +39,7 @@ type DebianCacheCmd struct {
|
|||||||
Path string `help:"path to cache"`
|
Path string `help:"path to cache"`
|
||||||
Refetch int `help:"days before refetch versions without deb package" default:"7"`
|
Refetch int `help:"days before refetch versions without deb package" default:"7"`
|
||||||
UpdateRelease bool `help:"update release data"`
|
UpdateRelease bool `help:"update release data"`
|
||||||
|
UpdateKbuild bool `help:"update kbuild package"`
|
||||||
Dump bool `help:"dump cache"`
|
Dump bool `help:"dump cache"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,7 +57,10 @@ func (cmd *DebianCacheCmd) Run(dcmd *DebianCmd) (err error) {
|
|||||||
|
|
||||||
mode := debian.NoMode
|
mode := debian.NoMode
|
||||||
if cmd.UpdateRelease {
|
if cmd.UpdateRelease {
|
||||||
mode = debian.UpdateRelease
|
mode |= debian.UpdateRelease
|
||||||
|
}
|
||||||
|
if cmd.UpdateKbuild {
|
||||||
|
mode |= debian.UpdateKbuild
|
||||||
}
|
}
|
||||||
|
|
||||||
kernels, err := debian.GetKernelsWithLimit(dcmd.Limit, mode)
|
kernels, err := debian.GetKernelsWithLimit(dcmd.Limit, mode)
|
||||||
|
@ -278,6 +278,30 @@ func findKbuild(versions []string, kpkgver string) (
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func updateKbuild(toolsVersions []string, dk *DebianKernel) {
|
||||||
|
if !kver(dk.Version.Package).LessThan(kver("4.5-rc0")) {
|
||||||
|
dk.Internal.Invalid = true
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var deps []snapshot.Package
|
||||||
|
for _, pkg := range dk.Dependencies {
|
||||||
|
if strings.Contains(pkg.Name, "kbuild") {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
deps = append(deps, pkg)
|
||||||
|
}
|
||||||
|
dk.Dependencies = deps
|
||||||
|
|
||||||
|
kbuildpkg, err := findKbuild(toolsVersions, dk.Version.Package)
|
||||||
|
if err != nil {
|
||||||
|
dk.Internal.Invalid = true
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
dk.Dependencies = append(dk.Dependencies, kbuildpkg)
|
||||||
|
}
|
||||||
|
|
||||||
func getKernelsByVersion(slog zerolog.Logger, c *Cache, toolsVersions []string,
|
func getKernelsByVersion(slog zerolog.Logger, c *Cache, toolsVersions []string,
|
||||||
version string, mode GetKernelsMode) (kernels []DebianKernel,
|
version string, mode GetKernelsMode) (kernels []DebianKernel,
|
||||||
fromcache bool) {
|
fromcache bool) {
|
||||||
@ -287,6 +311,7 @@ func getKernelsByVersion(slog zerolog.Logger, c *Cache, toolsVersions []string,
|
|||||||
if err == nil {
|
if err == nil {
|
||||||
dk = dks[0]
|
dk = dks[0]
|
||||||
if !dk.Internal.Invalid {
|
if !dk.Internal.Invalid {
|
||||||
|
// TODO refactor
|
||||||
slog.Trace().Msgf("found in cache")
|
slog.Trace().Msgf("found in cache")
|
||||||
if dk.Release == None && mode&UpdateRelease != 0 {
|
if dk.Release == None && mode&UpdateRelease != 0 {
|
||||||
slog.Debug().Msg("update release")
|
slog.Debug().Msg("update release")
|
||||||
@ -300,6 +325,16 @@ func getKernelsByVersion(slog zerolog.Logger, c *Cache, toolsVersions []string,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if mode&UpdateKbuild != 0 {
|
||||||
|
slog.Debug().Msg("update kbuild")
|
||||||
|
updateKbuild(toolsVersions, &dk)
|
||||||
|
slog.Debug().Msg("update cache")
|
||||||
|
err = c.Put([]DebianKernel{dk})
|
||||||
|
if err != nil {
|
||||||
|
slog.Error().Err(err).Msg("")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
kernels = append(kernels, dk)
|
kernels = append(kernels, dk)
|
||||||
fromcache = true
|
fromcache = true
|
||||||
return
|
return
|
||||||
@ -326,26 +361,11 @@ func getKernelsByVersion(slog zerolog.Logger, c *Cache, toolsVersions []string,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !dk.HasDependency("kbuild") {
|
if !dk.HasDependency("kbuild") {
|
||||||
if !kver(dk.Version.Package).LessThan(kver("4.5-rc0")) {
|
|
||||||
dk.Internal.Invalid = true
|
|
||||||
} else {
|
|
||||||
// Debian kernels prior to the 4.5 package
|
// Debian kernels prior to the 4.5 package
|
||||||
// version did not have a kbuild built from
|
// version did not have a kbuild built from
|
||||||
// the linux source itself, but used the
|
// the linux source itself, but used the
|
||||||
// linux-tools source package.
|
// linux-tools source package.
|
||||||
kbuildpkg, err := findKbuild(
|
updateKbuild(toolsVersions, &dk)
|
||||||
toolsVersions,
|
|
||||||
dk.Version.Package,
|
|
||||||
)
|
|
||||||
if err != nil {
|
|
||||||
dk.Internal.Invalid = true
|
|
||||||
} else {
|
|
||||||
dk.Dependencies = append(
|
|
||||||
dk.Dependencies,
|
|
||||||
kbuildpkg,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dk.Internal.LastFetch = time.Now()
|
dk.Internal.LastFetch = time.Now()
|
||||||
@ -374,6 +394,7 @@ type GetKernelsMode int
|
|||||||
const (
|
const (
|
||||||
NoMode GetKernelsMode = iota
|
NoMode GetKernelsMode = iota
|
||||||
UpdateRelease
|
UpdateRelease
|
||||||
|
UpdateKbuild
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetKernelsWithLimit is workaround for testing and building the
|
// GetKernelsWithLimit is workaround for testing and building the
|
||||||
|
@ -23,7 +23,7 @@ func TestGetDebianKernel(t *testing.T) {
|
|||||||
func TestParseKernelVersion(t *testing.T) {
|
func TestParseKernelVersion(t *testing.T) {
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
|
|
||||||
kernels, err := GetKernels()
|
kernels, err := GetKernelsWithLimit(16, NoMode)
|
||||||
assert.Nil(err)
|
assert.Nil(err)
|
||||||
assert.NotEmpty(kernels)
|
assert.NotEmpty(kernels)
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ func TestParseKernelVersion(t *testing.T) {
|
|||||||
func TestKbuildVersion(t *testing.T) {
|
func TestKbuildVersion(t *testing.T) {
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
|
|
||||||
kernels, err := GetKernels()
|
kernels, err := GetKernelsWithLimit(16, NoMode)
|
||||||
assert.Nil(err)
|
assert.Nil(err)
|
||||||
assert.NotEmpty(kernels)
|
assert.NotEmpty(kernels)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user