1
0
forked from ALHP/ALHP.GO

check if package is available before build

This commit is contained in:
2021-11-20 01:02:37 +01:00
parent 66a21cba22
commit 76b21b7770
2 changed files with 40 additions and 9 deletions

14
main.go
View File

@@ -202,8 +202,12 @@ func (b *BuildManager) parseWorker() {
} }
pkg.Version = constructVersion(pkg.Srcinfo.Pkgver, pkg.Srcinfo.Pkgrel, pkg.Srcinfo.Epoch) pkg.Version = constructVersion(pkg.Srcinfo.Pkgver, pkg.Srcinfo.Pkgrel, pkg.Srcinfo.Epoch)
pkg.toDbPackage(true) if !pkg.isAvailable(alpmHandle) {
log.Debugf("[%s/%s] Not available on mirror, skipping build", pkg.FullRepo, pkg.Pkgbase)
continue
}
pkg.toDbPackage(true)
skipping := false skipping := false
if contains(pkg.Srcinfo.Arch, "any") { if contains(pkg.Srcinfo.Arch, "any") {
log.Debugf("Skipped %s: any-Package", pkg.Srcinfo.Pkgbase) log.Debugf("Skipped %s: any-Package", pkg.Srcinfo.Pkgbase)
@@ -452,9 +456,7 @@ func (b *BuildManager) repoWorker(repo string) {
res, err := cmd.CombinedOutput() res, err := cmd.CombinedOutput()
log.Debug(string(res)) log.Debug(string(res))
if err != nil && cmd.ProcessState.ExitCode() == 1 { if err != nil && cmd.ProcessState.ExitCode() == 1 {
log.Debugf("Deleteing package %s failed: Package not found in database", pkg.Pkgbase) log.Debugf("Deleting package %s failed: Package not found in repo-database", pkg.Pkgbase)
b.repoWG.Done()
continue
} }
if pkg.DbPackage != nil { if pkg.DbPackage != nil {
@@ -462,8 +464,8 @@ func (b *BuildManager) repoWorker(repo string) {
} }
for _, file := range pkg.PkgFiles { for _, file := range pkg.PkgFiles {
check(os.Remove(file)) _ = os.Remove(file)
check(os.Remove(file + ".sig")) _ = os.Remove(file + ".sig")
} }
updateLastUpdated() updateLastUpdated()
b.repoWG.Done() b.repoWG.Done()

View File

@@ -296,6 +296,26 @@ func initALPM(root string, dbpath string) (*alpm.Handle, error) {
return h, nil return h, nil
} }
func (p *BuildPackage) isAvailable(h *alpm.Handle) bool {
dbs, err := h.SyncDBs()
if err != nil {
return false
}
buildManager.alpmMutex.Lock()
pkg, err := dbs.FindSatisfier(p.Srcinfo.Packages[0].Pkgname)
buildManager.alpmMutex.Unlock()
if err != nil {
return false
}
if pkg.DB().Name() != p.Repo.String() {
return false
}
return true
}
func (p *BuildPackage) SVN2GITVersion(h *alpm.Handle) (string, error) { func (p *BuildPackage) SVN2GITVersion(h *alpm.Handle) (string, error) {
if p.Pkgbuild == "" && p.Pkgbase == "" { if p.Pkgbuild == "" && p.Pkgbase == "" {
return "", fmt.Errorf("invalid arguments") return "", fmt.Errorf("invalid arguments")
@@ -306,7 +326,7 @@ func (p *BuildPackage) SVN2GITVersion(h *alpm.Handle) (string, error) {
var fPkgbuilds []string var fPkgbuilds []string
for _, pkgbuild := range pkgBuilds { for _, pkgbuild := range pkgBuilds {
sPkgbuild := strings.Split(pkgbuild, "/") sPkgbuild := strings.Split(pkgbuild, string(filepath.Separator))
repo := sPkgbuild[len(sPkgbuild)-2] repo := sPkgbuild[len(sPkgbuild)-2]
if repo == "trunk" || containsSubStr(repo, conf.Blacklist.Repo) { if repo == "trunk" || containsSubStr(repo, conf.Blacklist.Repo) {
@@ -325,7 +345,9 @@ func (p *BuildPackage) SVN2GITVersion(h *alpm.Handle) (string, error) {
return "", err return "", err
} }
buildManager.alpmMutex.Lock()
iPackage, err := dbs.FindSatisfier(p.Pkgbase) iPackage, err := dbs.FindSatisfier(p.Pkgbase)
buildManager.alpmMutex.Unlock()
if err != nil { if err != nil {
return "", err return "", err
} }
@@ -490,8 +512,13 @@ func housekeeping(repo string, wg *sync.WaitGroup) error {
pkgfile := PKGFile(path) pkgfile := PKGFile(path)
dbPkg, err := pkgfile.DBPackage() dbPkg, err := pkgfile.DBPackage()
if err != nil { if err != nil {
log.Warningf("[HK/%s] Unable to find entry for %s in db: %v", repo, filepath.Base(path), err) log.Infof("[HK/%s] removing orphan %s", repo, filepath.Base(path))
// TODO: remove orphan file not tracked by db (WTF kmod-debug!) splitPath := strings.Split(path, string(filepath.Separator))
pkg := &BuildPackage{
FullRepo: splitPath[len(splitPath)-4],
PkgFiles: []string{path},
}
buildManager.repoPurge[pkg.FullRepo] <- pkg
continue continue
} }
@@ -546,7 +573,9 @@ func housekeeping(repo string, wg *sync.WaitGroup) error {
if err != nil { if err != nil {
return err return err
} }
buildManager.alpmMutex.Lock()
pkgResolved, err := dbs.FindSatisfier(dbPkg.Packages[0]) pkgResolved, err := dbs.FindSatisfier(dbPkg.Packages[0])
buildManager.alpmMutex.Unlock()
if err != nil || pkgResolved.DB().Name() != pkg.DbPackage.Repository.String() { if err != nil || pkgResolved.DB().Name() != pkg.DbPackage.Repository.String() {
// package not found on mirror/db -> not part of any repo anymore // package not found on mirror/db -> not part of any repo anymore
log.Infof("[HK/%s/%s] not part of repo", pkg.FullRepo, pkg.Pkgbase) log.Infof("[HK/%s/%s] not part of repo", pkg.FullRepo, pkg.Pkgbase)