ppp now can be passed a list of partial package names to match on

This commit is contained in:
ferrreo 2023-09-18 16:19:52 +01:00
parent 2462b7eab3
commit dc5a2a923f
2 changed files with 10 additions and 2 deletions

BIN
ppp

Binary file not shown.

View File

@ -7,7 +7,6 @@ import (
"net/http" "net/http"
"os" "os"
"ppp/v2/deb" "ppp/v2/deb"
"slices"
"strings" "strings"
"sync" "sync"
@ -83,7 +82,7 @@ func processFile(url string, config config) map[string]packageInfo {
break break
} }
if len(config.Match) > 0 && !slices.Contains(config.Match, stanza["Package"]) { if len(config.Match) > 0 && !nameContains(stanza["Package"], config.Match) {
continue continue
} }
@ -112,6 +111,15 @@ func processFile(url string, config config) map[string]packageInfo {
return packages return packages
} }
func nameContains(name string, match []string) bool {
for _, m := range match {
if strings.Contains(name, m) {
return true
}
}
return false
}
func compare(basePackages map[string]packageInfo, targetPackages map[string]packageInfo, download bool) map[string]packageInfo { func compare(basePackages map[string]packageInfo, targetPackages map[string]packageInfo, download bool) map[string]packageInfo {
output := make(map[string]packageInfo) output := make(map[string]packageInfo)
for pack, info := range targetPackages { for pack, info := range targetPackages {