diff options
Diffstat (limited to 'stateWindow.go')
| -rw-r--r-- | stateWindow.go | 43 |
1 files changed, 34 insertions, 9 deletions
diff --git a/stateWindow.go b/stateWindow.go index d42de22..142c8b7 100644 --- a/stateWindow.go +++ b/stateWindow.go @@ -6,7 +6,9 @@ import ( "fmt" "os" "path/filepath" + "strconv" "strings" + "time" "go.wit.com/lib/gadgets" "go.wit.com/lib/gui/shell" @@ -86,17 +88,13 @@ func (c *controlBox) buildPackage() bool { debname := filename + "_" + version + "_" + arch + ".deb" - if !shell.Mkdir("files/usr/bin") { - log.Warn("mkdir failed") - return false - } - if shell.Exists("files/DEBIAN") { - if !shell.Run([]string{"rm", "-rf", "files/DEBIAN"}) { + if shell.Exists("files") { + if !shell.Run([]string{"rm", "-rf", "files"}) { log.Warn("rm failed") return false } } - if shell.Exists("files/DEBIAN") { + if shell.Exists("files") { log.Warn("rm failed") return false } @@ -104,6 +102,10 @@ func (c *controlBox) buildPackage() bool { log.Warn("mkdir failed") return false } + if !shell.Mkdir("files/usr/bin") { + log.Warn("mkdir failed") + return false + } if !shell.Run([]string{"cp", filename, "files/usr/bin"}) { log.Warn("cp failed") return false @@ -171,6 +173,11 @@ func (c *controlBox) writeFiles() bool { fmt.Fprintln(cf, "Architecture:", c.Architecture.String()) fmt.Fprintln(cf, "Depends:", c.Depends.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()) desc := c.Description.String() parts := strings.Split(desc, "\n") @@ -186,7 +193,7 @@ func (c *controlBox) computeControlValues() bool { // get the package name from the repo name path := c.pathL.String() parts := strings.Split(path, "/") - name := parts[len(parts) - 1] + name := parts[len(parts)-1] c.Package.SetText(name) } if c.Source.String() == "" { @@ -205,7 +212,25 @@ func (c *controlBox) computeControlValues() bool { // 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") + c.Description.SetText("missing control file") } 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") +} |
