1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
package main
import (
"embed"
"errors"
"flag"
"fmt"
"html/template"
"io/fs"
"os"
"path/filepath"
)
//go:embed templates
var templates embed.FS
var data = TemplateData{
Categories: []Category{
"laptop",
"server",
"desktop",
"half",
"mini",
"settop",
"eval",
"sbc",
"emulation",
"misc",
"unclass",
},
CategoryNiceNames: map[Category]string{
"desktop": "Desktops / Workstations",
"server": "Servers",
"laptop": "Laptops",
"half": "Embedded / PC/104 / Half-size boards",
"mini": "Mini-ITX / Micro-ITX / Nano-ITX",
"settop": "Set-top-boxes / Thin clients",
"eval": "Devel/Eval Boards",
"sbc": "Single-Board computer",
"emulation": "Emulation",
"misc": "Miscellaneous",
"unclass": "Unclassified",
},
BoardsByCategory: map[Category][]Board{},
}
var (
cbdirFS fs.FS
cbdir string
bsdirFS fs.FS
)
func main() {
var cbDir, bsDir string
flag.StringVar(&cbDir, "coreboot-dir", filepath.Join("..", "coreboot.git"), "coreboot.git checkout")
flag.StringVar(&bsDir, "board-status-dir", filepath.Join("..", "board-status.git"), "board-status.git checkout")
flag.Parse()
tpls, err := template.ParseFS(templates, filepath.Join("templates", "*"))
if err != nil {
fmt.Fprintf(os.Stderr, "Parsing templates failed: %v\n", err)
os.Exit(1)
}
if _, err := os.Stat(cbDir); errors.Is(err, os.ErrNotExist) {
fmt.Fprintf(os.Stderr, "coreboot root %s does not exist\n", cbDir)
os.Exit(1)
}
if _, err := os.Stat(bsDir); errors.Is(err, os.ErrNotExist) {
fmt.Fprintf(os.Stderr, "board-status dir %s does not exist\n", bsDir)
os.Exit(1)
}
cbdirFS = os.DirFS(cbDir)
cbdir = cbDir
bsdirFS = os.DirFS(bsDir)
dirs := make(chan NamedFS)
go fetchLogs(dirs)
collectLogs(dirs)
dirs = make(chan NamedFS)
go fetchBoards(dirs)
collectBoards(dirs)
err = tpls.ExecuteTemplate(os.Stdout, "board-status.html", data)
if err != nil {
fmt.Fprintf(os.Stderr, "Executing template failed: %v\n", err)
os.Exit(1)
}
}
|