forked from ALHP/ALHP.GO
fixed housekeeping not detecting moved packages
This commit is contained in:
45
utils.go
45
utils.go
@@ -629,10 +629,11 @@ func housekeeping(repo string, wg *sync.WaitGroup) error {
|
|||||||
|
|
||||||
for _, path := range packages {
|
for _, path := range packages {
|
||||||
pkgfile := PKGFile(path)
|
pkgfile := PKGFile(path)
|
||||||
|
splitPath := strings.Split(path, string(filepath.Separator))
|
||||||
|
|
||||||
dbPkg, err := pkgfile.DBPackage()
|
dbPkg, err := pkgfile.DBPackage()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Infof("[HK/%s] removing orphan %s", repo, filepath.Base(path))
|
log.Infof("[HK/%s] removing orphan %s", repo, filepath.Base(path))
|
||||||
splitPath := strings.Split(path, string(filepath.Separator))
|
|
||||||
pkg := &BuildPackage{
|
pkg := &BuildPackage{
|
||||||
FullRepo: splitPath[len(splitPath)-4],
|
FullRepo: splitPath[len(splitPath)-4],
|
||||||
PkgFiles: []string{path},
|
PkgFiles: []string{path},
|
||||||
@@ -643,8 +644,8 @@ func housekeeping(repo string, wg *sync.WaitGroup) error {
|
|||||||
|
|
||||||
pkg := &BuildPackage{
|
pkg := &BuildPackage{
|
||||||
Pkgbase: dbPkg.Pkgbase,
|
Pkgbase: dbPkg.Pkgbase,
|
||||||
Repo: dbPkg.Repository,
|
Repo: dbpackage.Repository(strings.Split(splitPath[len(splitPath)-4], "-")[0]),
|
||||||
FullRepo: dbPkg.Repository.String() + "-" + dbPkg.March,
|
FullRepo: splitPath[len(splitPath)-4],
|
||||||
DbPackage: dbPkg,
|
DbPackage: dbPkg,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -657,6 +658,25 @@ func housekeeping(repo string, wg *sync.WaitGroup) error {
|
|||||||
}
|
}
|
||||||
pkg.Pkgbuild = filepath.Join(conf.Basedir.Upstream, upstream, dbPkg.Pkgbase, "repos", pkg.DbPackage.Repository.String()+"-"+conf.Arch, "PKGBUILD")
|
pkg.Pkgbuild = filepath.Join(conf.Basedir.Upstream, upstream, dbPkg.Pkgbase, "repos", pkg.DbPackage.Repository.String()+"-"+conf.Arch, "PKGBUILD")
|
||||||
|
|
||||||
|
// check if package is still part of repo
|
||||||
|
dbs, err := alpmHandle.SyncDBs()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
buildManager.alpmMutex.Lock()
|
||||||
|
pkgResolved, err := dbs.FindSatisfier(dbPkg.Packages[0])
|
||||||
|
buildManager.alpmMutex.Unlock()
|
||||||
|
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
|
||||||
|
err = db.DbPackage.DeleteOne(pkg.DbPackage).Exec(context.Background())
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
// check if pkg signature is valid
|
// check if pkg signature is valid
|
||||||
valid, err := pkgfile.isSignatureValid()
|
valid, err := pkgfile.isSignatureValid()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -679,25 +699,6 @@ func housekeeping(repo string, wg *sync.WaitGroup) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: check split packages
|
// TODO: check split packages
|
||||||
|
|
||||||
// check if package is still part of repo
|
|
||||||
dbs, err := alpmHandle.SyncDBs()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
buildManager.alpmMutex.Lock()
|
|
||||||
pkgResolved, err := dbs.FindSatisfier(dbPkg.Packages[0])
|
|
||||||
buildManager.alpmMutex.Unlock()
|
|
||||||
if err != nil || pkgResolved.DB().Name() != pkg.DbPackage.Repository.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
|
|
||||||
err = db.DbPackage.DeleteOne(pkg.DbPackage).Exec(context.Background())
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
Reference in New Issue
Block a user