2025-02-01 11:38:22 -06:00
|
|
|
// Copyright 2017-2025 WIT.COM Inc. All rights reserved.
|
|
|
|
// Use of this source code is governed by the GPL 3.0
|
|
|
|
|
2024-12-24 04:47:58 -06:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
|
|
|
|
"go.wit.com/lib/protobuf/gitpb"
|
|
|
|
"go.wit.com/log"
|
|
|
|
)
|
|
|
|
|
|
|
|
func buildDeb() {
|
|
|
|
log.DaemonMode(true)
|
|
|
|
defer log.DaemonMode(false)
|
|
|
|
|
2025-02-14 17:27:00 -06:00
|
|
|
if err := doInstall(); err != nil {
|
|
|
|
log.Info("doInstall() failed", err)
|
|
|
|
badExit(err)
|
|
|
|
}
|
|
|
|
|
2024-12-24 04:47:58 -06:00
|
|
|
all := me.forge.Repos.SortByFullPath()
|
|
|
|
for all.Scan() {
|
|
|
|
var cmd []string
|
|
|
|
check := all.Next()
|
|
|
|
|
|
|
|
outdir := getOutdir(check)
|
|
|
|
os.MkdirAll(outdir, 0755)
|
|
|
|
|
2025-02-14 17:27:00 -06:00
|
|
|
if me.forge.Config.IsReadOnly(check.GetGoPath()) {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
if !check.IsBinary() {
|
2024-12-24 04:47:58 -06:00
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
2025-02-14 20:39:50 -06:00
|
|
|
if check.IsGoPlugin() {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
2024-12-24 04:47:58 -06:00
|
|
|
if argv.Release {
|
2025-02-14 17:27:00 -06:00
|
|
|
cmd = []string{"go-deb", "--release", "--no-gui", "--auto", "--forge", check.GetGoPath(), "--dir", outdir}
|
2024-12-24 04:47:58 -06:00
|
|
|
} else {
|
2025-01-18 15:48:15 -06:00
|
|
|
cmd = []string{"go-deb", "--auto", "--no-gui", "--forge", check.GetGoPath(), "--dir", outdir}
|
2024-12-24 04:47:58 -06:00
|
|
|
}
|
|
|
|
if me.forge.Config.IsPrivate(check.GetGoPath()) {
|
2025-02-14 17:27:00 -06:00
|
|
|
cmd = []string{"go-deb", "--auto", "--no-gui", "--forge", check.GetGoPath(), "--dir", outdir}
|
|
|
|
continue
|
2024-12-24 04:47:58 -06:00
|
|
|
}
|
2025-02-14 17:27:00 -06:00
|
|
|
|
|
|
|
if argv.Verbose {
|
|
|
|
log.Info("build cmd:", cmd)
|
2025-02-20 09:39:31 -06:00
|
|
|
cmd = append(cmd, "--verbose")
|
2025-02-14 17:27:00 -06:00
|
|
|
}
|
|
|
|
if argv.DryRun {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
if argv.Force {
|
|
|
|
// build everything no matter what
|
|
|
|
} else {
|
|
|
|
if state[check] != "need to build" {
|
|
|
|
// log.Info("skipping build for", check.GetGoPath(), state[check])
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
_, err := os.Stat(filepath.Join(outdir, debnames[check]))
|
|
|
|
if err == nil {
|
|
|
|
if debnames[check] == "" {
|
|
|
|
log.Info("something went wrong. .deb blank", check.GetGoPath())
|
|
|
|
}
|
|
|
|
// already built
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
|
|
if err := check.RunVerbose(cmd); err != nil {
|
|
|
|
failed[check] = fmt.Sprint("godeb failed", cmd, "with", err)
|
|
|
|
badExit(err)
|
2024-12-24 04:47:58 -06:00
|
|
|
} else {
|
|
|
|
log.Info("build worked")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func getOutdir(repo *gitpb.Repo) string {
|
|
|
|
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"
|
|
|
|
}
|
|
|
|
|
|
|
|
if me.forge.Config.IsPrivate(repo.GetGoPath()) {
|
|
|
|
return "/home/jcarr/incoming-private"
|
|
|
|
}
|
|
|
|
return "/home/jcarr/incoming"
|
|
|
|
}
|