diff options
| author | Jeff Carr <[email protected]> | 2025-10-03 15:04:11 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-10-03 15:04:11 -0500 |
| commit | deed575dd7f1ef60477065f6e543a57faa08aa4d (patch) | |
| tree | 62ce201144c3be3b214d4e45898e1c1a6a35ff8a | |
| parent | f19039b4ae20fbf01248da9fbdf97ef93c7080d0 (diff) | |
working through logic to improve the codev0.1.2
| -rw-r--r-- | doBuild.go | 27 | ||||
| -rw-r--r-- | doDebian.go | 36 | ||||
| -rw-r--r-- | structs.go | 18 |
3 files changed, 32 insertions, 49 deletions
@@ -7,6 +7,7 @@ import ( "fmt" "os" "path/filepath" + "strings" "go.wit.com/lib/gui/shell" "go.wit.com/lib/protobuf/gitpb" @@ -53,13 +54,11 @@ func doInstallRepo(check *gitpb.Repo) error { 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) return 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) return err } } @@ -67,8 +66,6 @@ func doInstallRepo(check *gitpb.Repo) error { } func doInstallScan() { - initForge() // make sure forge is init'd here - all := me.forge.Repos.SortByFullPath() for all.Scan() { check := all.Next() @@ -86,13 +83,14 @@ func doInstallScan() { continue } + if check.GetState() == "" || check.GetState() == "PERFECT" { + check.State = "need to build" + } + // 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()) @@ -132,16 +130,17 @@ func doInstallScan() { // log.Info(debname, "does not exist") } - if check.GetState() == "" { - check.State = "need to build" - } - start = fmt.Sprintf("%-15s %-20s %-50s", check.GetState(), ver, debname) + start = fmt.Sprintf("%-18s %-24s %-50s", check.GetState(), ver, debname) if check.GetState() == "need to build" { - end += " (will build) " + end = "(will build)" + end } - log.Info(start, end) + end = strings.TrimSpace(end) + if end == "" { + end = check.GetState() + } + log.Info(start, check.GetRepoType(), end) if name == "" { // err := fmt.Sprintf("name is blank error %+v", repo) log.Warn("name is blank error", check.GetGoPath()) @@ -151,6 +150,7 @@ func doInstallScan() { func doInstall() error { initForge() + doInstallScan() found := gitpb.NewRepos() for check := range me.forge.Repos.IterAll() { @@ -170,7 +170,6 @@ func doInstall() error { me.forge.PrintForgedTable(found) if argv.DryRun { - doInstallScan() okExit("") } diff --git a/doDebian.go b/doDebian.go index 333b99f..0a2617a 100644 --- a/doDebian.go +++ b/doDebian.go @@ -4,7 +4,6 @@ package main import ( - "fmt" "os" "path/filepath" @@ -28,6 +27,7 @@ func doDebian() { } initForge() + doInstallScan() found := gitpb.NewRepos() for check := range me.forge.Repos.IterAll() { @@ -46,31 +46,31 @@ func doDebian() { } me.forge.PrintForgedTable(found) - if argv.DryRun { - doInstallScan() - okExit("") - } - - me.forge.ConfigRill(16, 16) - stats := me.forge.RunOnRepos(found, doInstallRepo) - for s, stat := range stats { - if stat.Err == nil { - continue + 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) + badExit(stat.Err) } - dur := stat.End.Sub(stat.Start) - log.Info("CRAP. INSTALL FAILED", shell.FormatDuration(dur), s, stat.Err) - badExit(stat.Err) } me.forge.ConfigRill(16, 16) log.Info("STARTING .deb BUILDS repo len =", found.Len()) - stats = me.forge.RunOnRepos(found, buildDeb) + stats := me.forge.RunOnRepos(found, buildDeb) for s, stat := range stats { - log.Info(s, stat.Err) if stat.Err != nil { + log.Info("ERROR WITH buildDeb", s, stat.Err) badExit(stat.Err) } } + if argv.DryRun { + return + } exitOnErrorRealtime([]string{"do-aptly"}) } @@ -91,9 +91,6 @@ func buildDeb(check *gitpb.Repo) error { return nil } - // computes the state hash todo: move this logic into the protobuf - doInstallScan() - if argv.Force { // build everything no matter what } else { @@ -115,7 +112,6 @@ func buildDeb(check *gitpb.Repo) error { var err error if _, err = check.RunVerboseOnError(cmd); err != nil { log.Info(check.FullPath, cmd) - failed[check] = fmt.Sprint("godeb failed", cmd, "with", err) return err } @@ -9,7 +9,6 @@ import ( "go.wit.com/lib/gui/prep" "go.wit.com/lib/protobuf/forgepb" - "go.wit.com/lib/protobuf/gitpb" "go.wit.com/lib/protobuf/zoopb" ) @@ -24,12 +23,6 @@ type mainType struct { homedir string // where the user homedir is } -// move these to mainType -var failed map[*gitpb.Repo]string - -// var state map[*gitpb.Repo]string -// var debnames map[*gitpb.Repo]string - func initForge() { if me.forge == nil { me.forge = forgepb.Init() @@ -46,12 +39,7 @@ func initMachine() { func initMain() { // autocomplete must be processed before there is anything sent to STDOUT or STDERR - me.auto = prep.Bash3(&argv) // add support for bash autocomplete with go-arg - - failed = make(map[*gitpb.Repo]string) - // state = make(map[*gitpb.Repo]string) - // debnames = make(map[*gitpb.Repo]string) - - me.homedir, _ = os.UserHomeDir() - dumpDebug() + me.auto = prep.Bash3(&argv) // add support for bash autocomplete with go-arg + me.homedir, _ = os.UserHomeDir() // store shortcut here todo: add better logic + dumpDebug() // tinkering } |
