go-deb/main.go

95 lines
1.8 KiB
Go

package main
import (
"embed"
"os"
"path/filepath"
"time"
"go.wit.com/dev/alexflint/arg"
"go.wit.com/lib/gui/prep"
"go.wit.com/lib/protobuf/gitpb"
"go.wit.com/log"
)
// sent from -ldflags
var VERSION string
var DATE string
//go:embed resources/*
var resources embed.FS
var ARGNAME string = "go-deb"
var argv args
func main() {
me = new(mainType)
prep.Bash(ARGNAME, argv.DoAutoComplete) // this line should be: prep.Bash(argv)
me.myGui = prep.Gui() // prepares the GUI package for go-args
me.pp = arg.MustParse(&argv)
wd, err := os.Getwd()
if err != nil {
badExit(err)
}
me.repo, err = gitpb.NewRepo(wd)
if err != nil {
badExit(err)
}
// build()
if argv.Show != nil {
log.Info("todo: show", me.repo.GetGoPath())
okExit("")
}
log.Info("Namespace:", me.repo.GetNamespace(), "Fullpath:", me.repo.GetFullPath())
// figure out where we are working from
// os.Chdir to that directory
var debpath string
if me.repo == nil {
os.Setenv("GO_DEB_CUSTOM", "true")
debpath, _ = os.Getwd()
} else {
debpath = me.repo.GetFullPath()
}
_, basename := filepath.Split(debpath)
me.goPath = basename
os.Chdir(debpath)
// look for a 'config' file in the repo
if readControlFile(me.repo) == nil {
log.Warn("scan worked")
} else {
log.Warn("scan failed")
}
computeControlValues(me.repo)
if argv.Gui != nil {
// only load teh toolkit if you get this far
me.myGui.Start() // loads the GUI toolkit
doGui()
win := makebasicWindow()
win.Show()
debug()
}
log.Info("go-deb: attempting to build package")
if ok, err := buildPackage(me.repo); ok {
log.Info("build worked")
} else {
log.Warn("build failed:", err)
os.Exit(-1)
}
os.Exit(0)
}
func debug() {
time.Sleep(2 * time.Second)
for {
log.Info("idle loop() todo: could check for things here")
time.Sleep(90 * time.Second)
}
}