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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
|
// Copyright 2017-2025 WIT.COM Inc. All rights reserved.
// Use of this source code is governed by the GPL 3.0
package main
import (
"os"
"path/filepath"
"go.wit.com/lib/gui/shell"
"go.wit.com/lib/protobuf/gitpb"
"go.wit.com/log"
)
func doDebian() error {
// clean out old deb files
globPattern := filepath.Join(me.homedir, "incoming", "*.deb")
files, err := filepath.Glob(globPattern)
if err != nil {
log.Info("Error during globbing:", err)
return err
}
if len(files) > 0 {
cmd := []string{"rm"}
cmd = append(cmd, files...)
_, err := shell.RunRealtimeError(cmd)
return err
}
initForge()
// doInstallScan()
found := gitpb.NewRepos()
for check := range me.forge.Repos.IterAll() {
if me.forge.Config.IsReadOnly(check.GetNamespace()) {
continue
}
if !check.IsBinary() {
continue
}
found.Append(check)
}
printPackagingTable(found)
// func (f *Forge) isInstalled(repo *gitpb.Repo) string {
// return "X"
// }
if !argv.DryRun {
me.forge.ConfigRill(16, 16)
stats := me.forge.RunOnRepos(found, doInstallRepo)
for s, stat := range stats {
if stat.Err == nil {
continue
}
dur := stat.End.Sub(stat.Start)
log.Info("CRAP. INSTALL FAILED", shell.FormatDuration(dur), s, stat.Err)
return stat.Err
}
}
if err := doOnlyDebianPackages(); err != nil {
return err
}
if !argv.DryRun {
_, err = shell.RunRealtimeError([]string{"do-aptly"})
return err
}
return nil
}
// avoids nil panics
func isDebianRelease() bool {
if argv.Build == nil {
return false
}
if argv.Build.Debian == nil {
return false
}
return argv.Build.Debian.Release
}
func shouldBuild(check *gitpb.Repo) bool {
if isPackageOnMirrors(check) {
return false
}
return true
}
func buildDeb(check *gitpb.Repo) error {
var cmd []string
outdir := getOutdir(check)
os.MkdirAll(outdir, 0755)
if isDebianRelease() {
cmd = []string{"go-deb", "--release", "--namespace", check.Namespace, "--dir", outdir}
} else {
cmd = []string{"go-deb", "--namespace", check.Namespace, "--dir", outdir}
}
if me.forge.Config.IsPrivate(check.GetNamespace()) {
cmd = []string{"go-deb", "--namespace", check.Namespace, "--dir", outdir}
return nil
}
if argv.Verbose || argv.Force {
// log.Info("build cmd:", cmd)
cmd = append(cmd, "--verbose")
}
if !shouldBuild(check) {
return nil
}
if argv.DryRun {
log.Info("RUN:", check.FullPath, cmd)
return nil
}
log.Info("Building .deb", cmd)
var err error
if _, err = check.RunVerboseOnError(cmd); err != nil {
log.Info(check.FullPath, cmd)
return err
}
log.Info("build worked", cmd, check.FullPath)
return nil
}
func getOutdir(repo *gitpb.Repo) string {
if me.forge.Config.IsPrivate(repo.GetNamespace()) {
return "/home/jcarr/incoming-private"
}
if argv.Force {
return "/home/jcarr/incoming"
}
if repo.GetLastTag() != repo.GetMasterVersion() {
return "/home/jcarr/incoming-devel"
}
if repo.GetCurrentBranchVersion() != repo.GetMasterVersion() {
return "/home/jcarr/incoming-devel"
}
if repo.CheckDirty() {
return "/home/jcarr/incoming-devel"
}
return "/home/jcarr/incoming"
}
func doOnlyDebianPackages() error {
// clean out old deb files
globPattern := filepath.Join(me.homedir, "incoming", "*.deb")
files, err := filepath.Glob(globPattern)
if err != nil {
log.Info("Error during globbing:", err)
return err
}
if len(files) > 0 {
cmd := []string{"rm"}
cmd = append(cmd, files...)
_, err := shell.RunRealtimeError(cmd)
return err
}
initForge()
found := gitpb.NewRepos()
for check := range me.forge.Repos.IterAll() {
if me.forge.Config.IsReadOnly(check.GetNamespace()) {
continue
}
if !check.IsBinary() {
continue
}
found.Append(check)
}
printPackagingTable(found)
me.forge.ConfigRill(16, 16)
log.Info("STARTING .deb BUILDS repo len =", found.Len())
stats := me.forge.RunOnRepos(found, buildDeb)
for s, stat := range stats {
if stat.Err != nil {
log.Info("ERROR WITH buildDeb", s, stat.Err)
return stat.Err
}
}
return nil
}
|