Compare commits
2 Commits
ac4b3e0c1d
...
b34caae965
Author | SHA1 | Date |
---|---|---|
Jeff Carr | b34caae965 | |
Jeff Carr | 5db343390b |
|
@ -0,0 +1,34 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
/*
|
||||||
|
this parses the command line arguements
|
||||||
|
this enables command line options from other packages like 'gui' and 'log'
|
||||||
|
*/
|
||||||
|
|
||||||
|
import (
|
||||||
|
"go.wit.com/log"
|
||||||
|
)
|
||||||
|
|
||||||
|
// okay
|
||||||
|
func checkoutDevel() bool {
|
||||||
|
log.Info("running git checkout devel everwhere")
|
||||||
|
var failed int = 0
|
||||||
|
var count int = 0
|
||||||
|
loop := me.repos.View.ReposSortByName()
|
||||||
|
for loop.Scan() {
|
||||||
|
repo := loop.Repo()
|
||||||
|
count += 1
|
||||||
|
|
||||||
|
// don't switch branches on readonly repos
|
||||||
|
if me.forge.IsReadOnly(repo.GoPath()) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if repo.Status.CheckoutDevel() {
|
||||||
|
// checkout ok
|
||||||
|
} else {
|
||||||
|
failed += 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
log.Info("Ran git checkout in", count, "repos. failure count =", failed)
|
||||||
|
return true
|
||||||
|
}
|
|
@ -193,39 +193,3 @@ func globalBuildOptions(vbox *gui.Node) {
|
||||||
})
|
})
|
||||||
grid.NextRow()
|
grid.NextRow()
|
||||||
}
|
}
|
||||||
|
|
||||||
// this code isn't ready yet
|
|
||||||
/*
|
|
||||||
s.checkB = s.grid.NewButton("Check repos are working", func() {
|
|
||||||
me.Disable()
|
|
||||||
defer me.Enable()
|
|
||||||
for loop.Scan() {
|
|
||||||
if repo.GitURL() != "" {
|
|
||||||
log.Info("repo already checked. do they match?")
|
|
||||||
log.Info("go.wit.com =", repo.GoURL())
|
|
||||||
log.Info("localurl =", repo.Path())
|
|
||||||
} else {
|
|
||||||
ok, giturl := gowit.CheckRegistered(repo)
|
|
||||||
if ok {
|
|
||||||
log.Info("is url correct?", repo.Path(), "vs", giturl)
|
|
||||||
repo.giturl = giturl
|
|
||||||
if giturl != repo.Path() {
|
|
||||||
log.Info("repo check failed", repo.String())
|
|
||||||
s.unknownOL.SetText(repo.String())
|
|
||||||
s.unknownOL.Show()
|
|
||||||
s.unknownSubmitB.Show()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
log.Info("repo check failed", repo.String())
|
|
||||||
repo.giturl = "look in .git/config"
|
|
||||||
s.unknownOL.SetText(repo.String())
|
|
||||||
s.unknownOL.Show()
|
|
||||||
s.unknownSubmitB.Show()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
s.checkB.SetText("GOOD")
|
|
||||||
})
|
|
||||||
*/
|
|
||||||
|
|
|
@ -158,20 +158,3 @@ func globalResetOptions(box *gui.Node) {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func attemptAutoRebuild() {
|
|
||||||
gosrc := me.goSrcPwd.String()
|
|
||||||
|
|
||||||
quickCmd(gosrc, []string{"go-clone", "--recursive", "go.wit.com/apps/autotypist"})
|
|
||||||
quickCmd(gosrc, []string{"go-clone", "--recursive", "go.wit.com/toolkits/debian"})
|
|
||||||
quickCmd(gosrc, []string{"go-clone", "--recursive", "go.wit.com/toolkits/tree"})
|
|
||||||
quickCmd(gosrc, []string{"go-clone", "--recursive", "go.wit.com/toolkits/nocui"})
|
|
||||||
quickCmd(gosrc, []string{"go-clone", "--recursive", "go.wit.com/toolkits/gocui"})
|
|
||||||
quickCmd(gosrc, []string{"go-clone", "--recursive", "go.wit.com/toolkits/andlabs"})
|
|
||||||
|
|
||||||
quickCmd(filepath.Join(gosrc, "go.wit.com/toolkits/nocui/"), []string{"make"})
|
|
||||||
quickCmd(filepath.Join(gosrc, "go.wit.com/toolkits/gocui/"), []string{"make"})
|
|
||||||
quickCmd(filepath.Join(gosrc, "go.wit.com/toolkits/andlabs/"), []string{"make"})
|
|
||||||
|
|
||||||
quickCmd(filepath.Join(gosrc, "go.wit.com/apps/autotypist/"), []string{"make", "build"})
|
|
||||||
}
|
|
||||||
|
|
2
main.go
2
main.go
|
@ -18,6 +18,8 @@ var myargv argv
|
||||||
func main() {
|
func main() {
|
||||||
me = new(autoType)
|
me = new(autoType)
|
||||||
|
|
||||||
|
standardMachineInit()
|
||||||
|
|
||||||
log.DaemonMode(false)
|
log.DaemonMode(false)
|
||||||
me.myGui = gui.New()
|
me.myGui = gui.New()
|
||||||
if !myargv.GitPull {
|
if !myargv.GitPull {
|
||||||
|
|
|
@ -0,0 +1,91 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/go-cmd/cmd"
|
||||||
|
|
||||||
|
"go.wit.com/lib/gui/shell"
|
||||||
|
"go.wit.com/log"
|
||||||
|
)
|
||||||
|
|
||||||
|
// attempt to rebuild this app
|
||||||
|
// This should work from a blank slate
|
||||||
|
// TODO: make sure this works in a empty directory with a go-work file
|
||||||
|
|
||||||
|
func attemptAutoRebuild() bool {
|
||||||
|
gosrc := me.goSrcPwd.String()
|
||||||
|
|
||||||
|
if r, ok := quickCmd(gosrc, []string{"go-clone", "--recursive", "go.wit.com/apps/autotypist"}); !ok {
|
||||||
|
return buildDied(r)
|
||||||
|
}
|
||||||
|
if r, ok := quickCmd(gosrc, []string{"go-clone", "--recursive", "go.wit.com/toolkits/debian"}); !ok {
|
||||||
|
return buildDied(r)
|
||||||
|
}
|
||||||
|
if r, ok := quickCmd(gosrc, []string{"go-clone", "--recursive", "go.wit.com/toolkits/tree"}); !ok {
|
||||||
|
return buildDied(r)
|
||||||
|
}
|
||||||
|
if r, ok := quickCmd(gosrc, []string{"go-clone", "--recursive", "go.wit.com/toolkits/nocui"}); !ok {
|
||||||
|
return buildDied(r)
|
||||||
|
}
|
||||||
|
if r, ok := quickCmd(gosrc, []string{"go-clone", "--recursive", "go.wit.com/toolkits/gocui"}); !ok {
|
||||||
|
return buildDied(r)
|
||||||
|
}
|
||||||
|
if r, ok := quickCmd(gosrc, []string{"go-clone", "--recursive", "go.wit.com/toolkits/andlabs"}); !ok {
|
||||||
|
return buildDied(r)
|
||||||
|
}
|
||||||
|
|
||||||
|
if r, ok := quickCmd(filepath.Join(gosrc, "go.wit.com/toolkits/nocui/"), []string{"make"}); !ok {
|
||||||
|
return buildDied(r)
|
||||||
|
}
|
||||||
|
if r, ok := quickCmd(filepath.Join(gosrc, "go.wit.com/toolkits/gocui/"), []string{"make"}); !ok {
|
||||||
|
return buildDied(r)
|
||||||
|
}
|
||||||
|
if r, ok := quickCmd(filepath.Join(gosrc, "go.wit.com/toolkits/andlabs/"), []string{"make"}); !ok {
|
||||||
|
return buildDied(r)
|
||||||
|
}
|
||||||
|
|
||||||
|
// build the protobuf files
|
||||||
|
// TODO: verify the right protoc-gen-go exists
|
||||||
|
if !shell.Exists("/usr/bin/protoc-gen-go") {
|
||||||
|
log.Warn("missing /usr/bin/protc-gen-go. apt install protoc-gen-go")
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
quickCmd(filepath.Join(gosrc, "go.wit.com/lib/protobuf/forgepb/"), []string{"make"})
|
||||||
|
quickCmd(filepath.Join(gosrc, "go.wit.com/lib/protobuf/virtbuf/"), []string{"make"})
|
||||||
|
quickCmd(filepath.Join(gosrc, "go.wit.com/lib/protobuf/zoopb/"), []string{"make"})
|
||||||
|
|
||||||
|
quickCmd(filepath.Join(gosrc, "go.wit.com/apps/autotypist/"), []string{"make", "build"})
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
// only errors on bad errors
|
||||||
|
func quickCmd(fullpath string, cmd []string) (*cmd.Status, bool) {
|
||||||
|
if me.autoDryRun.Checked() {
|
||||||
|
log.Warn("RUN --dry-run", fullpath, cmd)
|
||||||
|
return nil, true
|
||||||
|
} else {
|
||||||
|
log.Warn("RUN:", fullpath, cmd)
|
||||||
|
}
|
||||||
|
|
||||||
|
r := shell.PathRun(fullpath, cmd)
|
||||||
|
output := strings.TrimSpace(strings.Join(r.Stdout, "\n"))
|
||||||
|
if r.Error != nil {
|
||||||
|
log.Warn("cmd =", cmd)
|
||||||
|
log.Warn("err =", r.Error)
|
||||||
|
log.Warn("b =", r.Exit)
|
||||||
|
log.Warn("output =", output)
|
||||||
|
return &r, false
|
||||||
|
} else if r.Exit != 0 {
|
||||||
|
log.Warn("b =", r.Exit)
|
||||||
|
log.Warn("output =", output)
|
||||||
|
return &r, true
|
||||||
|
}
|
||||||
|
log.Warn("output = ", output)
|
||||||
|
return &r, true
|
||||||
|
}
|
||||||
|
|
||||||
|
func buildDied(r *cmd.Status) bool {
|
||||||
|
return false
|
||||||
|
}
|
34
shell.go
34
shell.go
|
@ -1,34 +0,0 @@
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"go.wit.com/lib/gui/shell"
|
|
||||||
"go.wit.com/log"
|
|
||||||
)
|
|
||||||
|
|
||||||
// only errors on bad errors
|
|
||||||
func quickCmd(fullpath string, cmd []string) bool {
|
|
||||||
if me.autoDryRun.Checked() {
|
|
||||||
log.Warn("RUN --dry-run", fullpath, cmd)
|
|
||||||
return false
|
|
||||||
} else {
|
|
||||||
log.Warn("RUN:", fullpath, cmd)
|
|
||||||
}
|
|
||||||
|
|
||||||
r := shell.PathRun(fullpath, cmd)
|
|
||||||
output := strings.TrimSpace(strings.Join(r.Stdout, "\n"))
|
|
||||||
if r.Error != nil {
|
|
||||||
log.Warn("cmd =", cmd)
|
|
||||||
log.Warn("err =", r.Error)
|
|
||||||
log.Warn("b =", r.Exit)
|
|
||||||
log.Warn("output =", output)
|
|
||||||
return false
|
|
||||||
} else if r.Exit != 0 {
|
|
||||||
log.Warn("b =", r.Exit)
|
|
||||||
log.Warn("output =", output)
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
log.Warn("output = ", output)
|
|
||||||
return true
|
|
||||||
}
|
|
|
@ -0,0 +1,49 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.wit.com/lib/protobuf/forgepb"
|
||||||
|
"go.wit.com/log"
|
||||||
|
)
|
||||||
|
|
||||||
|
// does a standard forgepb & zoopb init
|
||||||
|
|
||||||
|
func standardMachineInit() {
|
||||||
|
var err error
|
||||||
|
// load the ~/.config/forge/ config
|
||||||
|
if err = me.forge.ConfigLoad(); err != nil {
|
||||||
|
log.Warn("forgepb.ConfigLoad() failed", err)
|
||||||
|
os.Exit(-1)
|
||||||
|
}
|
||||||
|
|
||||||
|
me.forge.PrintTable()
|
||||||
|
|
||||||
|
// load the ~/.config/forge/ machine file from zoopb
|
||||||
|
if err = me.machine.ConfigLoad(); err != nil {
|
||||||
|
log.Warn("zoopb.ConfigLoad() failed", err)
|
||||||
|
os.Exit(-1)
|
||||||
|
}
|
||||||
|
me.machine.InitWit()
|
||||||
|
|
||||||
|
// list all packages from mirrors.wit.com
|
||||||
|
/*
|
||||||
|
loop := me.machine.Wit.SortByName()
|
||||||
|
for loop.Scan() {
|
||||||
|
p := loop.Package()
|
||||||
|
log.Info("package:", p.Name, p.Version, p.PkgName)
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
// use ~/go/src unless we find a go.work file in a parent directory
|
||||||
|
if me.goSrcPath, err = forgepb.FindGoSrc(); err != nil {
|
||||||
|
log.Info(err)
|
||||||
|
os.Exit(-1)
|
||||||
|
}
|
||||||
|
|
||||||
|
// this ENV value is used by the repolist and repostatus packages
|
||||||
|
if me.goSrcPath != "" {
|
||||||
|
os.Setenv("REPO_WORK_PATH", me.goSrcPath)
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
11
structs.go
11
structs.go
|
@ -3,6 +3,8 @@ package main
|
||||||
import (
|
import (
|
||||||
"go.wit.com/gui"
|
"go.wit.com/gui"
|
||||||
"go.wit.com/lib/gadgets"
|
"go.wit.com/lib/gadgets"
|
||||||
|
"go.wit.com/lib/protobuf/forgepb"
|
||||||
|
"go.wit.com/lib/protobuf/zoopb"
|
||||||
)
|
)
|
||||||
|
|
||||||
var me *autoType
|
var me *autoType
|
||||||
|
@ -17,6 +19,15 @@ func (b *autoType) Enable() {
|
||||||
|
|
||||||
// this app's variables
|
// this app's variables
|
||||||
type autoType struct {
|
type autoType struct {
|
||||||
|
// your customized repo preferences and settings
|
||||||
|
forge forgepb.Repos
|
||||||
|
|
||||||
|
// where your ~/go/src is
|
||||||
|
goSrcPath string
|
||||||
|
|
||||||
|
// use zookeeper to get the list of installed packages
|
||||||
|
machine zoopb.Machine
|
||||||
|
|
||||||
// allrepos map[string]*repo
|
// allrepos map[string]*repo
|
||||||
myGui *gui.Node
|
myGui *gui.Node
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue