feat: less smart kbuild version guess
This commit is contained in:
parent
7942bd22fa
commit
9271d69bc6
@ -3,7 +3,6 @@ package debian
|
||||
import (
|
||||
"errors"
|
||||
"math"
|
||||
"sort"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@ -227,10 +226,6 @@ func getCachedKernel(deb string) (dk DebianKernel, err error) {
|
||||
}
|
||||
|
||||
func kbuildVersion(versions []string, kpkgver string) string {
|
||||
sort.Slice(versions, func(i, j int) bool {
|
||||
return kver(versions[i]).GreaterThan(kver(versions[j]))
|
||||
})
|
||||
|
||||
for _, v := range versions {
|
||||
if v == kpkgver {
|
||||
return v
|
||||
@ -254,12 +249,6 @@ func kbuildVersion(versions []string, kpkgver string) string {
|
||||
continue
|
||||
}
|
||||
|
||||
// Use the first version that is newer than the kernel
|
||||
|
||||
if ver.LessThan(cver) {
|
||||
continue
|
||||
}
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,8 @@ import (
|
||||
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"code.dumpstack.io/tools/out-of-tree/distro/debian/snapshot"
|
||||
)
|
||||
|
||||
func TestGetDebianKernel(t *testing.T) {
|
||||
@ -37,3 +39,29 @@ func TestParseKernelVersion(t *testing.T) {
|
||||
versions[dkv.Package] = true
|
||||
}
|
||||
}
|
||||
|
||||
func TestKbuildVersion(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
kernels, err := GetKernels()
|
||||
assert.Nil(err)
|
||||
assert.NotEmpty(kernels)
|
||||
|
||||
toolsVersions, err := snapshot.SourcePackageVersions("linux-tools")
|
||||
assert.Nil(err)
|
||||
|
||||
for _, dk := range kernels {
|
||||
if !kver(dk.Version.Package).LessThan(kver("4.5-rc0")) {
|
||||
continue
|
||||
}
|
||||
|
||||
version := kbuildVersion(
|
||||
toolsVersions,
|
||||
dk.Version.Package,
|
||||
)
|
||||
assert.Nil(err)
|
||||
assert.NotEmpty(version)
|
||||
|
||||
t.Log(dk.Version.Package, "->", version)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user