compute control file if it doesn't exist
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
98293e4bf9
commit
b3eea67983
4
Makefile
4
Makefile
|
@ -1,10 +1,10 @@
|
||||||
.PHONY: debian
|
.PHONY: debian
|
||||||
|
|
||||||
run: build
|
run: build
|
||||||
./go-deb --repo go.wit.com/apps/control-panel-dns
|
./go-deb --repo go.wit.com/apps/autotypist
|
||||||
|
|
||||||
no-gui: build
|
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:
|
build:
|
||||||
-cp ~/go/src/go.wit.com/toolkits/*.so resources/
|
-cp ~/go/src/go.wit.com/toolkits/*.so resources/
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
// This is a simple example
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
|
@ -80,6 +80,3 @@ func newControl(parent *gui.Node) *controlBox {
|
||||||
|
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
|
||||||
func scanConfigFile() {
|
|
||||||
}
|
|
||||||
|
|
11
main.go
11
main.go
|
@ -42,8 +42,17 @@ func main() {
|
||||||
filepath := filepath.Join("/home/jcarr/go/src", args.Repo)
|
filepath := filepath.Join("/home/jcarr/go/src", args.Repo)
|
||||||
os.Chdir(filepath)
|
os.Chdir(filepath)
|
||||||
|
|
||||||
|
// scan the repo
|
||||||
cBox.addRepo(args.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 args.NoGui {
|
||||||
if cBox.buildPackage() {
|
if cBox.buildPackage() {
|
||||||
log.Info("build worked")
|
log.Info("build worked")
|
||||||
|
|
|
@ -2,6 +2,7 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
|
"errors"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
@ -13,6 +14,7 @@ func (c *controlBox) readControlFile() error {
|
||||||
file, err := os.Open("control")
|
file, err := os.Open("control")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warn("readControlFile() could not find the file")
|
log.Warn("readControlFile() could not find the file")
|
||||||
|
return errors.New("'control': file not found")
|
||||||
}
|
}
|
||||||
defer file.Close()
|
defer file.Close()
|
||||||
|
|
||||||
|
|
|
@ -56,11 +56,10 @@ func makebasicWindow() *gadgets.BasicWindow {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *controlBox) buildPackage() bool {
|
func (c *controlBox) buildPackage() bool {
|
||||||
if c.readControlFile() == nil {
|
// TODO: if dirty, set GO111MODULE
|
||||||
log.Warn("scan worked")
|
// also, if last tag != version
|
||||||
} else {
|
if c.status.CheckDirty() {
|
||||||
log.Warn("scan failed")
|
os.Setenv("GO111MODULE", "off")
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
if shell.Run([]string{"go", "build", "-v", "-x"}) {
|
if shell.Run([]string{"go", "build", "-v", "-x"}) {
|
||||||
log.Warn("build worked")
|
log.Warn("build worked")
|
||||||
|
@ -91,10 +90,6 @@ func (c *controlBox) buildPackage() bool {
|
||||||
log.Warn("mkdir failed")
|
log.Warn("mkdir failed")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if !shell.Mkdir("files/usr/lib/" + filename) {
|
|
||||||
log.Warn("mkdir failed")
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
if shell.Exists("files/DEBIAN") {
|
if shell.Exists("files/DEBIAN") {
|
||||||
if !shell.Run([]string{"rm", "-rf", "files/DEBIAN"}) {
|
if !shell.Run([]string{"rm", "-rf", "files/DEBIAN"}) {
|
||||||
log.Warn("rm failed")
|
log.Warn("rm failed")
|
||||||
|
@ -117,10 +112,29 @@ func (c *controlBox) buildPackage() bool {
|
||||||
log.Warn("strip failed")
|
log.Warn("strip failed")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if !shell.Run([]string{"cp", "README.md", "files/usr/lib/" + filename}) {
|
|
||||||
log.Warn("cp failed")
|
// put the README in there (if missing, generate it?)
|
||||||
return false
|
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() {
|
if !c.writeFiles() {
|
||||||
log.Warn("write control file failed")
|
log.Warn("write control file failed")
|
||||||
return false
|
return false
|
||||||
|
@ -164,3 +178,34 @@ func (c *controlBox) writeFiles() bool {
|
||||||
|
|
||||||
return true
|
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 <jcarr@wit.com>")
|
||||||
|
}
|
||||||
|
// 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
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue