use packages instead of pkgbases for output
This commit is contained in:
1
go.mod
1
go.mod
@@ -4,7 +4,6 @@ go 1.24
|
|||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/Jguer/go-alpm/v2 v2.2.2
|
github.com/Jguer/go-alpm/v2 v2.2.2
|
||||||
github.com/deckarep/golang-set/v2 v2.8.0
|
|
||||||
github.com/sirupsen/logrus v1.9.3
|
github.com/sirupsen/logrus v1.9.3
|
||||||
somegit.dev/ALHP/ALHP.GO v0.0.0-20250322224907-01404adad53a
|
somegit.dev/ALHP/ALHP.GO v0.0.0-20250322224907-01404adad53a
|
||||||
)
|
)
|
||||||
|
2
go.sum
2
go.sum
@@ -9,8 +9,6 @@ github.com/Morganamilo/go-pacmanconf v0.0.0-20210502114700-cff030e927a5/go.mod h
|
|||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/deckarep/golang-set/v2 v2.8.0 h1:swm0rlPCmdWn9mESxKOjWk8hXSqoxOp+ZlfuyaAdFlQ=
|
|
||||||
github.com/deckarep/golang-set/v2 v2.8.0/go.mod h1:VAky9rY/yGXJOLEDv3OMci+7wtDpOF4IN+y82NBOac4=
|
|
||||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
|
21
main.go
21
main.go
@@ -5,7 +5,6 @@ import (
|
|||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/Jguer/go-alpm/v2"
|
"github.com/Jguer/go-alpm/v2"
|
||||||
"github.com/deckarep/golang-set/v2"
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
@@ -25,8 +24,8 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type JSONOut struct {
|
type JSONOut struct {
|
||||||
InQueue int `json:"in_queue"`
|
Total int `json:"total"`
|
||||||
PackageBases []string `json:"package_base"`
|
Packages []string `json:"packages"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -61,27 +60,27 @@ func main() {
|
|||||||
}
|
}
|
||||||
log.Debugf("alhp build queue length: %d", len(alhpQueue))
|
log.Debugf("alhp build queue length: %d", len(alhpQueue))
|
||||||
|
|
||||||
packagesInQueue := mapset.NewSet[string]()
|
var packagesInQueue []string
|
||||||
for _, pkg := range db.PkgCache().Slice() {
|
for _, pkg := range db.PkgCache().Slice() {
|
||||||
if Find(alhpQueue, pkg.Base()) != -1 {
|
if Find(alhpQueue, pkg.Base()) != -1 {
|
||||||
log.Debugf("found package in queue: %s", pkg.Base())
|
log.Debugf("found package in queue: %s", pkg.Name())
|
||||||
packagesInQueue.Add(pkg.Base())
|
packagesInQueue = append(packagesInQueue, pkg.Name())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !packagesInQueue.IsEmpty() {
|
if len(packagesInQueue) > 0 {
|
||||||
log.Debugf("found %d of your local packages in queue", packagesInQueue.Cardinality())
|
log.Debugf("found %d of your local packages in queue", len(packagesInQueue))
|
||||||
if *jsonFlag {
|
if *jsonFlag {
|
||||||
err = json.NewEncoder(os.Stdout).Encode(JSONOut{
|
err = json.NewEncoder(os.Stdout).Encode(JSONOut{
|
||||||
InQueue: packagesInQueue.Cardinality(),
|
Total: len(packagesInQueue),
|
||||||
PackageBases: packagesInQueue.ToSlice(),
|
Packages: packagesInQueue,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("error encoding JSON: %v", err)
|
log.Errorf("error encoding JSON: %v", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fmt.Println(strings.Join(packagesInQueue.ToSlice(), "\n"))
|
fmt.Println(strings.Join(packagesInQueue, "\n"))
|
||||||
}
|
}
|
||||||
|
|
||||||
if *exitCodeFlag {
|
if *exitCodeFlag {
|
||||||
|
Reference in New Issue
Block a user