2020-07-10 02:36:45 +02:00
|
|
|
package query
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2021-04-03 21:33:56 +02:00
|
|
|
"strings"
|
2020-07-10 02:36:45 +02:00
|
|
|
|
|
|
|
"github.com/leonelquinteros/gotext"
|
|
|
|
|
2023-03-07 22:04:06 +01:00
|
|
|
"github.com/Jguer/yay/v12/pkg/stringset"
|
|
|
|
"github.com/Jguer/yay/v12/pkg/text"
|
2020-07-10 02:36:45 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
type AURWarnings struct {
|
|
|
|
Orphans []string
|
|
|
|
OutOfDate []string
|
|
|
|
Missing []string
|
|
|
|
Ignore stringset.StringSet
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewWarnings() *AURWarnings {
|
|
|
|
return &AURWarnings{Ignore: make(stringset.StringSet)}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (warnings *AURWarnings) Print() {
|
2021-04-03 21:33:56 +02:00
|
|
|
normalMissing, debugMissing := filterDebugPkgs(warnings.Missing)
|
|
|
|
|
|
|
|
if len(normalMissing) > 0 {
|
2022-12-19 19:17:47 +01:00
|
|
|
text.Warn(gotext.Get("Packages not in AUR:"))
|
2021-04-03 21:33:56 +02:00
|
|
|
printRange(normalMissing)
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(debugMissing) > 0 {
|
|
|
|
text.Warn(gotext.Get("Missing AUR Debug Packages:"))
|
|
|
|
printRange(debugMissing)
|
2020-07-10 02:36:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if len(warnings.Orphans) > 0 {
|
2022-12-19 19:17:47 +01:00
|
|
|
text.Warn(gotext.Get("Orphan (unmaintained) AUR Packages:"))
|
2020-07-10 02:36:45 +02:00
|
|
|
printRange(warnings.Orphans)
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(warnings.OutOfDate) > 0 {
|
|
|
|
text.Warn(gotext.Get("Flagged Out Of Date AUR Packages:"))
|
|
|
|
printRange(warnings.OutOfDate)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-03 21:33:56 +02:00
|
|
|
func filterDebugPkgs(names []string) (normal, debug []string) {
|
2021-04-05 23:47:29 +02:00
|
|
|
normal = make([]string, 0, len(names))
|
|
|
|
debug = make([]string, 0, len(names))
|
2021-04-03 21:33:56 +02:00
|
|
|
|
|
|
|
for _, name := range names {
|
|
|
|
if strings.HasSuffix(name, "-debug") {
|
|
|
|
debug = append(debug, name)
|
|
|
|
} else {
|
|
|
|
normal = append(normal, name)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2020-07-10 02:36:45 +02:00
|
|
|
func printRange(names []string) {
|
|
|
|
for _, name := range names {
|
|
|
|
fmt.Print(" " + text.Cyan(name))
|
|
|
|
}
|
2021-08-11 20:13:28 +02:00
|
|
|
|
2020-07-10 02:36:45 +02:00
|
|
|
fmt.Println()
|
|
|
|
}
|