From 0322b3ad856345c1e3c848e06c8d27caee6856af Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sun, 11 Feb 2024 13:56:59 -0600 Subject: [PATCH] builds automatically Signed-off-by: Jeff Carr --- Makefile | 2 +- addRepo.go | 1 - args.go | 7 ++++--- main.go | 35 ++++++++++++++++++++++------------- stateWindow.go | 16 ++++++++++++---- 5 files changed, 39 insertions(+), 22 deletions(-) diff --git a/Makefile b/Makefile index 49cf377..b434bfb 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ .PHONY: debian run: build - ./go-deb --open-gui + ./go-deb --no-gui --repo go.wit.com/apps/control-panel-dns dns: build ./go-deb --repo go.wit.com/apps/control-panel-dns diff --git a/addRepo.go b/addRepo.go index 1a25dc9..7fd9994 100644 --- a/addRepo.go +++ b/addRepo.go @@ -52,7 +52,6 @@ func (c *controlBox) addRepo(path string) { c.status.SetUserWorkingName("jcarr") c.status.Update() - cbname := c.status.GetCurrentBranchName() cbversion := c.status.GetCurrentBranchVersion() debversion := strings.TrimPrefix(cbversion, "v") diff --git a/args.go b/args.go index 35b272b..58be509 100644 --- a/args.go +++ b/args.go @@ -13,9 +13,10 @@ import ( ) var args struct { - TmpLog bool `arg:"--tmp-log" help:"automatically send STDOUT to /tmp"` - OpenGui bool `arg:"--open-gui" help:"open the go-deb gui"` - Repo string `arg:"--repo" help:"go get path to the repo"` + TmpLog bool `arg:"--tmp-log" help:"automatically send STDOUT to /tmp"` + NoGui bool `arg:"--no-gui" help:"don't open the gui, just make the .deb"` + Repo string `arg:"--repo" help:"go get path to the repo"` + PkgDir string `arg:"--pkg-dir" help:"set default directory (~/incoming/)"` } func init() { diff --git a/main.go b/main.go index 55101d4..5ebdc7b 100644 --- a/main.go +++ b/main.go @@ -20,6 +20,12 @@ var cBox *controlBox var basicWindow *gadgets.BasicWindow func main() { + if args.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) + } if debugger.ArgDebug() { log.SetAll(true) log.ShowFlags() @@ -33,20 +39,18 @@ func main() { basicWindow = makebasicWindow() - if args.Repo != "" { - filepath := filepath.Join("/home/jcarr/go/src", args.Repo) - os.Chdir(filepath) + filepath := filepath.Join("/home/jcarr/go/src", args.Repo) + os.Chdir(filepath) - cBox.addRepo(args.Repo) - cBox.readControlFile() - basicWindow.Show() - // go will sit here until the window exits - gui.Watchdog() - } - if args.OpenGui { - basicWindow.Show() - // go will sit here until the window exits - gui.Watchdog() + cBox.addRepo(args.Repo) + cBox.readControlFile() + if args.NoGui { + if cBox.buildPackage() { + log.Info("build worked") + } else { + log.Warn("build failed") + } + os.Exit(0) } // run the debugger if triggered from the commandline @@ -56,4 +60,9 @@ func main() { debugger.DebugWindow() }() } + + basicWindow.Show() + // go will sit here until the window exits + gui.Watchdog() + os.Exit(0) } diff --git a/stateWindow.go b/stateWindow.go index efe9a8a..9f9f166 100644 --- a/stateWindow.go +++ b/stateWindow.go @@ -5,6 +5,7 @@ package main import ( "fmt" "os" + "path/filepath" "strings" "go.wit.com/lib/gadgets" @@ -125,15 +126,22 @@ func (c *controlBox) buildPackage() bool { return false } - shell.Run([]string{"dpkg-deb", "--build", "files", debname}) - if shell.Exists(debname) { + homeDir, err := os.UserHomeDir() + if err != nil { + log.Warn("os.UserHomeDir() failed") + return false + } + + fulldebname := filepath.Join(homeDir, "incoming", debname) + shell.Run([]string{"dpkg-deb", "--build", "files", fulldebname}) + if shell.Exists(fulldebname) { log.Warn("build worked") } else { log.Warn("build failed") return false } - shell.Run([]string{"dpkg-deb", "-I", debname}) - shell.Run([]string{"dpkg-deb", "-c", debname}) + shell.Run([]string{"dpkg-deb", "-I", fulldebname}) + shell.Run([]string{"dpkg-deb", "-c", fulldebname}) return true }