forked from ALHP/ALHP.GO
use lists for repo-actions
This commit is contained in:
24
main.go
24
main.go
@@ -189,7 +189,7 @@ func (b *BuildManager) buildWorker(id int, march string) {
|
||||
pkg.DbPackage.Update().SetStatus(dbpackage.StatusFailed).ClearSkipReason().SetBuildTimeStart(start).SetBuildTimeEnd(time.Now().UTC()).SetHash(pkg.Hash).ExecX(context.Background())
|
||||
|
||||
// purge failed package from repo
|
||||
b.repoPurge[pkg.FullRepo] <- pkg
|
||||
b.repoPurge[pkg.FullRepo] <- []*BuildPackage{pkg}
|
||||
|
||||
err = cleanBuildDir(buildDir)
|
||||
if err != nil {
|
||||
@@ -251,7 +251,7 @@ func (b *BuildManager) buildWorker(id int, march string) {
|
||||
}
|
||||
|
||||
log.Infof("[%s/%s/%s] Build successful (%s)", pkg.FullRepo, pkg.Pkgbase, pkg.Version, time.Since(start))
|
||||
b.repoAdd[pkg.FullRepo] <- pkg
|
||||
b.repoAdd[pkg.FullRepo] <- []*BuildPackage{pkg}
|
||||
|
||||
err = cleanBuildDir(buildDir)
|
||||
if err != nil {
|
||||
@@ -318,7 +318,7 @@ func (b *BuildManager) parseWorker() {
|
||||
pkg.DbPackage = pkg.DbPackage.Update().SetUpdated(time.Now()).SetVersion(pkg.Version).
|
||||
SetPackages(packages2slice(pkg.Srcinfo.Packages)).SetStatus(pkg.DbPackage.Status).
|
||||
SetSkipReason(pkg.DbPackage.SkipReason).SetHash(pkg.Hash).SaveX(context.Background())
|
||||
b.repoPurge[pkg.FullRepo] <- pkg
|
||||
b.repoPurge[pkg.FullRepo] <- []*BuildPackage{pkg}
|
||||
b.parseWG.Done()
|
||||
continue
|
||||
} else {
|
||||
@@ -347,13 +347,13 @@ func (b *BuildManager) parseWorker() {
|
||||
case MultiplePKGBUILDError:
|
||||
log.Infof("Skipped %s: Multiple PKGBUILDs for dependency found: %v", pkg.Srcinfo.Pkgbase, err)
|
||||
pkg.DbPackage = pkg.DbPackage.Update().SetStatus(dbpackage.StatusSkipped).SetSkipReason("multiple PKGBUILD for dep. found").SaveX(context.Background())
|
||||
b.repoPurge[pkg.FullRepo] <- pkg
|
||||
b.repoPurge[pkg.FullRepo] <- []*BuildPackage{pkg}
|
||||
b.parseWG.Done()
|
||||
continue
|
||||
case UnableToSatisfyError:
|
||||
log.Infof("Skipped %s: unable to resolve dependencies: %v", pkg.Srcinfo.Pkgbase, err)
|
||||
pkg.DbPackage = pkg.DbPackage.Update().SetStatus(dbpackage.StatusSkipped).SetSkipReason("unable to resolve dependencies").SaveX(context.Background())
|
||||
b.repoPurge[pkg.FullRepo] <- pkg
|
||||
b.repoPurge[pkg.FullRepo] <- []*BuildPackage{pkg}
|
||||
b.parseWG.Done()
|
||||
continue
|
||||
}
|
||||
@@ -374,7 +374,7 @@ func (b *BuildManager) parseWorker() {
|
||||
// Worst case would be clients downloading a package update twice, once from their official mirror,
|
||||
// and then after build from ALHP. Best case we prevent a not buildable package from staying in the repos
|
||||
// in an outdated version.
|
||||
b.repoPurge[pkg.FullRepo] <- pkg
|
||||
b.repoPurge[pkg.FullRepo] <- []*BuildPackage{pkg}
|
||||
b.parseWG.Done()
|
||||
continue
|
||||
}
|
||||
@@ -541,7 +541,8 @@ func (b *BuildManager) htmlWorker() {
|
||||
func (b *BuildManager) repoWorker(repo string) {
|
||||
for {
|
||||
select {
|
||||
case pkg := <-b.repoAdd[repo]:
|
||||
case pkgL := <-b.repoAdd[repo]:
|
||||
for _, pkg := range pkgL {
|
||||
args := []string{"-s", "-v", "-p", "-n", filepath.Join(conf.Basedir.Repo, pkg.FullRepo, "os", conf.Arch, pkg.FullRepo) + ".db.tar.xz"}
|
||||
args = append(args, pkg.PkgFiles...)
|
||||
cmd := exec.Command("repo-add", args...)
|
||||
@@ -562,7 +563,9 @@ func (b *BuildManager) repoWorker(repo string) {
|
||||
check(err)
|
||||
updateLastUpdated()
|
||||
b.buildWG.Done()
|
||||
case pkg := <-b.repoPurge[repo]:
|
||||
}
|
||||
case pkgL := <-b.repoPurge[repo]:
|
||||
for _, pkg := range pkgL {
|
||||
if _, err := os.Stat(filepath.Join(conf.Basedir.Repo, pkg.FullRepo, "os", conf.Arch, pkg.FullRepo) + ".db.tar.xz"); err != nil {
|
||||
continue
|
||||
}
|
||||
@@ -603,6 +606,7 @@ func (b *BuildManager) repoWorker(repo string) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (b *BuildManager) syncWorker() {
|
||||
check(os.MkdirAll(filepath.Join(conf.Basedir.Work, upstreamDir), 0755))
|
||||
@@ -784,8 +788,8 @@ func main() {
|
||||
buildManager = &BuildManager{
|
||||
build: make(map[string]chan *BuildPackage),
|
||||
parse: make(chan *BuildPackage, 10000),
|
||||
repoPurge: make(map[string]chan *BuildPackage),
|
||||
repoAdd: make(map[string]chan *BuildPackage),
|
||||
repoPurge: make(map[string]chan []*BuildPackage),
|
||||
repoAdd: make(map[string]chan []*BuildPackage),
|
||||
exit: false,
|
||||
}
|
||||
|
||||
|
14
utils.go
14
utils.go
@@ -67,8 +67,8 @@ type BuildPackage struct {
|
||||
type BuildManager struct {
|
||||
build map[string]chan *BuildPackage
|
||||
parse chan *BuildPackage
|
||||
repoPurge map[string]chan *BuildPackage
|
||||
repoAdd map[string]chan *BuildPackage
|
||||
repoPurge map[string]chan []*BuildPackage
|
||||
repoAdd map[string]chan []*BuildPackage
|
||||
exit bool
|
||||
buildWG sync.WaitGroup
|
||||
parseWG sync.WaitGroup
|
||||
@@ -710,7 +710,7 @@ func housekeeping(repo string, wg *sync.WaitGroup) error {
|
||||
PkgFiles: []string{path},
|
||||
March: mPackage.MArch(),
|
||||
}
|
||||
buildManager.repoPurge[pkg.FullRepo] <- pkg
|
||||
buildManager.repoPurge[pkg.FullRepo] <- []*BuildPackage{pkg}
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -742,7 +742,7 @@ func housekeeping(repo string, wg *sync.WaitGroup) error {
|
||||
if err != nil || pkgResolved.DB().Name() != pkg.DbPackage.Repository.String() || pkgResolved.DB().Name() != pkg.Repo.String() {
|
||||
// package not found on mirror/db -> not part of any repo anymore
|
||||
log.Infof("[HK/%s/%s] not included in repo", pkg.FullRepo, pkg.Pkgbase)
|
||||
buildManager.repoPurge[pkg.FullRepo] <- pkg
|
||||
buildManager.repoPurge[pkg.FullRepo] <- []*BuildPackage{pkg}
|
||||
err = db.DbPackage.DeleteOne(pkg.DbPackage).Exec(context.Background())
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -757,7 +757,7 @@ func housekeeping(repo string, wg *sync.WaitGroup) error {
|
||||
}
|
||||
if !valid {
|
||||
log.Infof("[HK/%s/%s] invalid package signature", pkg.FullRepo, pkg.Pkgbase)
|
||||
buildManager.repoPurge[pkg.FullRepo] <- pkg
|
||||
buildManager.repoPurge[pkg.FullRepo] <- []*BuildPackage{pkg}
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -861,8 +861,8 @@ func syncMarchs() {
|
||||
for _, repo := range conf.Repos {
|
||||
fRepo := fmt.Sprintf("%s-%s", repo, march)
|
||||
repos = append(repos, fRepo)
|
||||
buildManager.repoAdd[fRepo] = make(chan *BuildPackage, conf.Build.Worker)
|
||||
buildManager.repoPurge[fRepo] = make(chan *BuildPackage, 10000)
|
||||
buildManager.repoAdd[fRepo] = make(chan []*BuildPackage, conf.Build.Worker)
|
||||
buildManager.repoPurge[fRepo] = make(chan []*BuildPackage, 10000)
|
||||
go buildManager.repoWorker(fRepo)
|
||||
|
||||
if _, err := os.Stat(filepath.Join(filepath.Join(conf.Basedir.Repo, fRepo, "os", conf.Arch))); os.IsNotExist(err) {
|
||||
|
Reference in New Issue
Block a user