From eed897eefde13caff77cd3c62c2a62f77165a129 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sun, 11 Feb 2024 02:16:51 -0600 Subject: preliminary file scan and build Signed-off-by: Jeff Carr --- control | 9 ++++++ controlBox.go | 8 ++++++ debian/control | 9 ------ readControlFile.go | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ stateWindow.go | 13 +++++++-- 5 files changed, 108 insertions(+), 12 deletions(-) create mode 100644 control delete mode 100644 debian/control create mode 100644 readControlFile.go diff --git a/control b/control new file mode 100644 index 0000000..12f6b3b --- /dev/null +++ b/control @@ -0,0 +1,9 @@ +Source: go-deb +Build-Depends: golang +Package: go-deb +Maintainer: Jeff Carr +Architecture: amd64 +Depends: +Recommends: libgtk-3-0, ddclient, ddupdate +Description: a control panel for DNS and IPv6 settings + Goals: show the settings, validate & update DNS diff --git a/controlBox.go b/controlBox.go index 846c5dc..4d3cec4 100644 --- a/controlBox.go +++ b/controlBox.go @@ -11,6 +11,7 @@ type controlFile struct { grid *gui.Node // the grid Package *gadgets.OneLiner + Source *gadgets.OneLiner Maintainer *gadgets.OneLiner Architecture *gadgets.BasicDropdown InstallPath *gadgets.BasicCombobox @@ -29,6 +30,10 @@ func newControl(parent *gui.Node) *controlFile { c.Package = gadgets.NewOneLiner(c.grid, "Package") c.grid.NextRow() + + c.Source = gadgets.NewOneLiner(c.grid, "Source") + c.grid.NextRow() + c.Architecture = gadgets.NewBasicDropdown(c.grid, "Architecture") c.Architecture.AddText("riscv") c.Architecture.AddText("amd64") @@ -62,3 +67,6 @@ func newControl(parent *gui.Node) *controlFile { return c } + +func scanConfigFile() { +} diff --git a/debian/control b/debian/control deleted file mode 100644 index 1a46081..0000000 --- a/debian/control +++ /dev/null @@ -1,9 +0,0 @@ -Source: control-panel-dns -Build-Depends: golang -Package: control-panel-dns -Maintainer: Jeff Carr -Architecture: amd64 -Depends: -Recommends: libgtk-3-0, ddclient, ddupdate -Description: a control panel for DNS and IPv6 settings - Goals: show the settings, validate & update DNS diff --git a/readControlFile.go b/readControlFile.go new file mode 100644 index 0000000..7431f2a --- /dev/null +++ b/readControlFile.go @@ -0,0 +1,81 @@ +package main + +import ( + "bufio" + "os" + "strings" + + "go.wit.com/log" +) + +// readGitConfig reads and parses the control file +func (c *controlFile) readControlFile() error { + file, err := os.Open("control") + if err != nil { + log.Warn("readControlFile() could not find the file") + } + defer file.Close() + + pairs := make(map[string]string) + var key string + + scanner := bufio.NewScanner(file) + for scanner.Scan() { + line := scanner.Text() + + // Skip empty lines and comments + if line == "" || strings.HasPrefix(line, "#") || strings.HasPrefix(line, ";") { + continue + } + + // if line starts with a space, it's part of the last key + if strings.HasPrefix(line, " ") { + pairs[key] = pairs[key] + "\n" + strings.TrimSpace(line) + continue + } + + partsNew := strings.SplitN(line, ":", 2) + if len(partsNew) < 2 { + log.Warn("error on line:", line) + continue + } + + key = strings.TrimSpace(partsNew[0]) + value := strings.TrimSpace(partsNew[1]) + pairs[key] = value + } + for key, value := range pairs { + switch key { + case "Source": + // log.Info("FOUND Source!", value) + c.Source.SetText(value) + case "Build-Depends": + c.BuildDepends.SetText(value) + case "Description": + c.Description.SetText(value) + case "Maintainer": + c.Maintainer.SetText(value) + case "Depends": + c.Depends.SetText(value) + case "Recommends": + c.Recommends.SetText(value) + case "Package": + c.Package.SetText(value) + // if c.Package.String() != value { + // log.Warn("not sure what to do with Package", c.Package.String(), value) + // } + case "Architecture": + if c.Architecture.String() != value { + log.Warn("not sure what to do with Architecture", c.Architecture.String(), value) + } + default: + log.Warn("error unknown key", key, "value:", value) + } + } + + if err := scanner.Err(); err != nil { + return err + } + + return nil +} diff --git a/stateWindow.go b/stateWindow.go index 84d82e8..afef4b2 100644 --- a/stateWindow.go +++ b/stateWindow.go @@ -7,6 +7,7 @@ import ( "go.wit.com/gui" "go.wit.com/lib/gadgets" + "go.wit.com/lib/gui/shell" "go.wit.com/log" ) @@ -23,16 +24,22 @@ func makebasicWindow() *gadgets.BasicWindow { } box1 := basicWindow.Box() - newControl(box1) + control := newControl(box1) - // vbox := box1.NewBox("vbox", false) - // vbox := box1.Box().Vertical() vbox := box1.Box().Horizontal() group1 := vbox.NewGroup("controls").Horizontal() // Vertical() + group1.NewButton("go build", func() { + shell.Run([]string{"go", "build", "-v", "-x"}) + }) + + group1.NewButton("read control file", func() { + control.readControlFile() }) + group1.NewButton("Make .deb", func() { }) + group1.NewButton("open repo", func() { }) /* -- cgit v1.2.3