diff options
| author | Jeff Carr <[email protected]> | 2025-10-03 13:13:40 -0500 | 
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-10-03 13:13:40 -0500 | 
| commit | 888ef5304907d0e8a98472a31728b5398972b647 (patch) | |
| tree | 6b72b9e0d991b42084201f44e41e74a61e5ceaa9 | |
| parent | 37aeae9b8ff49f42a135a1ff4255835889f2eeba (diff) | |
new argv stuffv0.1.1
| -rw-r--r-- | argv.go | 44 | ||||
| -rw-r--r-- | debian.go | 5 | ||||
| -rw-r--r-- | doInstall.go | 170 | ||||
| -rw-r--r-- | main.go | 16 | 
4 files changed, 75 insertions, 160 deletions
@@ -21,26 +21,28 @@ import (  var argv args  type args struct { -	Git         *GitCmd     `arg:"subcommand:git"                help:"git stuff"` -	TestBuild   *DefaultCmd `arg:"subcommand:build"              help:"try appropriate 'go build'"` -	Debian      *DebianCmd  `arg:"subcommand:debian"             help:"build missing .deb packages"` -	MacBuild    *EmptyCmd   `arg:"subcommand:macos"              help:"build macos packages"` -	MakeInstall *DefaultCmd `arg:"subcommand:install"            help:"run make install in each repo"` -	ListPkgs    *EmptyCmd   `arg:"subcommand:list"               help:"list all the packages on mirrors.wit.com"` -	Test        *EmptyCmd   `arg:"subcommand:test"               help:"test build everything first"` -	Clone       *CloneCmd   `arg:"subcommand:clone"              help:"go-clone from a gowebd repomap"` -	Rdate       *EmptyCmd   `arg:"subcommand:rdate"              help:"standard rdate"` -	Zoo         *EmptyCmd   `arg:"subcommand:zoo"                help:"WIT Private Cloud info"` -	Upgrade     *UpgradeCmd `arg:"subcommand:upgrade"            help:"apt upgrade packages installed from mirrors.wit.com"` -	RepoMap     string      `arg:"--repomap"                     help:"location of the repomap"` -	Release     bool        `arg:"--release"                     help:"use go-deb --release"` -	DryRun      bool        `arg:"--dry-run"                     help:"only show what would be packaged"` -	Install     bool        `arg:"--install"                     help:"go install the binaries first"` -	Verbose     bool        `arg:"--verbose"                     help:"be loud about it"` -	Force       bool        `arg:"--force"                       help:"rebuild everything"` -	Recursive   bool        `arg:"--recursive"                   help:"go-clone --recursive"` -	WITCOM      bool        `arg:"--witcom"                      help:"add the GPL header"` -	Max         int32       `arg:"--max"                         help:"stop building after max builds"` +	Git       *GitCmd     `arg:"subcommand:git"                help:"git stuff"` +	Build     *BuildCmd   `arg:"subcommand:build"              help:"build and install things"` +	ListPkgs  *EmptyCmd   `arg:"subcommand:list"               help:"list all the packages on mirrors.wit.com"` +	Clone     *CloneCmd   `arg:"subcommand:clone"              help:"go-clone from a gowebd repomap"` +	Rdate     *EmptyCmd   `arg:"subcommand:rdate"              help:"standard rdate"` +	Zoo       *EmptyCmd   `arg:"subcommand:zoo"                help:"WIT Private Cloud info"` +	Upgrade   *UpgradeCmd `arg:"subcommand:upgrade"            help:"apt upgrade packages installed from mirrors.wit.com"` +	RepoMap   string      `arg:"--repomap"                     help:"location of the repomap"` +	Release   bool        `arg:"--release"                     help:"use go-deb --release"` +	DryRun    bool        `arg:"--dry-run"                     help:"only show what would be packaged"` +	Install   bool        `arg:"--install"                     help:"go install the binaries first"` +	Verbose   bool        `arg:"--verbose"                     help:"be loud about it"` +	Force     bool        `arg:"--force"                       help:"rebuild everything"` +	Recursive bool        `arg:"--recursive"                   help:"go-clone --recursive"` +	WITCOM    bool        `arg:"--witcom"                      help:"add the GPL header"` +	Max       int32       `arg:"--max"                         help:"stop building after max builds"` +} + +type BuildCmd struct { +	Debian   *DebianCmd  `arg:"subcommand:debian"             help:"build missing .deb packages"` +	MacBuild *EmptyCmd   `arg:"subcommand:macos"              help:"build macos packages"` +	Install  *DefaultCmd `arg:"subcommand:install"            help:"run make install in each repo"`  }  type DebianCmd struct { @@ -114,7 +116,7 @@ func (args) Appname() string {  }  func (a args) DoAutoComplete(pb *prep.Auto) { -	base := []string{"--version", "build", "debian", "upgrade", "git", "--force"} +	base := []string{"--version", "build", "upgrade", "git", "--force"}  	if _, err := fhelp.CheckCmd("zood"); err == nil {  		base = append(base, "zoo")  	} @@ -56,11 +56,6 @@ func buildDeb(check *gitpb.Repo) error {  		}  	} -	if argv.MacBuild != nil { -		log.Info("todo: add mac builds") -		return nil -	} -  	var err error  	if _, err = check.RunVerboseOnError(cmd); err != nil {  		log.Info(check.FullPath, cmd) 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  } @@ -33,13 +33,13 @@ func main() {  		okExit("")  	} -	if argv.Debian != nil { -		doDebian() +	if argv.Rdate != nil { +		doRdate()  		okExit("")  	} -	if argv.Rdate != nil { -		doRdate() +	if argv.Build != nil { +		doBuild()  		okExit("")  	} @@ -105,14 +105,6 @@ func main() {  		okExit("")  	} -	if argv.MakeInstall != nil { -		if err := doInstall(); err != nil { -			log.Info("doInstall() failed", err) -			badExit(err) -		} -		okExit("EVERYTHING BUILT!") -	} -  	okExit("do what?")  }  | 
