forked from ALHP/ALHP.GO
more progress on housekeeping
This commit is contained in:
33
utils.go
33
utils.go
@@ -6,8 +6,6 @@ import (
|
|||||||
"bufio"
|
"bufio"
|
||||||
"context"
|
"context"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"entgo.io/ent/dialect/sql"
|
|
||||||
"entgo.io/ent/dialect/sql/sqljson"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/Jguer/go-alpm/v2"
|
"github.com/Jguer/go-alpm/v2"
|
||||||
paconf "github.com/Morganamilo/go-pacmanconf"
|
paconf "github.com/Morganamilo/go-pacmanconf"
|
||||||
@@ -403,27 +401,28 @@ func setupChroot() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func getPkgbaseFromPkgfile(pkg string) (*ent.DbPackage, error) {
|
func getDBPkgFromPkgfile(pkg string) (*ent.DbPackage, error) {
|
||||||
fNameSplit := strings.Split(pkg, "-")
|
fNameSplit := strings.Split(pkg, "-")
|
||||||
pkgname := strings.Join(fNameSplit[0:len(fNameSplit)-3], "-")
|
pkgname := strings.Join(fNameSplit[0:len(fNameSplit)-3], "-")
|
||||||
|
|
||||||
dbLock.RLock()
|
dbLock.RLock()
|
||||||
defer dbLock.RUnlock()
|
defer dbLock.RUnlock()
|
||||||
dbPkg, dbErr := db.DbPackage.Query().Where(func(s *sql.Selector) {
|
dbPkgs, err := db.DbPackage.Query().Where(dbpackage.PackagesNotNil()).All(context.Background())
|
||||||
s.Where(sqljson.ValueContains(dbpackage.FieldPackages, pkgname)).Or().Where(sql.EQ(s.C(dbpackage.FieldPkgbase), pkgname))
|
if err != nil {
|
||||||
}).Only(context.Background())
|
switch err.(type) {
|
||||||
|
|
||||||
if dbErr != nil {
|
|
||||||
switch dbErr.(type) {
|
|
||||||
case *ent.NotFoundError:
|
case *ent.NotFoundError:
|
||||||
log.Debugf("Not found in database: %s", pkgname)
|
log.Debugf("Not found in database: %s", pkgname)
|
||||||
return nil, fmt.Errorf("package not found in DB: %s", pkgname)
|
return nil, fmt.Errorf("package not found in DB: %s", pkgname)
|
||||||
default:
|
default:
|
||||||
log.Errorf("Problem querying db for package %s: %v", pkgname, dbErr)
|
log.Errorf("Problem querying db for package %s: %v", pkgname, err)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
for _, dbPkg := range dbPkgs {
|
||||||
|
if contains(dbPkg.Packages, pkg) {
|
||||||
return dbPkg, nil
|
return dbPkg, nil
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return nil, fmt.Errorf("package not found in DB: %s", pkgname)
|
return nil, fmt.Errorf("package not found in DB: %s", pkgname)
|
||||||
}
|
}
|
||||||
@@ -449,12 +448,22 @@ func housekeeping() error {
|
|||||||
check(err)
|
check(err)
|
||||||
|
|
||||||
for _, pkgfile := range packages {
|
for _, pkgfile := range packages {
|
||||||
// check if signature is valid
|
// check if pkg signature is valid
|
||||||
valid, err := isSignatureValid(pkgfile)
|
valid, err := isSignatureValid(pkgfile)
|
||||||
check(err)
|
check(err)
|
||||||
if !valid {
|
if !valid {
|
||||||
|
// TODO: purge pkg to trigger rebuild -> need srcinfo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: compare db-version with repo version
|
||||||
|
|
||||||
|
// TODO: check split packages
|
||||||
|
|
||||||
|
/* TODO: check if package is still part of repo
|
||||||
|
maybe we need to query ArchWeb here, since svn2git is not an absolute source
|
||||||
|
see https://git.harting.dev/anonfunc/ALHP.GO/issues/16#issuecomment-208
|
||||||
|
or https://git.harting.dev/anonfunc/ALHP.GO/issues/43#issuecomment-371
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user