fixed handling of new keys/ folder; added queue cleanup to housekeeping

master
Giovanni Harting 3 months ago
parent 08dd19c3ef
commit 4b3339125c
  1. 1
      go.mod
  2. 7
      go.sum
  3. 5
      proto_package.go
  4. 64
      utils.go

@ -9,6 +9,7 @@ require (
github.com/Morganamilo/go-srcinfo v1.0.0
github.com/google/uuid v1.3.0
github.com/jackc/pgx/v4 v4.16.1
github.com/otiai10/copy v1.7.0
github.com/sirupsen/logrus v1.8.1
github.com/wercker/journalhook v0.0.0-20180428041537-5d0a5ae867b3
golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f

@ -124,6 +124,13 @@ github.com/mattn/go-sqlite3 v1.14.10 h1:MLn+5bFRlWMGoSRmJour3CL1w/qL96mvipqpwQW/
github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo=
github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0=
github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0=
github.com/otiai10/copy v1.7.0 h1:hVoPiN+t+7d2nzzwMiDHPSOogsWAStewq3TwU05+clE=
github.com/otiai10/copy v1.7.0/go.mod h1:rmRl6QPdJj6EiUqXQ/4Nn2lLXoNQjFCQbbNrxgc/t3U=
github.com/otiai10/curr v0.0.0-20150429015615-9b4961190c95/go.mod h1:9qAhocn7zKJG+0mI8eUu6xqkFDYS2kb2saOteoSB3cE=
github.com/otiai10/curr v1.0.0/go.mod h1:LskTG5wDwr8Rs+nNQ+1LlxRjAtTZZjtJW4rMXl6j4vs=
github.com/otiai10/mint v1.3.0/go.mod h1:F5AjcsTsWUqX+Na9fpHb52P8pcRX2CI6A3ctIT91xUo=
github.com/otiai10/mint v1.3.3 h1:7JgpsBaN0uMkyju4tbYHu0mnM55hNKVYLsXmwr15NQI=
github.com/otiai10/mint v1.3.3/go.mod h1:/yxELlJQ0ufhjUwhshSj+wFjZ78CnZ48/1wtmBH1OTc=
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=

@ -11,6 +11,7 @@ import (
"github.com/Jguer/go-alpm/v2"
"github.com/Morganamilo/go-srcinfo"
"github.com/google/uuid"
"github.com/otiai10/copy"
log "github.com/sirupsen/logrus"
"io"
"math/rand"
@ -283,7 +284,7 @@ func (p *ProtoPackage) build(ctx context.Context) (time.Duration, error) {
if err != nil {
return time.Since(start), fmt.Errorf("error creating %s: %w", holdingDir, err)
}
_, err = copyFile(file, filepath.Join(holdingDir, filepath.Base(file)))
err = copy.Copy(file, filepath.Join(holdingDir, filepath.Base(file)))
if err != nil {
return time.Since(start), fmt.Errorf("error while copying file to %s: %w", filepath.Join(holdingDir, filepath.Base(file)), err)
}
@ -360,7 +361,7 @@ func (p *ProtoPackage) setupBuildDir() (string, error) {
}
for _, file := range files {
_, err = copyFile(file, filepath.Join(buildDir, filepath.Base(file)))
err = copy.Copy(file, filepath.Join(buildDir, filepath.Base(file)))
if err != nil {
return "", err
}

@ -600,6 +600,41 @@ func housekeeping(repo string, march string, wg *sync.WaitGroup) error {
}
}
// remove queued status from packages is not eligible
qPackages, err := db.DbPackage.Query().Where(
dbpackage.And(
dbpackage.RepositoryEQ(dbpackage.Repository(repo)),
dbpackage.March(march),
dbpackage.StatusEQ(dbpackage.StatusQueued),
)).All(context.Background())
if err != nil {
return err
}
for _, dbPkg := range qPackages {
pkg := &ProtoPackage{
Pkgbase: dbPkg.Pkgbase,
Repo: dbPkg.Repository,
FullRepo: string(dbPkg.Repository) + dbPkg.March,
DbPackage: dbPkg,
March: dbPkg.March,
}
var upstream string
switch pkg.DbPackage.Repository {
case dbpackage.RepositoryCore, dbpackage.RepositoryExtra:
upstream = "upstream-core-extra"
case dbpackage.RepositoryCommunity:
upstream = "upstream-community"
}
pkg.Pkgbuild = filepath.Join(conf.Basedir.Work, upstreamDir, upstream, dbPkg.Pkgbase, "repos", pkg.DbPackage.Repository.String()+"-"+conf.Arch, "PKGBUILD")
_, err := pkg.isEligible(context.Background())
if err != nil {
log.Warningf("[HK] unable to determine status for %s: %v", dbPkg.Pkgbase, err)
}
}
return nil
}
@ -894,35 +929,6 @@ func Replace[T comparable](arr []T, replace T, with T) []T {
return arr
}
func copyFile(src, dst string) (int64, error) {
sourceFileStat, err := os.Stat(src)
if err != nil {
return 0, err
}
if !sourceFileStat.Mode().IsRegular() {
return 0, fmt.Errorf("%s is not a regular file", src)
}
source, err := os.Open(src)
if err != nil {
return 0, err
}
defer func(source *os.File) {
_ = source.Close()
}(source)
destination, err := os.Create(dst)
if err != nil {
return 0, err
}
defer func(destination *os.File) {
_ = destination.Close()
}(destination)
nBytes, err := io.Copy(destination, source)
return nBytes, err
}
func Glob(pattern string) ([]string, error) {
if !strings.Contains(pattern, "**") {
return filepath.Glob(pattern)

Loading…
Cancel
Save