forked from ALHP/ALHP.GO
separate srcinfo gen into func
This commit is contained in:
40
main.go
40
main.go
@@ -9,7 +9,6 @@ import (
|
|||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/Jguer/go-alpm/v2"
|
"github.com/Jguer/go-alpm/v2"
|
||||||
"github.com/Morganamilo/go-srcinfo"
|
|
||||||
_ "github.com/mattn/go-sqlite3"
|
_ "github.com/mattn/go-sqlite3"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"github.com/wercker/journalhook"
|
"github.com/wercker/journalhook"
|
||||||
@@ -201,17 +200,9 @@ func (b *BuildManager) parseWorker() {
|
|||||||
}
|
}
|
||||||
select {
|
select {
|
||||||
case pkg := <-b.parse:
|
case pkg := <-b.parse:
|
||||||
cmd := exec.Command("sh", "-c", "cd "+filepath.Dir(pkg.Pkgbuild)+"&&"+"makepkg --printsrcinfo")
|
info, err := genSRCINFO(pkg.Pkgbuild)
|
||||||
res, err := cmd.Output()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warningf("Failed generate SRCINFO for %s: %v", pkg.Pkgbase, err)
|
log.Warningf("Failed to generate SRCINFO for %s: %v", pkg.Pkgbase, err)
|
||||||
b.parseWG.Done()
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
info, err := srcinfo.Parse(string(res))
|
|
||||||
if err != nil {
|
|
||||||
log.Warningf("Failed to parse SRCINFO for %s: %v", pkg.Pkgbase, err)
|
|
||||||
b.parseWG.Done()
|
b.parseWG.Done()
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@@ -226,32 +217,35 @@ func (b *BuildManager) parseWorker() {
|
|||||||
skipping := false
|
skipping := false
|
||||||
if contains(info.Arch, "any") {
|
if contains(info.Arch, "any") {
|
||||||
log.Debugf("Skipped %s: any-Package", info.Pkgbase)
|
log.Debugf("Skipped %s: any-Package", info.Pkgbase)
|
||||||
dbLock.Lock()
|
dbPkg.SkipReason = "arch = any"
|
||||||
dbPkg = dbPkg.Update().SetStatus(SKIPPED).SetSkipReason("arch = any").SetHash(pkg.Hash).SaveX(context.Background())
|
dbPkg.Hash = pkg.Hash
|
||||||
dbLock.Unlock()
|
dbPkg.Status = SKIPPED
|
||||||
skipping = true
|
skipping = true
|
||||||
} else if contains(conf.Blacklist.Packages, info.Pkgbase) {
|
} else if contains(conf.Blacklist.Packages, info.Pkgbase) {
|
||||||
log.Debugf("Skipped %s: blacklisted package", info.Pkgbase)
|
log.Debugf("Skipped %s: blacklisted package", info.Pkgbase)
|
||||||
dbLock.Lock()
|
dbPkg.SkipReason = "blacklisted"
|
||||||
dbPkg = dbPkg.Update().SetStatus(SKIPPED).SetSkipReason("blacklisted").SetHash(pkg.Hash).SaveX(context.Background())
|
dbPkg.Hash = pkg.Hash
|
||||||
dbLock.Unlock()
|
dbPkg.Status = SKIPPED
|
||||||
skipping = true
|
skipping = true
|
||||||
} else if contains(info.MakeDepends, "ghc") || contains(info.MakeDepends, "haskell-ghc") || contains(info.Depends, "ghc") || contains(info.Depends, "haskell-ghc") {
|
} else if contains(info.MakeDepends, "ghc") || contains(info.MakeDepends, "haskell-ghc") || contains(info.Depends, "ghc") || contains(info.Depends, "haskell-ghc") {
|
||||||
// Skip Haskell packages for now, as we are facing linking problems with them,
|
// Skip Haskell packages for now, as we are facing linking problems with them,
|
||||||
// most likely caused by not having a dependency check implemented yet and building at random.
|
// most likely caused by not having a dependency check implemented yet and building at random.
|
||||||
// https://git.harting.dev/anonfunc/ALHP.GO/issues/11
|
// https://git.harting.dev/anonfunc/ALHP.GO/issues/11
|
||||||
log.Debugf("Skipped %s: haskell package", info.Pkgbase)
|
log.Debugf("Skipped %s: haskell package", info.Pkgbase)
|
||||||
dbLock.Lock()
|
dbPkg.SkipReason = "blacklisted (haskell)"
|
||||||
dbPkg = dbPkg.Update().SetStatus(SKIPPED).SetSkipReason("blacklisted (haskell)").SetHash(pkg.Hash).SaveX(context.Background())
|
dbPkg.Hash = pkg.Hash
|
||||||
dbLock.Unlock()
|
dbPkg.Status = SKIPPED
|
||||||
skipping = true
|
skipping = true
|
||||||
} else if isPkgFailed(pkg) {
|
} else if isPkgFailed(pkg) {
|
||||||
log.Debugf("Skipped %s: failed build", info.Pkgbase)
|
log.Debugf("Skipped %s: failed build", info.Pkgbase)
|
||||||
dbLock.Lock()
|
dbPkg.SkipReason = ""
|
||||||
dbPkg = dbPkg.Update().SetStatus(FAILED).SetSkipReason("").SetHash(pkg.Hash).SaveX(context.Background())
|
dbPkg.Hash = pkg.Hash
|
||||||
dbLock.Unlock()
|
dbPkg.Status = FAILED
|
||||||
skipping = true
|
skipping = true
|
||||||
}
|
}
|
||||||
|
dbLock.Lock()
|
||||||
|
dbPkg = dbPkg.Update().SetStatus(dbPkg.Status).SetSkipReason(dbPkg.SkipReason).SetHash(dbPkg.Hash).SaveX(context.Background())
|
||||||
|
dbLock.Unlock()
|
||||||
|
|
||||||
if skipping {
|
if skipping {
|
||||||
b.repoPurge[pkg.FullRepo] <- pkg
|
b.repoPurge[pkg.FullRepo] <- pkg
|
||||||
|
15
utils.go
15
utils.go
@@ -377,6 +377,21 @@ func isPkgFailed(pkg *BuildPackage) bool {
|
|||||||
return failed
|
return failed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func genSRCINFO(pkgbuild string) (*srcinfo.Srcinfo, error) {
|
||||||
|
cmd := exec.Command("sh", "-c", "cd "+filepath.Dir(pkgbuild)+"&&"+"makepkg --printsrcinfo")
|
||||||
|
res, err := cmd.Output()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
info, err := srcinfo.Parse(string(res))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return info, nil
|
||||||
|
}
|
||||||
|
|
||||||
func setupChroot() {
|
func setupChroot() {
|
||||||
if _, err := os.Stat(filepath.Join(conf.Basedir.Chroot, pristineChroot)); err == nil {
|
if _, err := os.Stat(filepath.Join(conf.Basedir.Chroot, pristineChroot)); err == nil {
|
||||||
//goland:noinspection SpellCheckingInspection
|
//goland:noinspection SpellCheckingInspection
|
||||||
|
Reference in New Issue
Block a user