attempt to fix when not using forge
This commit is contained in:
parent
1e5fac4cd8
commit
d51f5b385a
5
Makefile
5
Makefile
|
@ -4,7 +4,7 @@ VERSION = $(shell git describe --tags)
|
|||
DATE = $(shell date +%Y.%m.%d)
|
||||
|
||||
run: build
|
||||
./go-deb --repo go.wit.com/apps/autotypist
|
||||
./go-deb --forge go.wit.com/apps/autotypist
|
||||
|
||||
vet:
|
||||
@GO111MODULE=off go vet
|
||||
|
@ -13,10 +13,9 @@ vet:
|
|||
auto-build: build
|
||||
./go-deb --auto --repo go.wit.com/apps/autotypist
|
||||
|
||||
build:
|
||||
build: goimports
|
||||
-rm resources/*.so
|
||||
touch resources/blank.so
|
||||
-cp -a ~/go/src/go.wit.com/toolkits/*/*.so resources/ # embed the toolkit plugins
|
||||
GO111MODULE="off" go build -v \
|
||||
-ldflags "-X main.VERSION=${VERSION} -X main.DATE=${DATE} -X gui.GUIVERSION=${VERSION}"
|
||||
|
||||
|
|
40
addRepo.go
40
addRepo.go
|
@ -17,8 +17,8 @@ func RemoveFirstElement(slice []string) (string, []string) {
|
|||
|
||||
// homeDir, _ := os.UserHomeDir()
|
||||
|
||||
func (c *controlBox) addRepo(path string) {
|
||||
path = strings.Trim(path, "/") // trim any extranous '/' chars put in the config file by the user
|
||||
func (c *controlBox) addRepo() {
|
||||
path := strings.Trim(me.goPath, "/") // trim any extranous '/' chars put in the config file by the user
|
||||
if path == "" {
|
||||
log.Warn("addRepo() got empty path", path)
|
||||
return
|
||||
|
@ -53,25 +53,42 @@ func (c *controlBox) addRepo(path string) {
|
|||
c.tagDate = gadgets.NewBasicEntry(c.grid, "git tag Date")
|
||||
c.grid.NextRow()
|
||||
|
||||
cbname := repo.GetCurrentBranchName()
|
||||
cbversion := repo.GetCurrentBranchVersion()
|
||||
debversion := repo.DebianCurrentVersion()
|
||||
var cbname string
|
||||
var cbversion string
|
||||
var debversion string
|
||||
|
||||
if repo.CheckDirty() {
|
||||
if me.repo == nil {
|
||||
cbname = "todo"
|
||||
cbversion = "todo version"
|
||||
debversion = "todo deb version"
|
||||
} else {
|
||||
cbname = me.repo.GetCurrentBranchName()
|
||||
cbversion = me.repo.GetCurrentBranchVersion()
|
||||
debversion = me.repo.DebianCurrentVersion()
|
||||
}
|
||||
|
||||
if me.repo == nil {
|
||||
c.dirtyL.SetText("unknown")
|
||||
} else {
|
||||
if me.repo.CheckDirty() {
|
||||
c.dirtyL.SetText("true")
|
||||
} else {
|
||||
c.dirtyL.SetText("false")
|
||||
}
|
||||
|
||||
if c.GoPath.String() == "" {
|
||||
c.GoPath.SetText(repo.GetGoPath())
|
||||
}
|
||||
|
||||
lasttag := repo.GetLastTagVersion()
|
||||
if c.GoPath.String() == "" {
|
||||
c.GoPath.SetText(me.goPath)
|
||||
}
|
||||
|
||||
var lasttag string = "unknown"
|
||||
if me.repo != nil {
|
||||
lasttag = me.repo.GetLastTagVersion()
|
||||
if argv.Release {
|
||||
debversion = repo.DebianReleaseVersion()
|
||||
debversion = me.repo.DebianReleaseVersion()
|
||||
c.dirtyL.SetText("false")
|
||||
}
|
||||
}
|
||||
|
||||
c.Version.SetText(debversion)
|
||||
|
||||
|
@ -80,6 +97,5 @@ func (c *controlBox) addRepo(path string) {
|
|||
|
||||
tagDate := c.getDateStamp(lasttag)
|
||||
c.tagDate.SetText(tagDate)
|
||||
|
||||
return
|
||||
}
|
||||
|
|
6
argv.go
6
argv.go
|
@ -8,8 +8,6 @@ package main
|
|||
|
||||
import (
|
||||
"go.wit.com/dev/alexflint/arg"
|
||||
"go.wit.com/lib/debugger"
|
||||
"go.wit.com/log"
|
||||
)
|
||||
|
||||
var argv args
|
||||
|
@ -17,7 +15,7 @@ var argv args
|
|||
type args struct {
|
||||
Auto bool `arg:"--auto" help:"automatically attempt to make the .deb"`
|
||||
Ldflags []string `arg:"--ldflags" help:"flags to pass to go build"`
|
||||
Repo string `arg:"--repo" help:"go get path to the repo"`
|
||||
Forge string `arg:"--forge" help:"use a git repo from forge"`
|
||||
OutDir string `arg:"--dir" help:"write .deb file into this directory"`
|
||||
Release bool `arg:"--release" help:"build a release from the last git tag"`
|
||||
KeepFiles bool `arg:"--keep-files" help:"keep the build files/"`
|
||||
|
@ -27,11 +25,13 @@ type args struct {
|
|||
func init() {
|
||||
arg.MustParse(&argv)
|
||||
|
||||
/*
|
||||
if debugger.ArgDebug() {
|
||||
log.Info("cmd line --debugger == true")
|
||||
} else {
|
||||
log.Info("cmd line --debugger == false")
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
func (args) Version() string {
|
||||
|
|
|
@ -9,6 +9,7 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/go-cmd/cmd"
|
||||
"go.wit.com/lib/gui/shell"
|
||||
"go.wit.com/log"
|
||||
)
|
||||
|
@ -297,7 +298,13 @@ func (c *controlBox) computeControlValues() bool {
|
|||
// stamp := time.Now().UTC().Format("2006/01/02 15:04:05 UTC")
|
||||
|
||||
func (c *controlBox) getDateStamp(tag string) string {
|
||||
r := repo.Run([]string{"git", "log", "-1", "--format=%at", tag})
|
||||
var r cmd.Status
|
||||
if me.repo == nil {
|
||||
r = shell.Run([]string{"git", "log", "-1", "--format=%at", tag})
|
||||
} else {
|
||||
r = me.repo.Run([]string{"git", "log", "-1", "--format=%at", tag})
|
||||
}
|
||||
|
||||
out := strings.Join(r.Stdout, "\n")
|
||||
out = strings.TrimSpace(out)
|
||||
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"go.wit.com/log"
|
||||
)
|
||||
|
||||
func okExit(thing string) {
|
||||
log.Info(thing, "ok")
|
||||
// log.Info("Finished go-clean on", check.GetGoPath(), "ok")
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
func badExit(err error) {
|
||||
log.Info("go-deb failed: ", err)
|
||||
os.Exit(-1)
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"go.wit.com/gui"
|
||||
"go.wit.com/lib/protobuf/forgepb"
|
||||
"go.wit.com/log"
|
||||
)
|
||||
|
||||
// if there is no "build" file
|
||||
// the attempt to use forgepb to init
|
||||
// the GO repo
|
||||
func doForge() {
|
||||
me.forge = forgepb.Init()
|
||||
os.Setenv("REPO_WORK_PATH", me.forge.GetGoSrc())
|
||||
|
||||
me.repo = me.forge.Repos.FindByFullPath(argv.Forge)
|
||||
if me.repo == nil {
|
||||
log.Info("repo not found", argv.Forge)
|
||||
me.repo = me.forge.FindByGoPath(argv.Forge)
|
||||
}
|
||||
if me.repo == nil {
|
||||
log.Info("I could not determine which go repo you have", argv.Forge)
|
||||
log.Info("you must create a build & control file", argv.Forge)
|
||||
os.Exit(-1)
|
||||
}
|
||||
log.Info("found repo", me.repo.GetGoPath())
|
||||
// build()
|
||||
}
|
||||
|
||||
func doGui() {
|
||||
me.myGui = gui.New()
|
||||
if !argv.Auto {
|
||||
me.myGui.InitEmbed(resources)
|
||||
}
|
||||
me.myGui.Default()
|
||||
|
||||
me.basicWindow.Show()
|
||||
// go will sit here until the window exits
|
||||
gui.Watchdog()
|
||||
os.Exit(0)
|
||||
}
|
105
main.go
105
main.go
|
@ -6,10 +6,8 @@ import (
|
|||
"path/filepath"
|
||||
|
||||
"go.wit.com/gui"
|
||||
"go.wit.com/lib/debugger"
|
||||
"go.wit.com/lib/gadgets"
|
||||
"go.wit.com/lib/fhelp"
|
||||
"go.wit.com/lib/gui/shell"
|
||||
"go.wit.com/lib/protobuf/gitpb"
|
||||
"go.wit.com/lib/protobuf/forgepb"
|
||||
"go.wit.com/log"
|
||||
)
|
||||
|
@ -18,91 +16,76 @@ import (
|
|||
var VERSION string
|
||||
var DATE string
|
||||
|
||||
// This is the beginning of the binary tree of GUI widgets
|
||||
var myGui *gui.Node
|
||||
|
||||
// this scans in the repos
|
||||
var forge *forgepb.Forge
|
||||
var repo *gitpb.Repo
|
||||
|
||||
var cBox *controlBox
|
||||
|
||||
// this is a basic window. the user can open and close it
|
||||
var basicWindow *gadgets.BasicWindow
|
||||
|
||||
//go:embed resources/*
|
||||
var resources embed.FS
|
||||
|
||||
func main() {
|
||||
if argv.Repo == "" {
|
||||
log.Info("You need to tell me what repo you want to work on")
|
||||
println("")
|
||||
println("go-deb --repo go.wit.com/apps/helloworld")
|
||||
os.Exit(0)
|
||||
}
|
||||
forge = forgepb.Init()
|
||||
os.Setenv("REPO_WORK_PATH", forge.GetGoSrc())
|
||||
me = new(mainType)
|
||||
|
||||
repo = forge.FindByGoPath(argv.Repo)
|
||||
if repo == nil {
|
||||
log.Info("repo not found. you need to clone", argv.Repo)
|
||||
goSrc, hasWork, err := fhelp.DetermineGoPath()
|
||||
if err != nil {
|
||||
badExit(err)
|
||||
}
|
||||
log.Info("GO src path", goSrc, "go.work is", hasWork)
|
||||
me.goSrc = goSrc
|
||||
me.hasWork = hasWork
|
||||
|
||||
// set the go src path
|
||||
os.Setenv("REPO_WORK_PATH", goSrc)
|
||||
|
||||
if argv.Forge != "" {
|
||||
me.forge = forgepb.Init()
|
||||
|
||||
me.repo = me.forge.Repos.FindByFullPath(argv.Forge)
|
||||
if me.repo == nil {
|
||||
log.Info("repo not found", argv.Forge)
|
||||
me.repo = me.forge.FindByGoPath(argv.Forge)
|
||||
}
|
||||
if me.repo == nil {
|
||||
log.Info("forge failure. repo not found", argv.Forge)
|
||||
os.Exit(-1)
|
||||
}
|
||||
log.Info("found repo", argv.Repo)
|
||||
log.Info("found repo", me.repo.GetGoPath())
|
||||
}
|
||||
// build()
|
||||
|
||||
myGui = gui.New()
|
||||
me.myGui = gui.New()
|
||||
if !argv.Auto {
|
||||
myGui.InitEmbed(resources)
|
||||
me.myGui.InitEmbed(resources)
|
||||
}
|
||||
myGui.Default()
|
||||
me.myGui.Default()
|
||||
|
||||
basicWindow = makebasicWindow()
|
||||
me.basicWindow = makebasicWindow()
|
||||
|
||||
// todo: add the go.work file logic here
|
||||
homeDir, _ := os.UserHomeDir()
|
||||
// figure out where we are working from
|
||||
// os.Chdir to that directory
|
||||
var debpath string
|
||||
if argv.Repo == "." {
|
||||
if me.repo == nil {
|
||||
os.Setenv("GO_DEB_CUSTOM", "true")
|
||||
debpath, _ = os.Getwd()
|
||||
} else {
|
||||
debpath = filepath.Join(homeDir, "go/src", argv.Repo)
|
||||
debpath = me.repo.GetFullPath()
|
||||
}
|
||||
_, basename := filepath.Split(debpath)
|
||||
me.goPath = basename
|
||||
os.Chdir(debpath)
|
||||
|
||||
// scan the repo
|
||||
cBox.addRepo(argv.Repo)
|
||||
me.cBox.addRepo()
|
||||
|
||||
// look for a 'config' file in the repo
|
||||
if cBox.readControlFile() == nil {
|
||||
if me.cBox.readControlFile() == nil {
|
||||
log.Warn("scan worked")
|
||||
} else {
|
||||
log.Warn("scan failed")
|
||||
}
|
||||
cBox.computeControlValues()
|
||||
me.cBox.computeControlValues()
|
||||
// verify the values for the package
|
||||
|
||||
if repo == nil {
|
||||
if argv.Repo == "." {
|
||||
// this means try the local directory for a custom 'control' file
|
||||
} else {
|
||||
log.Info("argv.Repo =", argv.Repo)
|
||||
log.Info("repo not found. Try:")
|
||||
log.Info("")
|
||||
log.Info(" go-clone", argv.Repo)
|
||||
log.Info("")
|
||||
os.Exit(-1)
|
||||
}
|
||||
}
|
||||
|
||||
// set the working directory to argv.Repo
|
||||
log.Info("cd", repo.FullPath)
|
||||
os.Chdir(repo.FullPath)
|
||||
|
||||
if argv.Auto {
|
||||
shell.TestTerminalColor()
|
||||
// basicWindow.Show() // broken gui package. convert to protobuf
|
||||
if ok, err := cBox.buildPackage(); ok {
|
||||
if ok, err := me.cBox.buildPackage(); ok {
|
||||
log.Info("build worked")
|
||||
} else {
|
||||
log.Warn("build failed:", err)
|
||||
|
@ -111,15 +94,7 @@ func main() {
|
|||
os.Exit(0)
|
||||
}
|
||||
|
||||
// run the debugger if triggered from the commandline
|
||||
if debugger.ArgDebug() {
|
||||
go func() {
|
||||
log.Sleep(2)
|
||||
debugger.DebugWindow()
|
||||
}()
|
||||
}
|
||||
|
||||
basicWindow.Show()
|
||||
me.basicWindow.Show()
|
||||
// go will sit here until the window exits
|
||||
gui.Watchdog()
|
||||
os.Exit(0)
|
||||
|
|
|
@ -22,10 +22,10 @@ func (c *controlBox) readControlFile() error {
|
|||
pairs["Architecture"] = "amd64" // TODO: figure this out
|
||||
pairs["Recommends"] = ""
|
||||
pairs["Source"] = "notsure"
|
||||
if argv.Repo == "" {
|
||||
if me.repo == nil {
|
||||
pairs["Description"] = "put something here"
|
||||
} else {
|
||||
pairs["Description"] = argv.Repo
|
||||
pairs["Description"] = me.repo.GetGoPath()
|
||||
}
|
||||
}
|
||||
defer file.Close()
|
||||
|
|
|
@ -9,17 +9,18 @@ import (
|
|||
)
|
||||
|
||||
// This initializes the first window, a group and a button
|
||||
// this is terribly old code. redo this all after widgets are switched to protobuf
|
||||
func makebasicWindow() *gadgets.BasicWindow {
|
||||
log.Warn("init basicWindow state")
|
||||
basicWindow = gadgets.NewBasicWindow(myGui, "Create .deb files for GO applications")
|
||||
basicWindow.Make()
|
||||
basicWindow.Custom = func() {
|
||||
win := gadgets.NewBasicWindow(me.myGui, "Create .deb files for GO applications")
|
||||
win.Make()
|
||||
win.Custom = func() {
|
||||
log.Info("got to close")
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
box1 := basicWindow.Box()
|
||||
cBox = newControl(box1)
|
||||
box1 := win.Box()
|
||||
me.cBox = newControl(box1)
|
||||
|
||||
vbox := box1.Box().Horizontal()
|
||||
group1 := vbox.NewGroup("controls").Horizontal() // Vertical()
|
||||
|
@ -29,19 +30,19 @@ func makebasicWindow() *gadgets.BasicWindow {
|
|||
})
|
||||
|
||||
group1.NewButton("read control file", func() {
|
||||
cBox.readControlFile()
|
||||
me.cBox.readControlFile()
|
||||
})
|
||||
|
||||
group1.NewButton("Make .deb", func() {
|
||||
basicWindow.Disable()
|
||||
if ok, err := cBox.buildPackage(); ok {
|
||||
win.Disable()
|
||||
if ok, err := me.cBox.buildPackage(); ok {
|
||||
log.Info("build worked")
|
||||
os.Exit(0)
|
||||
} else {
|
||||
log.Warn("build failed", err)
|
||||
}
|
||||
basicWindow.Enable()
|
||||
win.Enable()
|
||||
})
|
||||
|
||||
return basicWindow
|
||||
return win
|
||||
}
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"go.wit.com/dev/alexflint/arg"
|
||||
"go.wit.com/gui"
|
||||
"go.wit.com/lib/gadgets"
|
||||
"go.wit.com/lib/protobuf/forgepb"
|
||||
"go.wit.com/lib/protobuf/gitpb"
|
||||
)
|
||||
|
||||
var me *mainType
|
||||
|
||||
// this app's variables
|
||||
type mainType struct {
|
||||
pp *arg.Parser // for parsing the command line args. Yay to alexf lint!
|
||||
goSrc string // path to ~/go/src or go.work file
|
||||
goPath string // the goPath to use for the package
|
||||
hasWork bool // true if using go.work file
|
||||
forge *forgepb.Forge // the interface to the 'forge' protobuf information
|
||||
repo *gitpb.Repo // this is the repo we are in
|
||||
myGui *gui.Node // the gui toolkit handle
|
||||
cBox *controlBox // the GUI box in the main window
|
||||
basicWindow *gadgets.BasicWindow // this is a basic window. the user can open and close it
|
||||
}
|
Loading…
Reference in New Issue