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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
|
// Copyright 2017-2025 WIT.COM Inc. All rights reserved.
// Use of this source code is governed by the GPL 3.0
package main
import (
"fmt"
"os"
"path/filepath"
"strings"
"go.wit.com/lib/protobuf/gitpb"
"go.wit.com/log"
)
func isPackageOnMirrors(repo *gitpb.Repo) bool {
manufactured := repo.GetCurrentVersion()
ver := trimNonNumericFromStart(manufactured)
name := me.forge.Config.DebName(repo.GetGoPath())
if actualp := me.machine.FindByVersion(name, ver); actualp != nil {
// end += " (version match) " + actualp.Version + " " + ver + " "
// repo.State = "on mirrors"
return true
}
return false
}
func printRepos(pb *gitpb.Repos) {
tablePB := pb.NewTable("deb details")
tablePB.NewUuid()
var col *gitpb.RepoFunc
col = tablePB.AddNamespace()
col.Width = 32
col = tablePB.AddStringFunc("RepoType", func(r *gitpb.Repo) string {
return me.forge.GetRepoType(r)
})
col.Width = 8
col = tablePB.AddStringFunc("Build Version", func(r *gitpb.Repo) string {
return me.forge.GetPackageVersion(r)
})
col.Width = 24
col = tablePB.AddStringFunc("is old", func(r *gitpb.Repo) string {
manufactured := r.GetCurrentVersion()
ver := trimNonNumericFromStart(manufactured)
name := me.forge.Config.DebName(r.GetGoPath())
if actualp := me.machine.FindByVersion(name, ver); actualp != nil {
// end += " (version match) " + actualp.Version + " " + ver + " "
return ""
}
if installedPackage := me.machine.FindInstalledByName(name); installedPackage != nil {
return installedPackage.Version
}
return ""
})
col.Width = 10
col = tablePB.AddStringFunc("I", func(r *gitpb.Repo) string {
name := me.forge.Config.DebName(r.GetNamespace())
if me.machine.IsInstalled(name) {
return "X"
}
// debname := me.forge.Config.DebName(r.GetNamespace())
// if actualp := me.machine.FindInstalledByName(debname); actualp != nil {
// return "X"
// }
return ""
})
col.Width = 1
col = tablePB.AddStringFunc("done", func(r *gitpb.Repo) string {
if isPackageOnMirrors(r) {
return "yes"
}
return ""
})
col.Width = 4
col = tablePB.AddStringFunc("build", func(r *gitpb.Repo) string {
if willBuild(r) {
return "yes"
}
return ""
})
col.Width = 5
col = tablePB.AddStringFunc("deb name", func(r *gitpb.Repo) string {
name := me.forge.Config.DebName(r.GetNamespace())
ver := me.forge.GetPackageVersion(r)
debname := name + "_" + ver + "_amd64.deb"
return debname
})
col.Width = 32
col = tablePB.AddState()
col.Width = 32
col = tablePB.AddStringFunc("end", func(r *gitpb.Repo) string {
return getStatusEnd(r)
})
col.Width = -1
tablePB.PrintTable()
}
func getStatusEnd(repo *gitpb.Repo) string {
var end string
manufactured := repo.GetCurrentVersion()
ver := trimNonNumericFromStart(manufactured)
name := me.forge.Config.DebName(repo.GetGoPath())
var realver string
if installedPackage := me.machine.FindInstalledByName(name); installedPackage != nil {
realver = installedPackage.Version
}
if actualp := me.machine.FindByVersion(name, ver); actualp != nil {
// end += " (version match) " + actualp.Version + " " + ver + " "
// repo.State = "on mirrors"
} else {
if realver != "" {
end += fmt.Sprintf(" (version miss) %s vs %s ", realver, ver)
}
// end += "" + ver + " "
}
debname := name + "_" + ver + "_amd64.deb"
// debnames[repo] = debname
outdir := getOutdir(repo)
_, err := os.Stat(filepath.Join(outdir, debname))
if err == nil {
// log.Info("exists", filepath.Join(outdir, debname))
repo.State = "in incoming"
} else {
// log.Info(debname, "does not exist")
}
if strings.HasPrefix(repo.GetState(), "unknown bran") {
end += " (will build) "
}
if repo.State == "" {
end += " (will build) "
}
if repo.State == "need to build" {
end += " (will build) "
}
if name == "" {
// err := fmt.Sprintf("name is blank error %+v", repo)
log.Warn("name is blank error", repo.GetGoPath())
}
return end
}
func willBuild(repo *gitpb.Repo) bool {
if strings.HasPrefix(repo.GetState(), "unknown bran") {
return true
}
if repo.State == "" {
return true
}
if repo.State == "need to build" {
return true
}
return false
}
|