forked from ALHP/ALHP.GO
parse all packages right on start. output coverage stats.
This commit is contained in:
@@ -11,6 +11,7 @@ KillMode=mixed
|
|||||||
TimeoutStopSec=5min
|
TimeoutStopSec=5min
|
||||||
MemoryHigh=30G
|
MemoryHigh=30G
|
||||||
CPUQuota=700%
|
CPUQuota=700%
|
||||||
|
Nice=15
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
46
main.go
46
main.go
@@ -57,10 +57,15 @@ type BuildManager struct {
|
|||||||
toPurge chan *BuildPackage
|
toPurge chan *BuildPackage
|
||||||
toRepoAdd chan *BuildPackage
|
toRepoAdd chan *BuildPackage
|
||||||
exit bool
|
exit bool
|
||||||
wg sync.WaitGroup
|
buildWG sync.WaitGroup
|
||||||
|
parseWG sync.WaitGroup
|
||||||
failedMutex sync.RWMutex
|
failedMutex sync.RWMutex
|
||||||
buildProcesses []*os.Process
|
buildProcesses []*os.Process
|
||||||
buildProcMutex sync.RWMutex
|
buildProcMutex sync.RWMutex
|
||||||
|
stats struct {
|
||||||
|
fullyBuild int
|
||||||
|
eligible int
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type Conf struct {
|
type Conf struct {
|
||||||
@@ -243,7 +248,7 @@ func (b *BuildManager) buildWorker(id int) {
|
|||||||
log.Infof("Worker %d exited...", id)
|
log.Infof("Worker %d exited...", id)
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
b.wg.Add(1)
|
b.buildWG.Add(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
@@ -281,7 +286,7 @@ func (b *BuildManager) buildWorker(id int) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
if b.exit {
|
if b.exit {
|
||||||
gitClean(pkg)
|
gitClean(pkg)
|
||||||
b.wg.Done()
|
b.buildWG.Done()
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -305,7 +310,7 @@ func (b *BuildManager) buildWorker(id int) {
|
|||||||
check(os.WriteFile(filepath.Join(conf.Basedir.Repo, "logs", pkg.Pkgbase+".log"), out.Bytes(), os.ModePerm))
|
check(os.WriteFile(filepath.Join(conf.Basedir.Repo, "logs", pkg.Pkgbase+".log"), out.Bytes(), os.ModePerm))
|
||||||
|
|
||||||
gitClean(pkg)
|
gitClean(pkg)
|
||||||
b.wg.Done()
|
b.buildWG.Done()
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -317,7 +322,7 @@ func (b *BuildManager) buildWorker(id int) {
|
|||||||
log.Warningf("No packages found after building %s. Abort build.", pkg.Pkgbase)
|
log.Warningf("No packages found after building %s. Abort build.", pkg.Pkgbase)
|
||||||
|
|
||||||
gitClean(pkg)
|
gitClean(pkg)
|
||||||
b.wg.Done()
|
b.buildWG.Done()
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -327,7 +332,7 @@ func (b *BuildManager) buildWorker(id int) {
|
|||||||
log.Debug(string(res))
|
log.Debug(string(res))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warningf("Failed to sign %s: %s", pkg.Pkgbase, err)
|
log.Warningf("Failed to sign %s: %s", pkg.Pkgbase, err)
|
||||||
b.wg.Done()
|
b.buildWG.Done()
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -339,7 +344,7 @@ func (b *BuildManager) buildWorker(id int) {
|
|||||||
_, err = copyFile(file, filepath.Join(conf.Basedir.Repo, pkg.FullRepo, "os", conf.Arch, filepath.Base(file)))
|
_, err = copyFile(file, filepath.Join(conf.Basedir.Repo, pkg.FullRepo, "os", conf.Arch, filepath.Base(file)))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
check(err)
|
check(err)
|
||||||
b.wg.Done()
|
b.buildWG.Done()
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -370,12 +375,14 @@ func (b *BuildManager) parseWorker() {
|
|||||||
res, err := cmd.Output()
|
res, err := cmd.Output()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warningf("Failed generate SRCINFO for %s: %v", pkg.Pkgbase, err)
|
log.Warningf("Failed generate SRCINFO for %s: %v", pkg.Pkgbase, err)
|
||||||
|
b.parseWG.Done()
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
info, err := srcinfo.Parse(string(res))
|
info, err := srcinfo.Parse(string(res))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warningf("Failed to parse SRCINFO for %s: %v", pkg.Pkgbase, err)
|
log.Warningf("Failed to parse SRCINFO for %s: %v", pkg.Pkgbase, err)
|
||||||
|
b.parseWG.Done()
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
pkg.Srcinfo = info
|
pkg.Srcinfo = info
|
||||||
@@ -383,12 +390,14 @@ func (b *BuildManager) parseWorker() {
|
|||||||
if contains(info.Arch, "any") || contains(conf.Blacklist, info.Pkgbase) {
|
if contains(info.Arch, "any") || contains(conf.Blacklist, info.Pkgbase) {
|
||||||
log.Infof("Skipped %s: blacklisted or any-Package", info.Pkgbase)
|
log.Infof("Skipped %s: blacklisted or any-Package", info.Pkgbase)
|
||||||
b.toPurge <- pkg
|
b.toPurge <- pkg
|
||||||
|
b.parseWG.Done()
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if isPkgFailed(pkg) {
|
if isPkgFailed(pkg) {
|
||||||
log.Infof("Skipped %s: failed build", info.Pkgbase)
|
log.Infof("Skipped %s: failed build", info.Pkgbase)
|
||||||
b.toPurge <- pkg
|
b.toPurge <- pkg
|
||||||
|
b.parseWG.Done()
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -402,9 +411,13 @@ func (b *BuildManager) parseWorker() {
|
|||||||
repoVer := getVersionFromRepo(pkg)
|
repoVer := getVersionFromRepo(pkg)
|
||||||
if repoVer != "" && alpm.VerCmp(repoVer, pkgVer) > 0 {
|
if repoVer != "" && alpm.VerCmp(repoVer, pkgVer) > 0 {
|
||||||
log.Debugf("Skipped %s: Version in repo higher than in PKGBUILD (%s < %s)", info.Pkgbase, pkgVer, repoVer)
|
log.Debugf("Skipped %s: Version in repo higher than in PKGBUILD (%s < %s)", info.Pkgbase, pkgVer, repoVer)
|
||||||
|
b.stats.fullyBuild++
|
||||||
|
b.parseWG.Done()
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
b.stats.eligible++
|
||||||
|
b.parseWG.Done()
|
||||||
b.toBuild <- pkg
|
b.toBuild <- pkg
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -531,7 +544,7 @@ func (b *BuildManager) repoWorker() {
|
|||||||
res, err = cmd.CombinedOutput()
|
res, err = cmd.CombinedOutput()
|
||||||
log.Debug(string(res))
|
log.Debug(string(res))
|
||||||
check(err)
|
check(err)
|
||||||
b.wg.Done()
|
b.buildWG.Done()
|
||||||
case pkg := <-b.toPurge:
|
case pkg := <-b.toPurge:
|
||||||
if _, err := os.Stat(filepath.Join(conf.Basedir.Repo, pkg.FullRepo, "os", conf.Arch, pkg.FullRepo) + ".db.tar.xz"); err != nil {
|
if _, err := os.Stat(filepath.Join(conf.Basedir.Repo, pkg.FullRepo, "os", conf.Arch, pkg.FullRepo) + ".db.tar.xz"); err != nil {
|
||||||
continue
|
continue
|
||||||
@@ -582,7 +595,7 @@ func (b *BuildManager) syncWorker() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for {
|
for {
|
||||||
b.wg.Wait()
|
b.buildWG.Wait()
|
||||||
for gitDir, gitURL := range conf.Svn2git {
|
for gitDir, gitURL := range conf.Svn2git {
|
||||||
gitPath := filepath.Join(conf.Basedir.Upstream, gitDir)
|
gitPath := filepath.Join(conf.Basedir.Upstream, gitDir)
|
||||||
|
|
||||||
@@ -629,6 +642,7 @@ func (b *BuildManager) syncWorker() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, march := range conf.March {
|
for _, march := range conf.March {
|
||||||
|
b.parseWG.Add(1)
|
||||||
b.toParse <- &BuildPackage{
|
b.toParse <- &BuildPackage{
|
||||||
Pkgbuild: pkgbuild,
|
Pkgbuild: pkgbuild,
|
||||||
Pkgbase: sPkgbuild[len(sPkgbuild)-4],
|
Pkgbase: sPkgbuild[len(sPkgbuild)-4],
|
||||||
@@ -639,6 +653,10 @@ func (b *BuildManager) syncWorker() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
b.parseWG.Wait()
|
||||||
|
log.Infof("Processed source-repos. %d packages elegible to be build, %d already fully build. Covering %f of offical-repo (buildable) packages.", b.stats.eligible, b.stats.fullyBuild, b.stats.fullyBuild/b.stats.eligible)
|
||||||
|
b.stats.fullyBuild = 0
|
||||||
|
b.stats.eligible = 0
|
||||||
time.Sleep(5 * time.Minute)
|
time.Sleep(5 * time.Minute)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -667,12 +685,12 @@ func main() {
|
|||||||
check(err)
|
check(err)
|
||||||
|
|
||||||
buildManager = BuildManager{
|
buildManager = BuildManager{
|
||||||
toBuild: make(chan *BuildPackage),
|
toBuild: make(chan *BuildPackage, 10000),
|
||||||
toParse: make(chan *BuildPackage, conf.Build.Worker),
|
toParse: make(chan *BuildPackage, 10000),
|
||||||
toPurge: make(chan *BuildPackage),
|
toPurge: make(chan *BuildPackage, conf.Build.Worker),
|
||||||
toRepoAdd: make(chan *BuildPackage, conf.Build.Worker),
|
toRepoAdd: make(chan *BuildPackage, conf.Build.Worker),
|
||||||
exit: false,
|
exit: false,
|
||||||
wg: sync.WaitGroup{},
|
buildWG: sync.WaitGroup{},
|
||||||
failedMutex: sync.RWMutex{},
|
failedMutex: sync.RWMutex{},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -693,5 +711,5 @@ func main() {
|
|||||||
check(syscall.Kill(-pgid, syscall.SIGTERM))
|
check(syscall.Kill(-pgid, syscall.SIGTERM))
|
||||||
}
|
}
|
||||||
buildManager.buildProcMutex.RUnlock()
|
buildManager.buildProcMutex.RUnlock()
|
||||||
buildManager.wg.Wait()
|
buildManager.buildWG.Wait()
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user