feat: match only stable debian releases, backports, and updates
This commit is contained in:
parent
dce7546dd2
commit
013fb42350
@ -133,6 +133,18 @@ func (cn Release) String() string {
|
|||||||
|
|
||||||
func ReleaseFromString(s string) (r Release) {
|
func ReleaseFromString(s string) (r Release) {
|
||||||
switch strings.ToLower(s) {
|
switch strings.ToLower(s) {
|
||||||
|
case "1", "buzz":
|
||||||
|
r = Buzz
|
||||||
|
case "2", "hamm":
|
||||||
|
r = Hamm
|
||||||
|
case "3", "woody":
|
||||||
|
r = Woody
|
||||||
|
case "4", "etch":
|
||||||
|
r = Etch
|
||||||
|
case "5", "lenny":
|
||||||
|
r = Lenny
|
||||||
|
case "6", "squeeze":
|
||||||
|
r = Squeeze
|
||||||
case "7", "wheezy":
|
case "7", "wheezy":
|
||||||
r = Wheezy
|
r = Wheezy
|
||||||
case "8", "jessie":
|
case "8", "jessie":
|
||||||
|
@ -125,24 +125,7 @@ func getDebianKernel(version string) (dk DebianKernel, err error) {
|
|||||||
s := strings.Replace(dk.Image.Name, "linux-image-", "", -1)
|
s := strings.Replace(dk.Image.Name, "linux-image-", "", -1)
|
||||||
dk.Version.ABI = strings.Replace(s, "-amd64", "", -1)
|
dk.Version.ABI = strings.Replace(s, "-amd64", "", -1)
|
||||||
|
|
||||||
p := dk.Image
|
dk.Release = getRelease(dk.Image)
|
||||||
repos, err := metasnap.GetRepos(p.Repo.Archive, p.Name, p.Arch, version)
|
|
||||||
if err != nil {
|
|
||||||
flog.Debug().Err(err).Msg("ignore metasnap")
|
|
||||||
err = nil
|
|
||||||
}
|
|
||||||
for _, repo := range repos {
|
|
||||||
for _, release := range ReleaseStrings[1:] {
|
|
||||||
if strings.Contains(repo.Suite, release) {
|
|
||||||
dk.Release = ReleaseFromString(release)
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if dk.Release != None {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if dk.Release == None {
|
if dk.Release == None {
|
||||||
flog.Warn().Msg("release not found")
|
flog.Warn().Msg("release not found")
|
||||||
} else {
|
} else {
|
||||||
@ -152,6 +135,25 @@ func getDebianKernel(version string) (dk DebianKernel, err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getRelease(p snapshot.Package) Release {
|
||||||
|
repos, err := metasnap.GetRepos(p.Repo.Archive, p.Name, p.Arch, p.Version)
|
||||||
|
if err != nil {
|
||||||
|
log.Debug().Err(err).Msg("metasnap")
|
||||||
|
return None
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, repo := range repos {
|
||||||
|
for _, rel := range ReleaseStrings[1:] {
|
||||||
|
switch repo.Suite {
|
||||||
|
case rel, rel + "-backports", rel + "-updates":
|
||||||
|
return ReleaseFromString(rel)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return None
|
||||||
|
}
|
||||||
|
|
||||||
// GetCachedKernel by deb package name
|
// GetCachedKernel by deb package name
|
||||||
func getCachedKernel(deb string) (dk DebianKernel, err error) {
|
func getCachedKernel(deb string) (dk DebianKernel, err error) {
|
||||||
c, err := NewCache(CachePath)
|
c, err := NewCache(CachePath)
|
||||||
|
@ -4,17 +4,16 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/davecgh/go-spew/spew"
|
"github.com/davecgh/go-spew/spew"
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestGetDebianKernel(t *testing.T) {
|
func TestGetDebianKernel(t *testing.T) {
|
||||||
dk, err := getDebianKernel("4.17.14-1")
|
assert := assert.New(t)
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if dk.Version.ABI != "4.17.0-2" {
|
dk, err := getDebianKernel("4.6.4-1")
|
||||||
t.Fatalf("wrong abi")
|
assert.Nil(err)
|
||||||
}
|
|
||||||
|
assert.Equal(getRelease(dk.Image), Stretch)
|
||||||
|
|
||||||
t.Logf("%s", spew.Sdump(dk))
|
t.Logf("%s", spew.Sdump(dk))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user