package main import ( "bufio" "compress/gzip" "d1pkgweb/deb822" "fmt" "net/http" "os" ) func main() { args := os.Args if len(args) < 2 { fmt.Printf("Usage: %s \n", args[0]) return } confFile := args[1] conf := readConfig(confFile) //fmt.Printf("Got config: %s\n", *conf) for _, relCfg := range conf.PkgSets { // For each release... relName := relCfg.Release for _, suiteCfg := range relCfg.Suites { // For each suite of the release suiteName := suiteCfg.Name for _, component := range suiteCfg.Components { // For each component in the suite fullURL := fmt.Sprintf("%s/%s", relCfg.RepoURL, component.URL) fmt.Fprintf(os.Stderr, "Processing: %s\n", fullURL) f, err := http.Get(fullURL) if err != nil { fmt.Fprintf(os.Stderr, "...Ignoring %s\n", fullURL) } else { uncompressed, err := gzip.NewReader(f.Body) if err != nil { fmt.Fprintf(os.Stderr, "error uncompressing %s\n", fullURL) continue } r := bufio.NewScanner(uncompressed) for s, err := deb822.ScanStanza(r); s["Package"] != ""; s, err = deb822.ScanStanza(r) { if err == nil { deb822.Stanza2HtmlPage(s, pkgTempl, ".", relName, suiteName, component.Name) } else { fmt.Printf("error: %s\n", err) } } } } } } }