summaryrefslogtreecommitdiff
path: root/d1pkgweb.go
diff options
context:
space:
mode:
authorKatolaZ <katolaz@freaknet.org>2018-01-13 01:22:02 +0000
committerKatolaZ <katolaz@freaknet.org>2018-01-13 01:22:02 +0000
commitb47d3326f6175a3fb0b997a20b3b1daa3dc9156f (patch)
treea1046ef9d37a3ae5ce9332c5dfd6ace51d8f5274 /d1pkgweb.go
parent4d5afdc2a6dfbb985fe9030cad7b0b8c3fc74819 (diff)
added yaml config file
Diffstat (limited to 'd1pkgweb.go')
-rw-r--r--d1pkgweb.go48
1 files changed, 27 insertions, 21 deletions
diff --git a/d1pkgweb.go b/d1pkgweb.go
index 89fa764..09fe675 100644
--- a/d1pkgweb.go
+++ b/d1pkgweb.go
@@ -2,10 +2,11 @@ package main
import (
"bufio"
+ "compress/gzip"
"d1pkgweb/deb822"
"fmt"
+ "net/http"
"os"
- "strings"
)
func main() {
@@ -17,29 +18,34 @@ func main() {
return
}
- fnames := args[1:]
- for _, fname := range fnames {
- nameComps := strings.Split(fname, "_")
- suite := nameComps[3]
- component := nameComps[4]
- f, err := os.Open(fname)
- if err != nil {
- defer f.Close()
- }
- if err != nil {
- fmt.Printf("Error opening file %s\n", fname)
+ confFile := args[1]
+ conf := readConfig(confFile)
- } else {
- r := bufio.NewScanner(f)
+ //fmt.Printf("Got config: %s\n", *conf)
- if r != nil {
- for s, err := deb822.ScanStanza(r); s["Package"] != ""; s, err = deb822.ScanStanza(r) {
- if err == nil {
- deb822.Stanza2HtmlPage(s, pkgTempl, ".", suite, component)
- } else {
- fmt.Printf("error: %s\n", err)
+ for _, relCfg := range conf.PkgSets { // For each release...
+ for _, suiteCfg := range relCfg.Suites { // For each suite of the release
+ suite := 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, ".", suite, component.Name)
+ } else {
+ fmt.Printf("error: %s\n", err)
+ }
}
- //WriteFiles(s, num, "./files/")
}
}
}