1
0

feat: support for excluding kernels using regex

This commit is contained in:
dump_stack() 2023-05-25 18:35:27 +00:00
parent 0dceacd2df
commit 1a9fdf0917
Signed by: dump_stack
GPG Key ID: BE44DA8C062D87DC
2 changed files with 34 additions and 4 deletions

View File

@ -24,7 +24,8 @@ type Kernel struct {
// To string // To string
// prev. ReleaseMask // prev. ReleaseMask
Regex string Regex string
ExcludeRegex string
} }
// Target defines the kernel // Target defines the kernel
@ -178,7 +179,25 @@ func (ka Artifact) checkSupport(ki distro.KernelInfo, target Target) (
} }
} }
supported, err = regexp.MatchString(target.Kernel.Regex, ki.KernelRelease) r, err := regexp.Compile(target.Kernel.Regex)
if err != nil {
return
}
exr, err := regexp.Compile(target.Kernel.ExcludeRegex)
if err != nil {
return
}
if !r.MatchString(ki.KernelRelease) {
return
}
if target.Kernel.ExcludeRegex != "" && exr.MatchString(ki.KernelRelease) {
return
}
supported = true
return return
} }

View File

@ -33,10 +33,21 @@ func MatchPackages(km config.Target) (packages []string, err error) {
return return
} }
exr, err := regexp.Compile(km.Kernel.ExcludeRegex)
if err != nil {
return
}
for _, pkg := range pkgs { for _, pkg := range pkgs {
if r.MatchString(pkg) { if !r.MatchString(pkg) {
packages = append(packages, pkg) continue
} }
if km.Kernel.ExcludeRegex != "" && exr.MatchString(pkg) {
continue
}
packages = append(packages, pkg)
} }
return return