diff options
| author | Jeff Carr <[email protected]> | 2024-02-11 21:49:39 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2024-02-11 21:49:39 -0600 |
| commit | b3eea67983ef8bdfa814b097d3cdf6a952d4ea78 (patch) | |
| tree | fe778047cb42af629faf9a0a406cd588b8c001e4 /stateWindow.go | |
| parent | 98293e4bf9bdb91295f0cbe4653db3f9dcb2d701 (diff) | |
compute control file if it doesn't exist
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'stateWindow.go')
| -rw-r--r-- | stateWindow.go | 69 |
1 files changed, 57 insertions, 12 deletions
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 +} |
