builds automatically

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-02-11 13:56:59 -06:00
parent e4e12ae90d
commit 0322b3ad85
5 changed files with 39 additions and 22 deletions

View File

@ -1,7 +1,7 @@
.PHONY: debian .PHONY: debian
run: build run: build
./go-deb --open-gui ./go-deb --no-gui --repo go.wit.com/apps/control-panel-dns
dns: build dns: build
./go-deb --repo go.wit.com/apps/control-panel-dns ./go-deb --repo go.wit.com/apps/control-panel-dns

View File

@ -52,7 +52,6 @@ func (c *controlBox) addRepo(path string) {
c.status.SetUserWorkingName("jcarr") c.status.SetUserWorkingName("jcarr")
c.status.Update() c.status.Update()
cbname := c.status.GetCurrentBranchName() cbname := c.status.GetCurrentBranchName()
cbversion := c.status.GetCurrentBranchVersion() cbversion := c.status.GetCurrentBranchVersion()
debversion := strings.TrimPrefix(cbversion, "v") debversion := strings.TrimPrefix(cbversion, "v")

View File

@ -13,9 +13,10 @@ import (
) )
var args struct { var args struct {
TmpLog bool `arg:"--tmp-log" help:"automatically send STDOUT to /tmp"` TmpLog bool `arg:"--tmp-log" help:"automatically send STDOUT to /tmp"`
OpenGui bool `arg:"--open-gui" help:"open the go-deb gui"` 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"` Repo string `arg:"--repo" help:"go get path to the repo"`
PkgDir string `arg:"--pkg-dir" help:"set default directory (~/incoming/)"`
} }
func init() { func init() {

35
main.go
View File

@ -20,6 +20,12 @@ var cBox *controlBox
var basicWindow *gadgets.BasicWindow var basicWindow *gadgets.BasicWindow
func main() { 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() { if debugger.ArgDebug() {
log.SetAll(true) log.SetAll(true)
log.ShowFlags() log.ShowFlags()
@ -33,20 +39,18 @@ func main() {
basicWindow = makebasicWindow() basicWindow = makebasicWindow()
if args.Repo != "" { filepath := filepath.Join("/home/jcarr/go/src", args.Repo)
filepath := filepath.Join("/home/jcarr/go/src", args.Repo) os.Chdir(filepath)
os.Chdir(filepath)
cBox.addRepo(args.Repo) cBox.addRepo(args.Repo)
cBox.readControlFile() cBox.readControlFile()
basicWindow.Show() if args.NoGui {
// go will sit here until the window exits if cBox.buildPackage() {
gui.Watchdog() log.Info("build worked")
} } else {
if args.OpenGui { log.Warn("build failed")
basicWindow.Show() }
// go will sit here until the window exits os.Exit(0)
gui.Watchdog()
} }
// run the debugger if triggered from the commandline // run the debugger if triggered from the commandline
@ -56,4 +60,9 @@ func main() {
debugger.DebugWindow() debugger.DebugWindow()
}() }()
} }
basicWindow.Show()
// go will sit here until the window exits
gui.Watchdog()
os.Exit(0)
} }

View File

@ -5,6 +5,7 @@ package main
import ( import (
"fmt" "fmt"
"os" "os"
"path/filepath"
"strings" "strings"
"go.wit.com/lib/gadgets" "go.wit.com/lib/gadgets"
@ -125,15 +126,22 @@ func (c *controlBox) buildPackage() bool {
return false return false
} }
shell.Run([]string{"dpkg-deb", "--build", "files", debname}) homeDir, err := os.UserHomeDir()
if shell.Exists(debname) { 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") log.Warn("build worked")
} else { } else {
log.Warn("build failed") log.Warn("build failed")
return false return false
} }
shell.Run([]string{"dpkg-deb", "-I", debname}) shell.Run([]string{"dpkg-deb", "-I", fulldebname})
shell.Run([]string{"dpkg-deb", "-c", debname}) shell.Run([]string{"dpkg-deb", "-c", fulldebname})
return true return true
} }