-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathk-info.go
86 lines (77 loc) · 2.26 KB
/
k-info.go
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
package main
import (
"fmt"
"github.com/bjf/ktCore"
)
func printInfo(record map[string]interface{}) {
var ok bool
if _, ok = record["development"]; ok {
fmt.Printf(" development : %t\n", record["development"])
} else {
fmt.Printf(" development : false\n")
}
fmt.Printf(" series version : %s\n", record["series_version"])
fmt.Printf(" series name : %s\n", record["name"])
fmt.Printf(" kernel version : %s\n", record["kernel"])
fmt.Printf(" is supported : %t\n", record["supported"])
// packages
//
fmt.Printf(" packages : ")
pkgs := record["packages"].([]string)
if len(pkgs) > 0 {
for _, p := range pkgs {
fmt.Printf("%s ", p)
}
} else {
fmt.Printf("none")
}
fmt.Printf("\n")
// dependent-packages
//
fmt.Printf(" dependent packages : ")
if _, ok = record["dependent-packages"]; ok {
depPkgs := record["dependent-packages"].(map[string]map[string]string)
for k1, v1 := range depPkgs {
fmt.Printf("[%s] ", k1)
depPkg := v1
for _, v2 := range depPkg {
fmt.Printf("%s ", v2)
}
}
fmt.Printf("\n")
} else {
fmt.Printf(" none\n")
}
// derivative-packages
//
fmt.Printf(" derivative packages : ")
if _, ok = record["derivative-packages"]; ok {
derPkgs := record["derivative-packages"].(map[string][]string)
if len(derPkgs) > 0 {
for _, p := range derPkgs {
for _, p3 := range p {
fmt.Printf("%s ", p3)
}
}
} else {
fmt.Printf("none")
}
fmt.Printf("\n")
} else {
fmt.Printf(" none\n")
}
}
func main() {
var kp = core.NewUbuntuKernelsDB()
printInfo(kp.IndexByKernelVersion("3.13.0"))
fmt.Printf("\n")
printInfo(kp.IndexByKernelVersion("3.11.0"))
fmt.Printf("\n")
fmt.Printf("\n")
printInfo(kp.IndexBySeriesName("precise"))
// for seriesVersion, _ := range core.DB {
// fmt.Printf("%s\n", seriesVersion)
// printInfo(core.DB[seriesVersion])
// fmt.Printf("\n")
// }
}