specify repo on command line works
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
e78fd84d74
commit
e4e12ae90d
3
Makefile
3
Makefile
|
@ -3,6 +3,9 @@
|
||||||
run: build
|
run: build
|
||||||
./go-deb --open-gui
|
./go-deb --open-gui
|
||||||
|
|
||||||
|
dns: build
|
||||||
|
./go-deb --repo go.wit.com/apps/control-panel-dns
|
||||||
|
|
||||||
build:
|
build:
|
||||||
-cp ~/go/src/go.wit.com/toolkits/*.so resources/
|
-cp ~/go/src/go.wit.com/toolkits/*.so resources/
|
||||||
GO111MODULE="off" go build -v
|
GO111MODULE="off" go build -v
|
||||||
|
|
|
@ -0,0 +1,78 @@
|
||||||
|
// This is a simple example
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"go.wit.com/lib/gadgets"
|
||||||
|
"go.wit.com/lib/gui/repostatus"
|
||||||
|
"go.wit.com/log"
|
||||||
|
)
|
||||||
|
|
||||||
|
func RemoveFirstElement(slice []string) (string, []string) {
|
||||||
|
if len(slice) == 0 {
|
||||||
|
return "", slice // Return the original slice if it's empty
|
||||||
|
}
|
||||||
|
return slice[0], slice[1:] // Return the slice without the first element
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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
|
||||||
|
if path == "" {
|
||||||
|
log.Warn("addRepo() got empty path", path)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if repostatus.VerifyLocalGoRepo(path) {
|
||||||
|
log.Verbose("path actually exists", path)
|
||||||
|
} else {
|
||||||
|
log.Warn("repostatus.VerifyLocalGoRepo() failed for for", path)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
c.pathL = gadgets.NewOneLiner(c.grid, "path")
|
||||||
|
c.pathL.SetText(path)
|
||||||
|
c.grid.NextRow()
|
||||||
|
|
||||||
|
c.lastTag = gadgets.NewOneLiner(c.grid, "lastTag")
|
||||||
|
c.lastTag.SetText(path)
|
||||||
|
c.grid.NextRow()
|
||||||
|
|
||||||
|
c.dirtyL = gadgets.NewOneLiner(c.grid, "dirty")
|
||||||
|
c.grid.NextRow()
|
||||||
|
|
||||||
|
c.currentL = gadgets.NewOneLiner(c.grid, "current")
|
||||||
|
c.grid.NextRow()
|
||||||
|
|
||||||
|
c.status = repostatus.NewRepoStatusWindow(path)
|
||||||
|
c.status.SetMainWorkingName("master")
|
||||||
|
c.status.SetDevelWorkingName("devel")
|
||||||
|
c.status.SetUserWorkingName("jcarr")
|
||||||
|
c.status.Update()
|
||||||
|
|
||||||
|
|
||||||
|
cbname := c.status.GetCurrentBranchName()
|
||||||
|
cbversion := c.status.GetCurrentBranchVersion()
|
||||||
|
debversion := strings.TrimPrefix(cbversion, "v")
|
||||||
|
|
||||||
|
if c.status.CheckDirty() {
|
||||||
|
c.dirtyL.SetText("true")
|
||||||
|
debversion = debversion + "-dirty"
|
||||||
|
} else {
|
||||||
|
c.dirtyL.SetText("false")
|
||||||
|
}
|
||||||
|
|
||||||
|
c.Version.SetText(debversion)
|
||||||
|
|
||||||
|
lasttag := c.status.GetLastTagVersion()
|
||||||
|
c.lastTag.SetText(lasttag)
|
||||||
|
c.currentL.SetText(cbname + " " + cbversion)
|
||||||
|
|
||||||
|
if c.status.Changed() {
|
||||||
|
log.Warn("should scan here")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
10
control
10
control
|
@ -4,6 +4,10 @@ Package: go-deb
|
||||||
Maintainer: Jeff Carr <jcarr@wit.com>
|
Maintainer: Jeff Carr <jcarr@wit.com>
|
||||||
Architecture: amd64
|
Architecture: amd64
|
||||||
Depends:
|
Depends:
|
||||||
Recommends: libgtk-3-0, ddclient, ddupdate
|
Recommends: go-gui-toolkits
|
||||||
Description: a control panel for DNS and IPv6 settings
|
Description: create distribution packages for golang repositories
|
||||||
Goals: show the settings, validate & update DNS
|
Hopefully, this can make compatible and correct source
|
||||||
|
packages for things like debuild or the incoming queue since
|
||||||
|
golang applications are more strict then the traditional C
|
||||||
|
libraries and binaries that require lots of scripting.
|
||||||
|
A person can dream anyway.
|
||||||
|
|
|
@ -4,9 +4,10 @@ package main
|
||||||
import (
|
import (
|
||||||
"go.wit.com/gui"
|
"go.wit.com/gui"
|
||||||
"go.wit.com/lib/gadgets"
|
"go.wit.com/lib/gadgets"
|
||||||
|
"go.wit.com/lib/gui/repostatus"
|
||||||
)
|
)
|
||||||
|
|
||||||
type controlFile struct {
|
type controlBox struct {
|
||||||
group *gui.Node // the group
|
group *gui.Node // the group
|
||||||
grid *gui.Node // the grid
|
grid *gui.Node // the grid
|
||||||
|
|
||||||
|
@ -20,12 +21,19 @@ type controlFile struct {
|
||||||
BuildDepends *gadgets.OneLiner
|
BuildDepends *gadgets.OneLiner
|
||||||
Recommends *gadgets.OneLiner
|
Recommends *gadgets.OneLiner
|
||||||
Description *gadgets.OneLiner
|
Description *gadgets.OneLiner
|
||||||
|
|
||||||
|
// repostatus things
|
||||||
|
pathL *gadgets.OneLiner
|
||||||
|
lastTag *gadgets.OneLiner
|
||||||
|
dirtyL *gadgets.OneLiner
|
||||||
|
currentL *gadgets.OneLiner
|
||||||
|
status *repostatus.RepoStatus
|
||||||
}
|
}
|
||||||
|
|
||||||
// This initializes the control box
|
// This initializes the control box
|
||||||
func newControl(parent *gui.Node) *controlFile {
|
func newControl(parent *gui.Node) *controlBox {
|
||||||
var c *controlFile
|
var c *controlBox
|
||||||
c = new(controlFile)
|
c = new(controlBox)
|
||||||
c.group = parent.NewGroup("choices")
|
c.group = parent.NewGroup("choices")
|
||||||
c.grid = c.group.NewGrid("gridiron", 8, 1)
|
c.grid = c.group.NewGrid("gridiron", 8, 1)
|
||||||
|
|
||||||
|
@ -68,6 +76,7 @@ func newControl(parent *gui.Node) *controlFile {
|
||||||
c.grid.NextRow()
|
c.grid.NextRow()
|
||||||
|
|
||||||
c.Description = gadgets.NewOneLiner(c.grid, "Description")
|
c.Description = gadgets.NewOneLiner(c.grid, "Description")
|
||||||
|
c.grid.NextRow()
|
||||||
|
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
|
36
main.go
36
main.go
|
@ -2,6 +2,9 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
|
||||||
"go.wit.com/gui"
|
"go.wit.com/gui"
|
||||||
"go.wit.com/lib/debugger"
|
"go.wit.com/lib/debugger"
|
||||||
"go.wit.com/lib/gadgets"
|
"go.wit.com/lib/gadgets"
|
||||||
|
@ -11,8 +14,7 @@ import (
|
||||||
// This is the beginning of the binary tree of GUI widgets
|
// This is the beginning of the binary tree of GUI widgets
|
||||||
var myGui *gui.Node
|
var myGui *gui.Node
|
||||||
|
|
||||||
// this is the primary window. If you close it, the program will exit
|
var cBox *controlBox
|
||||||
// var mainWindow *gui.Node
|
|
||||||
|
|
||||||
// this is a basic window. the user can open and close it
|
// this is a basic window. the user can open and close it
|
||||||
var basicWindow *gadgets.BasicWindow
|
var basicWindow *gadgets.BasicWindow
|
||||||
|
@ -29,9 +31,18 @@ func main() {
|
||||||
myGui = gui.New()
|
myGui = gui.New()
|
||||||
myGui.Default()
|
myGui.Default()
|
||||||
|
|
||||||
// helloworld()
|
|
||||||
basicWindow = makebasicWindow()
|
basicWindow = makebasicWindow()
|
||||||
|
|
||||||
|
if args.Repo != "" {
|
||||||
|
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 {
|
if args.OpenGui {
|
||||||
basicWindow.Show()
|
basicWindow.Show()
|
||||||
// go will sit here until the window exits
|
// go will sit here until the window exits
|
||||||
|
@ -46,22 +57,3 @@ func main() {
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
// This initializes the first window and some widgets
|
|
||||||
func helloworld() {
|
|
||||||
mainWindow = myGui.NewWindow("Debian Package Creater for GO Language Applicatiosn").SetProgName("BASEWIN")
|
|
||||||
|
|
||||||
box := mainWindow.NewBox("hbox", true)
|
|
||||||
// section1 = newChoices(box)
|
|
||||||
|
|
||||||
group := box.NewGroup("control file")
|
|
||||||
group.NewButton("show basic window", func() {
|
|
||||||
if basicWindow.Hidden() {
|
|
||||||
basicWindow.Show()
|
|
||||||
} else {
|
|
||||||
basicWindow.Hide()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// readGitConfig reads and parses the control file
|
// readGitConfig reads and parses the control file
|
||||||
func (c *controlFile) readControlFile() error {
|
func (c *controlBox) readControlFile() error {
|
||||||
file, err := os.Open("control")
|
file, err := os.Open("control")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warn("readControlFile() could not find the file")
|
log.Warn("readControlFile() could not find the file")
|
||||||
|
|
|
@ -7,14 +7,11 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"go.wit.com/gui"
|
|
||||||
"go.wit.com/lib/gadgets"
|
"go.wit.com/lib/gadgets"
|
||||||
"go.wit.com/lib/gui/shell"
|
"go.wit.com/lib/gui/shell"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
var apple *gui.Node
|
|
||||||
|
|
||||||
// This initializes the first window, a group and a button
|
// This initializes the first window, a group and a button
|
||||||
func makebasicWindow() *gadgets.BasicWindow {
|
func makebasicWindow() *gadgets.BasicWindow {
|
||||||
log.Warn("init basicWindow state")
|
log.Warn("init basicWindow state")
|
||||||
|
@ -26,7 +23,7 @@ func makebasicWindow() *gadgets.BasicWindow {
|
||||||
}
|
}
|
||||||
|
|
||||||
box1 := basicWindow.Box()
|
box1 := basicWindow.Box()
|
||||||
control := newControl(box1)
|
cBox = newControl(box1)
|
||||||
|
|
||||||
vbox := box1.Box().Horizontal()
|
vbox := box1.Box().Horizontal()
|
||||||
group1 := vbox.NewGroup("controls").Horizontal() // Vertical()
|
group1 := vbox.NewGroup("controls").Horizontal() // Vertical()
|
||||||
|
@ -36,12 +33,12 @@ func makebasicWindow() *gadgets.BasicWindow {
|
||||||
})
|
})
|
||||||
|
|
||||||
group1.NewButton("read control file", func() {
|
group1.NewButton("read control file", func() {
|
||||||
control.readControlFile()
|
cBox.readControlFile()
|
||||||
})
|
})
|
||||||
|
|
||||||
group1.NewButton("Make .deb", func() {
|
group1.NewButton("Make .deb", func() {
|
||||||
basicWindow.Disable()
|
basicWindow.Disable()
|
||||||
if control.buildPackage() {
|
if cBox.buildPackage() {
|
||||||
log.Info("build worked")
|
log.Info("build worked")
|
||||||
} else {
|
} else {
|
||||||
log.Warn("build failed")
|
log.Warn("build failed")
|
||||||
|
@ -50,20 +47,14 @@ func makebasicWindow() *gadgets.BasicWindow {
|
||||||
})
|
})
|
||||||
|
|
||||||
group1.NewButton("open repo", func() {
|
group1.NewButton("open repo", func() {
|
||||||
|
cBox.status.Update()
|
||||||
|
cBox.status.Toggle()
|
||||||
})
|
})
|
||||||
/*
|
|
||||||
group1.NewButton("show apple", func() {
|
|
||||||
apple.Show()
|
|
||||||
})
|
|
||||||
apple = group1.NewButton("apple", func() {
|
|
||||||
log.Info("is not a pear")
|
|
||||||
})
|
|
||||||
*/
|
|
||||||
|
|
||||||
return basicWindow
|
return basicWindow
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *controlFile) buildPackage() bool {
|
func (c *controlBox) buildPackage() bool {
|
||||||
if c.readControlFile() == nil {
|
if c.readControlFile() == nil {
|
||||||
log.Warn("scan worked")
|
log.Warn("scan worked")
|
||||||
} else {
|
} else {
|
||||||
|
@ -88,8 +79,10 @@ func (c *controlFile) buildPackage() bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
arch := c.Architecture.String()
|
arch := c.Architecture.String()
|
||||||
version := "0.0.0"
|
version := c.Version.String()
|
||||||
c.Version.SetText(version)
|
if version == "" {
|
||||||
|
version = "0.0.0"
|
||||||
|
}
|
||||||
|
|
||||||
debname := filename + "_" + version + "_" + arch + ".deb"
|
debname := filename + "_" + version + "_" + arch + ".deb"
|
||||||
|
|
||||||
|
@ -139,10 +132,12 @@ func (c *controlFile) buildPackage() bool {
|
||||||
log.Warn("build failed")
|
log.Warn("build failed")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
shell.Run([]string{"dpkg-deb", "-I", debname})
|
||||||
|
shell.Run([]string{"dpkg-deb", "-c", debname})
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *controlFile) writeFiles() bool {
|
func (c *controlBox) writeFiles() bool {
|
||||||
cf, err := os.OpenFile("files/DEBIAN/control", os.O_RDWR|os.O_CREATE, 0644)
|
cf, err := os.OpenFile("files/DEBIAN/control", os.O_RDWR|os.O_CREATE, 0644)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Info("open control file failed", err)
|
log.Info("open control file failed", err)
|
||||||
|
@ -157,7 +152,7 @@ func (c *controlFile) writeFiles() bool {
|
||||||
fmt.Fprintln(cf, "Maintainer:", c.Maintainer.String())
|
fmt.Fprintln(cf, "Maintainer:", c.Maintainer.String())
|
||||||
desc := c.Description.String()
|
desc := c.Description.String()
|
||||||
parts := strings.Split(desc, "\n")
|
parts := strings.Split(desc, "\n")
|
||||||
fmt.Fprintln(cf, "Description:", strings.Join(parts, " \n"))
|
fmt.Fprintln(cf, "Description:", strings.Join(parts, "\n "))
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue