diff options
| -rw-r--r-- | Makefile | 4 | ||||
| -rw-r--r-- | addRepo.go | 1 | ||||
| -rw-r--r-- | controlBox.go | 3 | ||||
| -rw-r--r-- | main.go | 11 | ||||
| -rw-r--r-- | readControlFile.go | 2 | ||||
| -rw-r--r-- | stateWindow.go | 69 |
6 files changed, 71 insertions, 19 deletions
@@ -1,10 +1,10 @@ .PHONY: debian run: build - ./go-deb --repo go.wit.com/apps/control-panel-dns + ./go-deb --repo go.wit.com/apps/autotypist no-gui: build - ./go-deb --no-gui --repo go.wit.com/apps/control-panel-dns + ./go-deb --no-gui --repo go.wit.com/apps/autotypist build: -cp ~/go/src/go.wit.com/toolkits/*.so resources/ @@ -1,4 +1,3 @@ -// This is a simple example package main import ( diff --git a/controlBox.go b/controlBox.go index fc4fc36..4d1b893 100644 --- a/controlBox.go +++ b/controlBox.go @@ -80,6 +80,3 @@ func newControl(parent *gui.Node) *controlBox { return c } - -func scanConfigFile() { -} @@ -42,8 +42,17 @@ func main() { filepath := filepath.Join("/home/jcarr/go/src", args.Repo) os.Chdir(filepath) + // scan the repo cBox.addRepo(args.Repo) - cBox.readControlFile() + // look for a 'config' file in the repo + if cBox.readControlFile() == nil { + log.Warn("scan worked") + } else { + log.Warn("scan failed") + } + cBox.computeControlValues() + // verify the values for the package + if args.NoGui { if cBox.buildPackage() { log.Info("build worked") diff --git a/readControlFile.go b/readControlFile.go index 7b07430..9def952 100644 --- a/readControlFile.go +++ b/readControlFile.go @@ -2,6 +2,7 @@ package main import ( "bufio" + "errors" "os" "strings" @@ -13,6 +14,7 @@ func (c *controlBox) readControlFile() error { file, err := os.Open("control") if err != nil { log.Warn("readControlFile() could not find the file") + return errors.New("'control': file not found") } defer file.Close() diff --git a/stateWindow.go b/stateWindow.go index 9f9f166..d42de22 100644 --- a/stateWindow.go +++ b/stateWindow.go @@ -56,11 +56,10 @@ func makebasicWindow() *gadgets.BasicWindow { } func (c *controlBox) buildPackage() bool { - if c.readControlFile() == nil { - log.Warn("scan worked") - } else { - log.Warn("scan failed") - return false + // TODO: if dirty, set GO111MODULE + // also, if last tag != version + if c.status.CheckDirty() { + os.Setenv("GO111MODULE", "off") } if shell.Run([]string{"go", "build", "-v", "-x"}) { log.Warn("build worked") @@ -91,10 +90,6 @@ func (c *controlBox) buildPackage() bool { log.Warn("mkdir failed") return false } - if !shell.Mkdir("files/usr/lib/" + filename) { - log.Warn("mkdir failed") - return false - } if shell.Exists("files/DEBIAN") { if !shell.Run([]string{"rm", "-rf", "files/DEBIAN"}) { log.Warn("rm failed") @@ -117,10 +112,29 @@ func (c *controlBox) buildPackage() bool { log.Warn("strip failed") return false } - if !shell.Run([]string{"cp", "README.md", "files/usr/lib/" + filename}) { - log.Warn("cp failed") - return false + + // put the README in there (if missing, generate it?) + var readme string = "" + if shell.Exists("README.md") { + readme = "README.md" + } + + if shell.Exists("README") { + readme = "README" + } + + if readme != "" { + path := filepath.Join("files/usr/lib/" + filename) + if !shell.Mkdir(path) { + log.Warn("mkdir failed") + return false + } + if !shell.Run([]string{"cp", readme, path}) { + log.Warn("cp failed") + return false + } } + if !c.writeFiles() { log.Warn("write control file failed") return false @@ -164,3 +178,34 @@ func (c *controlBox) writeFiles() bool { return true } + +// try to guess or figure out the config file values +// if there is not a control file +func (c *controlBox) computeControlValues() bool { + if c.Package.String() == "" { + // get the package name from the repo name + path := c.pathL.String() + parts := strings.Split(path, "/") + name := parts[len(parts) - 1] + c.Package.SetText(name) + } + if c.Source.String() == "" { + c.Source.SetText(c.Package.String()) + } + if c.BuildDepends.String() == "" { + c.BuildDepends.SetText("golang") + } + if c.Recommends.String() == "" { + c.Recommends.SetText("go-gui-toolkits") + } + // TODO: get this from the git log + if c.Maintainer.String() == "" { + c.Maintainer.SetText("Jeff Carr <[email protected]>") + } + // TODO: get this from gitea (or gitlab or github, etc) + // or from the README.md ? + if c.Description.String() == "" { + c.Description.SetText("no control file") + } + return true +} |
