preliminary file scan and build
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
b29d6caf34
commit
eed897eefd
|
@ -1,6 +1,6 @@
|
||||||
Source: control-panel-dns
|
Source: go-deb
|
||||||
Build-Depends: golang
|
Build-Depends: golang
|
||||||
Package: control-panel-dns
|
Package: go-deb
|
||||||
Maintainer: Jeff Carr <jcarr@wit.com>
|
Maintainer: Jeff Carr <jcarr@wit.com>
|
||||||
Architecture: amd64
|
Architecture: amd64
|
||||||
Depends:
|
Depends:
|
|
@ -11,6 +11,7 @@ type controlFile struct {
|
||||||
grid *gui.Node // the grid
|
grid *gui.Node // the grid
|
||||||
|
|
||||||
Package *gadgets.OneLiner
|
Package *gadgets.OneLiner
|
||||||
|
Source *gadgets.OneLiner
|
||||||
Maintainer *gadgets.OneLiner
|
Maintainer *gadgets.OneLiner
|
||||||
Architecture *gadgets.BasicDropdown
|
Architecture *gadgets.BasicDropdown
|
||||||
InstallPath *gadgets.BasicCombobox
|
InstallPath *gadgets.BasicCombobox
|
||||||
|
@ -29,6 +30,10 @@ func newControl(parent *gui.Node) *controlFile {
|
||||||
|
|
||||||
c.Package = gadgets.NewOneLiner(c.grid, "Package")
|
c.Package = gadgets.NewOneLiner(c.grid, "Package")
|
||||||
c.grid.NextRow()
|
c.grid.NextRow()
|
||||||
|
|
||||||
|
c.Source = gadgets.NewOneLiner(c.grid, "Source")
|
||||||
|
c.grid.NextRow()
|
||||||
|
|
||||||
c.Architecture = gadgets.NewBasicDropdown(c.grid, "Architecture")
|
c.Architecture = gadgets.NewBasicDropdown(c.grid, "Architecture")
|
||||||
c.Architecture.AddText("riscv")
|
c.Architecture.AddText("riscv")
|
||||||
c.Architecture.AddText("amd64")
|
c.Architecture.AddText("amd64")
|
||||||
|
@ -62,3 +67,6 @@ func newControl(parent *gui.Node) *controlFile {
|
||||||
|
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func scanConfigFile() {
|
||||||
|
}
|
||||||
|
|
|
@ -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
|
||||||
|
}
|
|
@ -7,6 +7,7 @@ import (
|
||||||
|
|
||||||
"go.wit.com/gui"
|
"go.wit.com/gui"
|
||||||
"go.wit.com/lib/gadgets"
|
"go.wit.com/lib/gadgets"
|
||||||
|
"go.wit.com/lib/gui/shell"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -23,16 +24,22 @@ func makebasicWindow() *gadgets.BasicWindow {
|
||||||
}
|
}
|
||||||
|
|
||||||
box1 := basicWindow.Box()
|
box1 := basicWindow.Box()
|
||||||
newControl(box1)
|
control := newControl(box1)
|
||||||
|
|
||||||
// vbox := box1.NewBox("vbox", false)
|
|
||||||
// vbox := box1.Box().Vertical()
|
|
||||||
vbox := box1.Box().Horizontal()
|
vbox := box1.Box().Horizontal()
|
||||||
group1 := vbox.NewGroup("controls").Horizontal() // Vertical()
|
group1 := vbox.NewGroup("controls").Horizontal() // Vertical()
|
||||||
|
|
||||||
group1.NewButton("go build", func() {
|
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("Make .deb", func() {
|
||||||
})
|
})
|
||||||
|
|
||||||
group1.NewButton("open repo", func() {
|
group1.NewButton("open repo", func() {
|
||||||
})
|
})
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in New Issue