add build and tag dates to .deb packages
This commit is contained in:
parent
b3eea67983
commit
4348b1636c
14
addRepo.go
14
addRepo.go
|
@ -2,6 +2,7 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"go.wit.com/lib/gadgets"
|
"go.wit.com/lib/gadgets"
|
||||||
"go.wit.com/lib/gui/repostatus"
|
"go.wit.com/lib/gui/repostatus"
|
||||||
|
@ -36,7 +37,6 @@ func (c *controlBox) addRepo(path string) {
|
||||||
c.grid.NextRow()
|
c.grid.NextRow()
|
||||||
|
|
||||||
c.lastTag = gadgets.NewOneLiner(c.grid, "lastTag")
|
c.lastTag = gadgets.NewOneLiner(c.grid, "lastTag")
|
||||||
c.lastTag.SetText(path)
|
|
||||||
c.grid.NextRow()
|
c.grid.NextRow()
|
||||||
|
|
||||||
c.dirtyL = gadgets.NewOneLiner(c.grid, "dirty")
|
c.dirtyL = gadgets.NewOneLiner(c.grid, "dirty")
|
||||||
|
@ -45,6 +45,15 @@ func (c *controlBox) addRepo(path string) {
|
||||||
c.currentL = gadgets.NewOneLiner(c.grid, "current")
|
c.currentL = gadgets.NewOneLiner(c.grid, "current")
|
||||||
c.grid.NextRow()
|
c.grid.NextRow()
|
||||||
|
|
||||||
|
c.buildDate = gadgets.NewOneLiner(c.grid, "Build Date")
|
||||||
|
c.grid.NextRow()
|
||||||
|
|
||||||
|
stamp := time.Now().UTC().Format("2006/01/02 15:04:05 UTC")
|
||||||
|
c.buildDate.SetText(stamp)
|
||||||
|
|
||||||
|
c.tagDate = gadgets.NewOneLiner(c.grid, "git tag Date")
|
||||||
|
c.grid.NextRow()
|
||||||
|
|
||||||
c.status = repostatus.NewRepoStatusWindow(path)
|
c.status = repostatus.NewRepoStatusWindow(path)
|
||||||
c.status.SetMainWorkingName("master")
|
c.status.SetMainWorkingName("master")
|
||||||
c.status.SetDevelWorkingName("devel")
|
c.status.SetDevelWorkingName("devel")
|
||||||
|
@ -68,6 +77,9 @@ func (c *controlBox) addRepo(path string) {
|
||||||
c.lastTag.SetText(lasttag)
|
c.lastTag.SetText(lasttag)
|
||||||
c.currentL.SetText(cbname + " " + cbversion)
|
c.currentL.SetText(cbname + " " + cbversion)
|
||||||
|
|
||||||
|
tagDate := c.getDateStamp(lasttag)
|
||||||
|
c.tagDate.SetText(tagDate)
|
||||||
|
|
||||||
if c.status.Changed() {
|
if c.status.Changed() {
|
||||||
log.Warn("should scan here")
|
log.Warn("should scan here")
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,11 +23,13 @@ type controlBox struct {
|
||||||
Description *gadgets.OneLiner
|
Description *gadgets.OneLiner
|
||||||
|
|
||||||
// repostatus things
|
// repostatus things
|
||||||
pathL *gadgets.OneLiner
|
pathL *gadgets.OneLiner
|
||||||
lastTag *gadgets.OneLiner
|
lastTag *gadgets.OneLiner
|
||||||
dirtyL *gadgets.OneLiner
|
dirtyL *gadgets.OneLiner
|
||||||
currentL *gadgets.OneLiner
|
currentL *gadgets.OneLiner
|
||||||
status *repostatus.RepoStatus
|
buildDate *gadgets.OneLiner
|
||||||
|
tagDate *gadgets.OneLiner
|
||||||
|
status *repostatus.RepoStatus
|
||||||
}
|
}
|
||||||
|
|
||||||
// This initializes the control box
|
// This initializes the control box
|
||||||
|
|
|
@ -6,7 +6,9 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"go.wit.com/lib/gadgets"
|
"go.wit.com/lib/gadgets"
|
||||||
"go.wit.com/lib/gui/shell"
|
"go.wit.com/lib/gui/shell"
|
||||||
|
@ -86,17 +88,13 @@ func (c *controlBox) buildPackage() bool {
|
||||||
|
|
||||||
debname := filename + "_" + version + "_" + arch + ".deb"
|
debname := filename + "_" + version + "_" + arch + ".deb"
|
||||||
|
|
||||||
if !shell.Mkdir("files/usr/bin") {
|
if shell.Exists("files") {
|
||||||
log.Warn("mkdir failed")
|
if !shell.Run([]string{"rm", "-rf", "files"}) {
|
||||||
return false
|
|
||||||
}
|
|
||||||
if shell.Exists("files/DEBIAN") {
|
|
||||||
if !shell.Run([]string{"rm", "-rf", "files/DEBIAN"}) {
|
|
||||||
log.Warn("rm failed")
|
log.Warn("rm failed")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if shell.Exists("files/DEBIAN") {
|
if shell.Exists("files") {
|
||||||
log.Warn("rm failed")
|
log.Warn("rm failed")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -104,6 +102,10 @@ func (c *controlBox) buildPackage() bool {
|
||||||
log.Warn("mkdir failed")
|
log.Warn("mkdir failed")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
if !shell.Mkdir("files/usr/bin") {
|
||||||
|
log.Warn("mkdir failed")
|
||||||
|
return false
|
||||||
|
}
|
||||||
if !shell.Run([]string{"cp", filename, "files/usr/bin"}) {
|
if !shell.Run([]string{"cp", filename, "files/usr/bin"}) {
|
||||||
log.Warn("cp failed")
|
log.Warn("cp failed")
|
||||||
return false
|
return false
|
||||||
|
@ -171,6 +173,11 @@ func (c *controlBox) writeFiles() bool {
|
||||||
fmt.Fprintln(cf, "Architecture:", c.Architecture.String())
|
fmt.Fprintln(cf, "Architecture:", c.Architecture.String())
|
||||||
fmt.Fprintln(cf, "Depends:", c.Depends.String())
|
fmt.Fprintln(cf, "Depends:", c.Depends.String())
|
||||||
fmt.Fprintln(cf, "Build-Depends:", c.BuildDepends.String())
|
fmt.Fprintln(cf, "Build-Depends:", c.BuildDepends.String())
|
||||||
|
stamp := time.Now().UTC().Format("2006/01/02 15:04:05 UTC")
|
||||||
|
// update to now now despite what the GUI is showing
|
||||||
|
fmt.Fprintln(cf, "Package-Build-Date:", stamp)
|
||||||
|
fmt.Fprintln(cf, "Git-Tag-Date:", c.tagDate.String())
|
||||||
|
|
||||||
fmt.Fprintln(cf, "Maintainer:", c.Maintainer.String())
|
fmt.Fprintln(cf, "Maintainer:", c.Maintainer.String())
|
||||||
desc := c.Description.String()
|
desc := c.Description.String()
|
||||||
parts := strings.Split(desc, "\n")
|
parts := strings.Split(desc, "\n")
|
||||||
|
@ -186,7 +193,7 @@ func (c *controlBox) computeControlValues() bool {
|
||||||
// get the package name from the repo name
|
// get the package name from the repo name
|
||||||
path := c.pathL.String()
|
path := c.pathL.String()
|
||||||
parts := strings.Split(path, "/")
|
parts := strings.Split(path, "/")
|
||||||
name := parts[len(parts) - 1]
|
name := parts[len(parts)-1]
|
||||||
c.Package.SetText(name)
|
c.Package.SetText(name)
|
||||||
}
|
}
|
||||||
if c.Source.String() == "" {
|
if c.Source.String() == "" {
|
||||||
|
@ -205,7 +212,25 @@ func (c *controlBox) computeControlValues() bool {
|
||||||
// TODO: get this from gitea (or gitlab or github, etc)
|
// TODO: get this from gitea (or gitlab or github, etc)
|
||||||
// or from the README.md ?
|
// or from the README.md ?
|
||||||
if c.Description.String() == "" {
|
if c.Description.String() == "" {
|
||||||
c.Description.SetText("no control file")
|
c.Description.SetText("missing control file")
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// stamp := time.Now().UTC().Format("2006/01/02 15:04:05 UTC")
|
||||||
|
|
||||||
|
func (c *controlBox) getDateStamp(tag string) string {
|
||||||
|
_, out := c.status.RunCmd([]string{"git", "log", "-1", "--format=%at", tag})
|
||||||
|
out = strings.TrimSpace(out)
|
||||||
|
|
||||||
|
// Convert the string to an integer
|
||||||
|
gitTagTimestampInt, err := strconv.ParseInt(out, 10, 64)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("Error converting timestamp:", err)
|
||||||
|
return "git tag " + tag + " unknown"
|
||||||
|
}
|
||||||
|
|
||||||
|
// Parse the Unix timestamp into a time.Time object
|
||||||
|
gitTagDate := time.Unix(gitTagTimestampInt, 0)
|
||||||
|
return gitTagDate.UTC().Format("2006/01/02 15:04:05 UTC")
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue