feat: support for excluding kernels using regex
This commit is contained in:
parent
0dceacd2df
commit
1a9fdf0917
@ -24,7 +24,8 @@ type Kernel struct {
|
||||
// To string
|
||||
|
||||
// prev. ReleaseMask
|
||||
Regex string
|
||||
Regex string
|
||||
ExcludeRegex string
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
|
||||
|
@ -33,10 +33,21 @@ func MatchPackages(km config.Target) (packages []string, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
exr, err := regexp.Compile(km.Kernel.ExcludeRegex)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
for _, pkg := range pkgs {
|
||||
if r.MatchString(pkg) {
|
||||
packages = append(packages, pkg)
|
||||
if !r.MatchString(pkg) {
|
||||
continue
|
||||
}
|
||||
|
||||
if km.Kernel.ExcludeRegex != "" && exr.MatchString(pkg) {
|
||||
continue
|
||||
}
|
||||
|
||||
packages = append(packages, pkg)
|
||||
}
|
||||
|
||||
return
|
||||
|
Loading…
Reference in New Issue
Block a user