add mantic to ubuntu sync

This commit is contained in:
ferrreo 2023-09-18 16:05:15 +01:00
parent 2c4b3302af
commit dbd5edc46a

View File

@ -7,6 +7,7 @@ import (
"net/http" "net/http"
"os" "os"
"ppp/v2/deb" "ppp/v2/deb"
"slices"
"strings" "strings"
"sync" "sync"
@ -23,6 +24,7 @@ func main() {
Source: os.Args[1], Source: os.Args[1],
Target: os.Args[2], Target: os.Args[2],
Download: false, Download: false,
Match: make([]string, 0),
} }
if len(os.Args) > 3 { if len(os.Args) > 3 {
@ -31,8 +33,12 @@ func main() {
config.Output = os.Args[4] config.Output = os.Args[4]
} }
basePackages := processFile(config.Source) if len(os.Args) > 5 {
targetPackages := processFile(config.Target) config.Match = strings.Split(os.Args[5], ",")
}
basePackages := processFile(config.Source, config)
targetPackages := processFile(config.Target, config)
changed := compare(basePackages, targetPackages, config.Download) changed := compare(basePackages, targetPackages, config.Download)
if config.Download { if config.Download {
@ -40,7 +46,7 @@ func main() {
} }
} }
func processFile(url string) map[string]packageInfo { func processFile(url string, config config) map[string]packageInfo {
resp, err := http.Get(url) resp, err := http.Get(url)
if err != nil { if err != nil {
panic(err) panic(err)
@ -77,6 +83,10 @@ func processFile(url string) map[string]packageInfo {
break break
} }
if len(config.Match) > 0 && !slices.Contains(config.Match, stanza["Package"]) {
continue
}
_, broken := brokenPackages[stanza["Package"]] _, broken := brokenPackages[stanza["Package"]]
if broken { if broken {
continue continue
@ -185,6 +195,7 @@ type config struct {
Download bool Download bool
DlUrl string DlUrl string
Output string Output string
Match []string
} }
type packageInfo struct { type packageInfo struct {