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
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

View File

@ -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")

View File

@ -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() {

35
main.go
View File

@ -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)
}

View File

@ -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
}