From 1c1f1fba17b4a0812b707326160b3540cee5e1ec Mon Sep 17 00:00:00 2001 From: Giovanni Harting <539@idlegandalf.com> Date: Sat, 16 Dec 2023 12:39:15 +0100 Subject: [PATCH] add debug package cleanup to housekeeping --- buildmanager.go | 1 + housekeeping.go | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/buildmanager.go b/buildmanager.go index 19b04ad..b52a307 100644 --- a/buildmanager.go +++ b/buildmanager.go @@ -492,6 +492,7 @@ func (b *BuildManager) syncWorker(ctx context.Context) error { if err != nil { log.Warningf("log-housekeeping failed: %v", err) } + debugHK() // fetch updates between sync runs b.alpmMutex.Lock() diff --git a/housekeeping.go b/housekeeping.go index 0368c65..3ba1ea0 100644 --- a/housekeeping.go +++ b/housekeeping.go @@ -4,6 +4,7 @@ import ( "context" log "github.com/sirupsen/logrus" "os" + "os/exec" "path/filepath" "somegit.dev/ALHP/ALHP.GO/ent" "somegit.dev/ALHP/ALHP.GO/ent/dbpackage" @@ -304,3 +305,16 @@ func logHK() error { } return nil } + +func debugHK() { + for _, march := range conf.March { + if _, err := os.Stat(filepath.Join(conf.Basedir.Debug, march)); err == nil { + log.Debugf("[DHK/%s] start cleanup debug packages", march) + cleanCmd := exec.Command("paccache", "-rc", filepath.Join(conf.Basedir.Debug, march), "-k", "1") + res, err := cleanCmd.CombinedOutput() + if err != nil { + log.Warningf("[DHK/%s] cleanup debug packages failed: %v (%s)", march, err, string(res)) + } + } + } +}