summaryrefslogtreecommitdiff
path: root/stateWindow.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-02-11 03:51:37 -0600
committerJeff Carr <[email protected]>2024-02-11 03:51:37 -0600
commit2df4dc135abf279511c9c44c2609453b8cd612c1 (patch)
treec384d77e2a5668abf352d1d9f0b07a360606dbfa /stateWindow.go
parent3740ef98340655a2ec950eb4396095a423045d93 (diff)
next thing to do is generate the md5sums file
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'stateWindow.go')
-rw-r--r--stateWindow.go65
1 files changed, 63 insertions, 2 deletions
diff --git a/stateWindow.go b/stateWindow.go
index 5d88d8e..3fda09d 100644
--- a/stateWindow.go
+++ b/stateWindow.go
@@ -3,7 +3,9 @@
package main
import (
+ "fmt"
"os"
+ "strings"
"go.wit.com/gui"
"go.wit.com/lib/gadgets"
@@ -86,11 +88,50 @@ func (c *controlFile) buildPackage() bool {
}
arch := c.Architecture.String()
- version := "v0.0.0"
+ version := "0.0.0"
+ c.Version.SetText(version)
debname := filename + "_" + version + "_" + arch + ".deb"
- shell.Run([]string{"strip", filename})
+ if !shell.Mkdir("files/usr/bin") {
+ 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")
+ return false
+ }
+ }
+ if shell.Exists("files/DEBIAN") {
+ log.Warn("rm failed")
+ return false
+ }
+ if !shell.Mkdir("files/DEBIAN") {
+ log.Warn("mkdir failed")
+ return false
+ }
+ if !shell.Run([]string{"cp", filename, "files/usr/bin"}) {
+ log.Warn("cp failed")
+ return false
+ }
+ if !shell.Run([]string{"strip", "files/usr/bin/" + filename}) {
+ log.Warn("strip failed")
+ return false
+ }
+ if !shell.Run([]string{"cp", "README.md", "files/usr/lib/" + filename}) {
+ log.Warn("cp failed")
+ return false
+ }
+ if !c.writeFiles() {
+ log.Warn("write control file failed")
+ return false
+ }
+
shell.Run([]string{"dpkg-deb", "--build", "files", debname})
if shell.Exists(debname) {
log.Warn("build worked")
@@ -100,3 +141,23 @@ func (c *controlFile) buildPackage() bool {
}
return true
}
+
+func (c *controlFile) writeFiles() bool {
+ cf, err := os.OpenFile("files/DEBIAN/control", os.O_RDWR|os.O_CREATE, 0644)
+ if err != nil {
+ log.Info("open control file failed", err)
+ return false
+ }
+ fmt.Fprintln(cf, "Package:", c.Package.String())
+ fmt.Fprintln(cf, "Source:", c.Source.String())
+ fmt.Fprintln(cf, "Version:", c.Version.String())
+ fmt.Fprintln(cf, "Architecture:", c.Architecture.String())
+ fmt.Fprintln(cf, "Depends:", c.Depends.String())
+ fmt.Fprintln(cf, "Build-Depends:", c.BuildDepends.String())
+ fmt.Fprintln(cf, "Maintainer:", c.Maintainer.String())
+ desc := c.Description.String()
+ parts := strings.Split(desc, "\n")
+ fmt.Fprintln(cf, "Description:", strings.Join(parts, " \n"))
+
+ return true
+}