repolist/testGui/main.go

104 lines
2.1 KiB
Go

package main
import (
"fmt"
"os"
"go.wit.com/log"
"go.wit.com/gui"
"go.wit.com/lib/gui/repolist"
"go.wit.com/lib/protobuf/forgepb"
)
// sent via -ldflags
var VERSION string
var BUILDTIME string
func main() {
me = new(autoType)
// load the ~/.config/forge/ config
me.forge = forgepb.Init()
me.forge.ConfigPrintTable()
if err := me.forge.Machine.ConfigLoad(); err != nil {
log.Warn("zoopb.ConfigLoad() failed", err)
os.Exit(-1)
}
me.forge.Machine.InitWit()
// setup the GUI
me.myGui = gui.New()
me.myGui.Default()
me.repoList = repolist.Init(me.forge, me.myGui)
me.repoList.Enable()
failed := make(map[*repolist.RepoRow]string)
versions := make(map[*repolist.RepoRow]string)
rloop := me.repoList.ReposSortByName()
for rloop.Scan() {
repo := rloop.Repo()
// var cmd []string
var start string
var end string
var alreadyBuilt bool
ver := repo.Status.DebianReleaseVersion()
name := me.forge.DebName(repo.GoPath())
if me.forge.Machine.IsInstalled(name) {
end += "(installed) "
}
if actualp := me.forge.Machine.FindVersion(name, ver); actualp != nil {
end += " (version match) " + actualp.Version + " " + ver + " "
alreadyBuilt = true
} else {
end += " (need to build) " + ver + " "
}
if alreadyBuilt {
start = fmt.Sprintf("already built %-30s %-8s %-50s", name, ver, repo.GoPath())
} else {
start = fmt.Sprintf("need to build %-30s %-8s %-50s", name, ver, repo.GoPath())
}
log.Info(start, "("+versions[repo]+")", end)
if name == "" {
// err := fmt.Sprintf("name is blank error %+v", repo)
log.Warn("name is blank error", repo.GoPath())
}
if argv.DryRun {
continue
}
// skip if already built. (unless --force)
if alreadyBuilt {
// don't rebuild things
if argv.Force {
// well, okay, force me to rebuild them then
} else {
continue
}
}
if repo.Status.IsPrivate() {
// cmd = []string{"go-deb", "--auto", "--repo", repo.GoPath()}
} else {
}
}
log.Info("")
log.Info("something failed on:")
var fail bool = true
for repo, cmd := range failed {
log.Info("failed cmd :", cmd, repo.Status.Path())
fail = false
}
if fail {
os.Exit(0)
}
os.Exit(-1)
}