complete restructure

This commit is contained in:
Jeff Carr 2025-02-14 17:27:00 -06:00
parent 22e0cbe022
commit 339f5ff27e
7 changed files with 311 additions and 28 deletions

View File

@ -32,3 +32,17 @@ gpl:
check-git-clean:
@git diff-index --quiet HEAD -- || (echo "Git repository is dirty, please commit your changes first"; exit 1)
debian-release: install
wit-test debian --dry-run --verbose --release
debian-release-force: install
rm -f ~/incoming/*.deb
forge --install go.wit.com/apps/go-deb
go-deb -h # check to make sure go-deb builds
-wit-test debian --force --verbose --release
ls -hl ~/incoming/
dpkg-deb -c ~/incoming/go-gui-toolkits*.deb
debian-force: install
wit-test debian --force --verbose

View File

@ -27,6 +27,7 @@ type args struct {
Release bool `arg:"--release" help:"use go-deb --release"`
DryRun bool `arg:"--dry-run" help:"only show what would be packaged"`
Verbose bool `arg:"--verbose" help:"be loud about it"`
Force bool `arg:"--force" help:"rebuild everything"`
Recursive bool `arg:"--recursive" help:"go-clone --recursive"`
Test bool `arg:"--test" help:"test build after everything else"`
WITCOM bool `arg:"--witcom" help:"add the GPL header"`

View File

@ -6,56 +6,76 @@ package main
import (
"fmt"
"os"
"path/filepath"
"go.wit.com/lib/protobuf/gitpb"
"go.wit.com/log"
)
func buildDeb() {
if argv.DryRun {
return
}
log.DaemonMode(true)
defer log.DaemonMode(false)
if err := doInstall(); err != nil {
log.Info("doInstall() failed", err)
badExit(err)
}
all := me.forge.Repos.SortByFullPath()
for all.Scan() {
var cmd []string
check := all.Next()
if state[check] != "need to build" {
// log.Info("skipping build for", check.GetGoPath(), state[check])
continue
}
outdir := getOutdir(check)
os.MkdirAll(outdir, 0755)
_, 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
if me.forge.Config.IsReadOnly(check.GetGoPath()) {
continue
}
if !check.IsBinary() {
continue
}
if argv.Release {
cmd = []string{"go-deb", "--release", "--auto", "--forge", check.GetGoPath(), "--dir", outdir}
cmd = []string{"go-deb", "--release", "--no-gui", "--auto", "--forge", check.GetGoPath(), "--dir", outdir}
} else {
cmd = []string{"go-deb", "--auto", "--no-gui", "--forge", check.GetGoPath(), "--dir", outdir}
}
if me.forge.Config.IsPrivate(check.GetGoPath()) {
cmd = []string{"go-deb", "--auto", "--forge", check.GetGoPath(), "--dir", outdir}
cmd = []string{"go-deb", "--auto", "--no-gui", "--forge", check.GetGoPath(), "--dir", outdir}
continue
}
log.Info("build cmd:", cmd)
if r := check.RunRealtime(cmd); r.Error != nil {
log.Info("go-deb failed error:", r.Error, check.GetGoPath())
failed[check] = fmt.Sprint("godeb failed", cmd, "with", r.Exit, r.Error)
} else if r.Exit != 0 {
log.Info("go-deb failed exit =", r.Exit, check.GetGoPath())
failed[check] = fmt.Sprint("godeb failed", cmd, "with", r.Exit, r.Error)
if argv.Verbose {
log.Info("build cmd:", cmd)
}
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)
} else {
log.Info("build worked")
}

145
doInstall.go Normal file
View File

@ -0,0 +1,145 @@
// Copyright 2017-2025 WIT.COM Inc. All rights reserved.
// Use of this source code is governed by the GPL 3.0
package main
import (
"errors"
"fmt"
"os"
"path/filepath"
"go.wit.com/log"
)
func doInstall() error {
all := me.forge.Repos.SortByFullPath()
for all.Scan() {
check := all.Next()
repotype := check.GetRepoType()
if repotype == "binary" || repotype == "plugin" {
// we only want to process things that can be compiled with 'go build'
} else {
// log.Info("skipping repo", check.GetGoPath(), repotype)
continue
}
if me.forge.Config.IsReadOnly(check.GetGoPath()) {
// ignore read only stuff
continue
}
// var cmd []string
var start string
var end string
// add te repotype
end += check.GetRepoType()
manufactured := check.GetCurrentVersion()
ver := trimNonNumericFromStart(manufactured)
name := me.forge.Config.DebName(check.GetGoPath())
var realver string
if installedPackage := me.forge.Machine.FindInstalledByName(name); installedPackage != nil {
realver = installedPackage.Version
}
if actualp := me.forge.Machine.FindVersion(name, ver); actualp != nil {
end += " (version match) " + actualp.Version + " " + ver + " "
state[check] = "on mirrors"
} else {
if realver != "" {
end += fmt.Sprintf(" (version miss) %s vs %s ", realver, ver)
}
// end += "" + ver + " "
}
if me.forge.Machine.IsInstalled(name) {
if actualp := me.forge.Machine.FindInstalledByName(name); actualp != nil {
if ver != actualp.Version {
end += "(installed " + actualp.Version + ") "
} else {
end += "(installed ok) "
}
} else {
end += "(installed) "
}
}
debname := name + "_" + ver + "_amd64.deb"
debnames[check] = debname
outdir := getOutdir(check)
_, err := os.Stat(filepath.Join(outdir, debname))
if err == nil {
// log.Info("exists", filepath.Join(outdir, debname))
state[check] = "in incoming"
} else {
// log.Info(debname, "does not exist")
}
if state[check] == "" {
state[check] = "need to build"
}
start = fmt.Sprintf("%-15s %-20s %-50s", state[check], ver, debname)
if state[check] == "need to build" {
end += " (will build) "
}
log.Info(start, end)
if name == "" {
// err := fmt.Sprintf("name is blank error %+v", repo)
log.Warn("name is blank error", check.GetGoPath())
}
if argv.DryRun {
continue
}
if argv.TestBuild != nil {
if argv.DryRun {
continue
}
if argv.Verbose {
verbose := []string{"-v", "-x"}
if err := me.forge.Build(check, verbose); err != nil {
log.Warn("BUILD FAILED", check.GetGoPath(), err)
failed[check] = fmt.Sprintf("%s %s %v", "go build", check.GetGoPath(), err)
}
} else {
if err := me.forge.Build(check, nil); err != nil {
log.Warn("BUILD FAILED", check.GetGoPath(), err)
failed[check] = fmt.Sprintf("%s %s %v", "go build", check.GetGoPath(), err)
}
}
continue
}
log.Info("STARTING 'make install' in", check.GetGoPath())
if argv.DryRun {
continue
}
if argv.Verbose {
verbose := []string{"-v", "-x"}
if err := me.forge.Install(check, verbose); err != nil {
log.Warn("INSTALL FAILED", check.GetGoPath(), err)
failed[check] = fmt.Sprintf("%s %s %v", "go install", check.GetGoPath(), err)
}
} else {
if err := me.forge.Install(check, nil); err != nil {
log.Warn("INSTALL FAILED", check.GetGoPath(), err)
failed[check] = fmt.Sprintf("%s %s %v", "go install", check.GetGoPath(), err)
}
}
}
if len(failed) != 0 {
log.Info("")
log.Info("something failed on:")
for repo, cmd := range failed {
log.Info("failed cmd :", cmd, repo.GetGoPath())
}
// me.forge.CheckoutUser()
// shell.Run([]string{"forge", "--find-private"})
badExit(errors.New("some repos failed"))
return errors.New("some repos failed")
}
return nil
}

93
doListRepos.go Normal file
View File

@ -0,0 +1,93 @@
// 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"
"go.wit.com/log"
)
func doListRepos() {
all := me.forge.Repos.SortByFullPath()
for all.Scan() {
check := all.Next()
repotype := check.GetRepoType()
if repotype == "binary" || repotype == "plugin" {
// we only want to process things that can be compiled with 'go build'
} else {
// log.Info("skipping repo", check.GetGoPath(), repotype)
continue
}
if me.forge.Config.IsReadOnly(check.GetGoPath()) {
// ignore read only stuff
continue
}
// var cmd []string
var start string
var end string
// add te repotype
end += check.GetRepoType()
manufactured := check.GetCurrentVersion()
ver := trimNonNumericFromStart(manufactured)
name := me.forge.Config.DebName(check.GetGoPath())
var realver string
if installedPackage := me.forge.Machine.FindInstalledByName(name); installedPackage != nil {
realver = installedPackage.Version
}
if actualp := me.forge.Machine.FindVersion(name, ver); actualp != nil {
end += " (version match) " + actualp.Version + " " + ver + " "
state[check] = "on mirrors"
} else {
if realver != "" {
end += fmt.Sprintf(" (version miss) %s vs %s ", realver, ver)
}
// end += "" + ver + " "
}
if me.forge.Machine.IsInstalled(name) {
if actualp := me.forge.Machine.FindInstalledByName(name); actualp != nil {
if ver != actualp.Version {
end += "(installed " + actualp.Version + ") "
} else {
end += "(installed ok) "
}
} else {
end += "(installed) "
}
}
debname := name + "_" + ver + "_amd64.deb"
debnames[check] = debname
outdir := getOutdir(check)
_, err := os.Stat(filepath.Join(outdir, debname))
if err == nil {
// log.Info("exists", filepath.Join(outdir, debname))
state[check] = "in incoming"
} else {
// log.Info(debname, "does not exist")
}
if state[check] == "" {
state[check] = "need to build"
}
start = fmt.Sprintf("%-15s %-20s %-50s", state[check], ver, debname)
if state[check] == "need to build" {
end += " (will build) "
}
log.Info(start, end)
if name == "" {
// err := fmt.Sprintf("name is blank error %+v", repo)
log.Warn("name is blank error", check.GetGoPath())
}
}
}

View File

@ -1,7 +1,6 @@
// Copyright 2017-2025 WIT.COM Inc. All rights reserved.
// Use of this source code is governed by the GPL 3.0
package main
import (

17
main.go
View File

@ -102,6 +102,20 @@ func main() {
okExit("")
}
doListRepos()
if argv.DebBuild != nil {
buildDeb()
okExit("")
}
if argv.MakeInstall != nil {
if err := doInstall(); err != nil {
log.Info("doInstall() failed", err)
badExit(err)
} else {
okExit("EVERYTHING BUILT!")
}
}
all := me.forge.Repos.SortByFullPath()
for all.Scan() {
check := all.Next()
@ -222,9 +236,6 @@ func main() {
continue
}
}
if argv.DebBuild != nil {
buildDeb()
}
if len(failed) != 0 {
log.Info("")
log.Info("something failed on:")