diff --git a/distro/debian/kernel.go b/distro/debian/kernel.go index 4bbe45d..53d7210 100644 --- a/distro/debian/kernel.go +++ b/distro/debian/kernel.go @@ -36,28 +36,16 @@ func GetDebianKernel(version string) (dk DebianKernel, err error) { regex := `^linux-(image|headers)-[a-z+~0-9\.\-]*-(amd64|amd64-unsigned)$` - pkgs, err := snapshot.Packages("linux", version, "amd64", regex) - if err != nil { - return + filter := []string{ + "rt-amd64", + "cloud-amd64", + "all-amd64", } - // FIXME correct regex - var packages []snapshot.Package - for _, p := range pkgs { - skip := false - for _, s := range []string{ - "rt-amd64", - "cloud-amd64", - "all-amd64", - } { - if strings.Contains(p.Name, s) { - skip = true - break - } - } - if !skip { - packages = append(packages, p) - } + packages, err := snapshot.Packages("linux", version, "amd64", + regex, filter) + if err != nil { + return } if len(packages) == 0 { diff --git a/distro/debian/snapshot/snapshot.go b/distro/debian/snapshot/snapshot.go index 1937ef8..58cb4a9 100644 --- a/distro/debian/snapshot/snapshot.go +++ b/distro/debian/snapshot/snapshot.go @@ -283,7 +283,18 @@ func contains(pkgs []Package, pkg Package) bool { return false } -func Packages(srcname, version, arch, regex string) (pkgs []Package, err error) { +func filtered(s string, filter []string) bool { + for _, f := range filter { + if strings.Contains(s, f) { + return true + } + } + return false +} + +func Packages(srcname, version, arch, regex string, + filter []string) (pkgs []Package, err error) { + binpkgs, err := mr.GetBinpackages(srcname, version) if err == mr.ErrNotFound { err = nil @@ -296,7 +307,7 @@ func Packages(srcname, version, arch, regex string) (pkgs []Package, err error) r := regexp.MustCompile(regex) for _, res := range binpkgs.Result { - if !r.MatchString(res.Name) { + if !r.MatchString(res.Name) || filtered(res.Name, filter) { continue }