add glob matching for no-build list

This commit is contained in:
Giovanni Harting 2024-06-22 20:02:26 +02:00
parent b510954115
commit 38a7b6562c
3 changed files with 27 additions and 9 deletions

View File

@ -88,7 +88,7 @@ func (b *BuildManager) buildQueue(ctx context.Context, queue []*ProtoPackage) er
b.buildingLock.RUnlock()
// check if package can be build right now
if !unknownBuilds && currentMemLoad+(datasize.ByteSize(*pkg.DBPackage.MaxRss)*datasize.KB) > conf.Build.MemoryLimit {
if currentMemLoad+(datasize.ByteSize(*pkg.DBPackage.MaxRss)*datasize.KB) > conf.Build.MemoryLimit {
log.Debugf("[Q] skipped package with max_rss %s while load %s: %s->%s",
datasize.ByteSize(*pkg.DBPackage.MaxRss)*datasize.KB, currentMemLoad, pkg.Pkgbase, pkg.March)
continue
@ -291,8 +291,7 @@ func (b *BuildManager) syncWorker(ctx context.Context) error {
for _, repo := range repos {
wg.Add(1)
splitRepo := strings.Split(repo, "-")
repo := repo
go func() {
go func() { //nolint:contextcheck
err := housekeeping(splitRepo[0], strings.Join(splitRepo[1:], "-"), wg)
if err != nil {
log.Warningf("[%s] housekeeping failed: %v", repo, err)
@ -301,7 +300,7 @@ func (b *BuildManager) syncWorker(ctx context.Context) error {
}
wg.Wait()
err := logHK()
err := logHK() //nolint:contextcheck
if err != nil {
log.Warningf("log-housekeeping failed: %v", err)
}
@ -331,7 +330,7 @@ func (b *BuildManager) syncWorker(ctx context.Context) error {
}
b.alpmMutex.Unlock()
queue, err := b.genQueue()
queue, err := b.genQueue() //nolint:contextcheck
if err != nil {
log.Errorf("error building queue: %v", err)
} else {
@ -344,7 +343,7 @@ func (b *BuildManager) syncWorker(ctx context.Context) error {
if ctx.Err() == nil {
for _, repo := range repos {
err = movePackagesLive(repo)
err = movePackagesLive(repo) //nolint:contextcheck
if err != nil {
log.Errorf("[%s] error moving packages live: %v", repo, err)
}

View File

@ -43,6 +43,11 @@ var (
)
func (p *ProtoPackage) isEligible(ctx context.Context) bool {
globMatch, err := MatchGlobList(p.Pkgbase, conf.Blacklist.Packages)
if err != nil {
log.Errorf("error parsing blob from no-build list: %v", err)
}
skipping := false
switch {
case p.Arch == "any":
@ -50,8 +55,8 @@ func (p *ProtoPackage) isEligible(ctx context.Context) bool {
p.DBPackage.SkipReason = "arch = any"
p.DBPackage.Status = dbpackage.StatusSkipped
skipping = true
case Contains(conf.Blacklist.Packages, p.Pkgbase):
log.Debugf("skipped %s: blacklisted package", p.Pkgbase)
case globMatch:
log.Debugf("skipped %s: package on no-build list", p.Pkgbase)
p.DBPackage.SkipReason = "blacklisted"
p.DBPackage.Status = dbpackage.StatusSkipped
skipping = true
@ -79,7 +84,7 @@ func (p *ProtoPackage) isEligible(ctx context.Context) bool {
repoVer, err := p.repoVersion()
if err != nil {
p.DBPackage = p.DBPackage.Update().ClearRepoVersion().SaveX(ctx)
} else if err == nil && alpm.VerCmp(repoVer, p.Version) > 0 {
} else if alpm.VerCmp(repoVer, p.Version) > 0 {
log.Debugf("skipped %s: version in repo higher than in PKGBUILD (%s < %s)", p.Pkgbase, p.Version, repoVer)
p.DBPackage = p.DBPackage.Update().SetStatus(dbpackage.StatusLatest).ClearSkipReason().SetTagRev(p.State.TagRev).SaveX(ctx)
return false

View File

@ -7,6 +7,7 @@ import (
paconf "github.com/Morganamilo/go-pacmanconf"
"github.com/Morganamilo/go-srcinfo"
"github.com/c2h5oh/datasize"
"github.com/gobwas/glob"
log "github.com/sirupsen/logrus"
"gopkg.in/yaml.v2"
"io/fs"
@ -657,3 +658,16 @@ func (globs Globs) Expand() ([]string, error) {
return matches, nil
}
func MatchGlobList(target string, globs []string) (bool, error) {
for _, lGlob := range globs {
tGlob, err := glob.Compile(lGlob)
if err != nil {
return false, fmt.Errorf("failed to compile glob %s: %w", lGlob, err)
}
if tGlob.Match(target) {
return true, nil
}
}
return false, nil
}