diff options
| author | Jeff Carr <[email protected]> | 2025-02-14 18:39:14 -0600 | 
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-02-14 18:39:14 -0600 | 
| commit | 48585f15a5d93315cf20b18edc0d8121547cb305 (patch) | |
| tree | 1929a7d91a2f59209d2a7e44f2b5ddba41ebf432 | |
| parent | 339f5ff27e96da6eb02e158aa0b33de8104618ca (diff) | |
attempt to stabilize deb package creationv0.0.30
| -rw-r--r-- | main.go | 246 | 
1 files changed, 125 insertions, 121 deletions
@@ -4,7 +4,6 @@  package main  import ( -	"errors"  	"fmt"  	"os"  	"path/filepath" @@ -103,164 +102,169 @@ func main() {  	}  	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!")  		} +		okExit("EVERYTHING BUILT!")  	} -	all := me.forge.Repos.SortByFullPath() -	for all.Scan() { -		check := all.Next() +	if argv.Test { +		homeDir, _ := os.UserHomeDir() -		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 -		} +		testdir := filepath.Join(homeDir, "go/src/go.wit.com/apps/utils/wit-utils/go-clone-test/") +		os.Chdir(testdir) +		shell.RunRealtime([]string{"go", "install"}) -		if me.forge.Config.IsReadOnly(check.GetGoPath()) { -			// ignore read only stuff -			continue +		workdir := filepath.Join(homeDir, "gowork") +		if err := os.MkdirAll(workdir, os.ModePerm); err != nil { +			badExit(err)  		} +		os.Chdir(workdir) +		shell.RunRealtime([]string{"go-clone-test"}) +	} -		// var cmd []string -		var start string -		var end string +	okExit("everything compiled") -		// add te repotype -		end += check.GetRepoType() +	/* +		all := me.forge.Repos.SortByFullPath() +		for all.Scan() { +			check := all.Next() -		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) +			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  			} -			// 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 + ") " + +			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 ok) " +					end += "(installed) "  				} -			} 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") -		} +			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] == "" { +				state[check] = "need to build" +			} +			start = fmt.Sprintf("%-15s %-20s %-50s", state[check], ver, debname) -		if state[check] == "need to build" { -			end += " (will build) " -		} +			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()) -		} +			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) +			if argv.TestBuild != nil { +				if argv.DryRun { +					continue  				} -			} 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) +				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 -		} - -		if argv.MakeInstall != nil { -			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) + +			if argv.MakeInstall != nil { +				log.Info("STARTING 'make install' in", check.GetGoPath()) +				if argv.DryRun { +					continue  				} -			} 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 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) +					}  				} +				continue  			} -			continue  		} -	} -	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")) -	} -	if argv.Test { -		homeDir, _ := os.UserHomeDir() - -		testdir := filepath.Join(homeDir, "go/src/go.wit.com/apps/utils/wit-utils/go-clone-test/") -		os.Chdir(testdir) -		shell.RunRealtime([]string{"go", "install"}) - -		workdir := filepath.Join(homeDir, "gowork") -		if err := os.MkdirAll(workdir, os.ModePerm); err != nil { -			badExit(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"))  		} -		os.Chdir(workdir) -		shell.RunRealtime([]string{"go-clone-test"}) -	} -	okExit("everything compiled") +	*/  }  // this is dumb. sync this with go-deb  | 
