summaryrefslogtreecommitdiff
path: root/doInstall.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-10-03 13:13:40 -0500
committerJeff Carr <[email protected]>2025-10-03 13:13:40 -0500
commit888ef5304907d0e8a98472a31728b5398972b647 (patch)
tree6b72b9e0d991b42084201f44e41e74a61e5ceaa9 /doInstall.go
parent37aeae9b8ff49f42a135a1ff4255835889f2eeba (diff)
new argv stuffv0.1.1
Diffstat (limited to 'doInstall.go')
-rw-r--r--doInstall.go170
1 files changed, 48 insertions, 122 deletions
diff --git a/doInstall.go b/doInstall.go
index 3269c77..28e1189 100644
--- a/doInstall.go
+++ b/doInstall.go
@@ -4,15 +4,37 @@
package main
import (
- "errors"
"fmt"
"os"
"path/filepath"
+ "go.wit.com/lib/gui/shell"
"go.wit.com/lib/protobuf/gitpb"
"go.wit.com/log"
)
+func doBuild() error {
+ if argv.Build.Install != nil {
+ if err := doInstall(); err != nil {
+ log.Info("doInstall() failed", err)
+ badExit(err)
+ }
+ okExit("EVERYTHING BUILT!")
+ }
+
+ if argv.Build.MacBuild != nil {
+ log.Info("todo: add mac builds")
+ return nil
+ }
+
+ if argv.Build.Debian != nil {
+ doDebian()
+ okExit("")
+ }
+
+ return nil
+}
+
func doInstallRepo(check *gitpb.Repo) error {
repotype := check.GetRepoType()
if repotype == "binary" || repotype == "plugin" {
@@ -44,7 +66,7 @@ func doInstallRepo(check *gitpb.Repo) error {
return nil
}
-func doInstall() error {
+func doInstallScan() {
initForge() // make sure forge is init'd here
all := me.forge.Repos.SortByFullPath()
@@ -124,139 +146,43 @@ func doInstall() error {
// 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
}
-func doInstallScan() {
- initForge() // make sure forge is init'd here
-
- 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
- }
+func doInstall() error {
+ initForge()
+ found := gitpb.NewRepos()
+ for check := range me.forge.Repos.IterAll() {
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.machine.FindInstalledByName(name); installedPackage != nil {
- realver = installedPackage.Version
- }
- if actualp := me.machine.FindByVersion(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.machine.IsInstalled(name) {
- if actualp := me.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 !check.IsBinary() {
+ continue
}
- if state[check] == "" {
- state[check] = "need to build"
+ if check.IsGoPlugin() {
+ continue
}
- start = fmt.Sprintf("%-15s %-20s %-50s", state[check], ver, debname)
+ found.Append(check)
+ }
+ me.forge.PrintForgedTable(found)
- if state[check] == "need to build" {
- end += " (will build) "
- }
+ if argv.DryRun {
+ doInstallScan()
+ okExit("")
+ }
- log.Info(start, end)
- if name == "" {
- // err := fmt.Sprintf("name is blank error %+v", repo)
- log.Warn("name is blank error", check.GetGoPath())
+ 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)
}
+ return nil
}