func main() { log.Println("Program start") // Without flag.Parse(), -h doesn't work. flag.Parse() // Parse the template early. t := template.Must(template.New("tmpl").Parse(markdownTmpl)) spec := diskformat.CatalogSpec{ "unstable", "i386", "SunOS5.10", } log.Println("Looking at catalog ", spec, " only.") inGarByPkgname := make(map[string]PackageWithExtraData) if cws, err := diskformat.GetCatalogWithSpec(spec); err != nil { log.Fatalln("Error unmarshalling JSON data:", err) } else { var count = 0 for _, pkg := range cws.Pkgs { log.Println("Processing", fmt.Sprintf("%+v", pkg)) stats, err := GetPkgstats(pkg.Md5_sum) if err != nil { log.Fatalln("Failed to fetch: ", pkg.Md5_sum, " because ", err) } _, inGar := stats.Pkginfo["OPENCSW_REPOSITORY"] log.Println("Result: ", pkg.Md5_sum, "is", inGar) var pwed PackageWithExtraData pwed.Pkg = pkg pwed.InGar = inGar inGarByPkgname[pkg.Catalogname] = pwed count += 1 if testingRun && count > 10 { break } } } f, err := os.Create(outputFile) if err != nil { panic(err) } defer f.Close() var td TemplateData td.Pkgs = make([]PackageWithExtraData, 0) for _, pkg := range inGarByPkgname { td.Pkgs = append(td.Pkgs, pkg) } sort.Sort(ByCatalogname(td.Pkgs)) td.Date = time.Now() if err := t.Execute(f, td); err != nil { log.Fatal(err) } log.Println("Finished, potentially successfully.") }
func main() { flag.Parse() spec := diskformat.CatalogSpec{catrel_flag, arch_flag, osrel_flag} cws, err := diskformat.GetCatalogWithSpec(spec) if err != nil { log.Fatalln("Could not fetch", spec, ":", err) } catalog_fd, err := os.Create(out_file) if err != nil { log.Fatalln("Could not open the output file for writing:", err) } defer catalog_fd.Close() catbuf := bufio.NewWriter(catalog_fd) defer catbuf.Flush() log.Println("Writing", spec, "to", out_file) if err = diskformat.WriteCatalogIndex(catbuf, cws); err != nil { log.Fatalln("Error while writing:", err) } else { log.Println("Catalog index written successfully") } }