diff --git a/debian/control b/control similarity index 81% rename from debian/control rename to control index 1a46081..12f6b3b 100644 --- a/debian/control +++ b/control @@ -1,6 +1,6 @@ -Source: control-panel-dns +Source: go-deb Build-Depends: golang -Package: control-panel-dns +Package: go-deb Maintainer: Jeff Carr Architecture: amd64 Depends: 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/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() { }) /*