From 4bf23793574fb57d749cf6a213195b195f957017 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Tue, 19 Nov 2024 05:30:56 -0600 Subject: [PATCH] better control file value handling --- addRepo.go | 2 +- buildPackage.go | 24 +++++++++++++++++++----- controlBox.go | 10 +++++++++- examples/pkgsite/control | 7 +++---- examples/protoc-gen-go/control | 6 ++---- readControlFile.go | 6 +++++- 6 files changed, 39 insertions(+), 16 deletions(-) diff --git a/addRepo.go b/addRepo.go index 6f6e7f4..279892c 100644 --- a/addRepo.go +++ b/addRepo.go @@ -52,7 +52,7 @@ func (c *controlBox) addRepo(path string) { 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.tagDate = gadgets.NewBasicEntry(c.grid, "git tag Date") c.grid.NextRow() err, repo := repostatus.NewRepoStatusWindow(path) diff --git a/buildPackage.go b/buildPackage.go index 047f77c..67a2752 100644 --- a/buildPackage.go +++ b/buildPackage.go @@ -220,15 +220,29 @@ func (c *controlBox) writeDebianControlFile() bool { 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()) + if c.Depends.String() != "" { + fmt.Fprintln(cf, "Depends:", c.Depends.String()) + } + if 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()) + if c.tagDate.String() == "" { + // todo: allow this to be set somehow + } else { + fmt.Fprintln(cf, "Git-Tag-Date:", c.tagDate.String()) + } fmt.Fprintln(cf, "Maintainer:", c.Maintainer.String()) - fmt.Fprintln(cf, "Conflicts:", c.Conflicts.String()) + fmt.Fprintln(cf, "Packager:", c.Packager.String()) + if c.URL.String() != "" { + fmt.Fprintln(cf, "URL:", c.URL.String()) + } + if c.Conflicts.String() != "" { + fmt.Fprintln(cf, "Conflicts:", c.Conflicts.String()) + } desc := c.Description.String() parts := strings.Split(desc, "\n") @@ -258,7 +272,7 @@ func (c *controlBox) computeControlValues() bool { } // TODO: get this from the git log if c.Maintainer.String() == "" { - c.Maintainer.SetText("Jeff Carr ") + c.Maintainer.SetText("made by go-deb") } // TODO: get this from gitea (or gitlab or github, etc) // or from the README.md ? diff --git a/controlBox.go b/controlBox.go index ba8d377..2f9f73f 100644 --- a/controlBox.go +++ b/controlBox.go @@ -14,6 +14,8 @@ type controlBox struct { Source *gadgets.OneLiner Version *gadgets.OneLiner Maintainer *gadgets.OneLiner + Packager *gadgets.BasicEntry + URL *gadgets.BasicEntry Architecture *gadgets.BasicDropdown InstallPath *gadgets.BasicCombobox Depends *gadgets.OneLiner @@ -29,7 +31,7 @@ type controlBox struct { dirtyL *gadgets.OneLiner currentL *gadgets.OneLiner buildDate *gadgets.OneLiner - tagDate *gadgets.OneLiner + tagDate *gadgets.BasicEntry status *repostatus.RepoStatus } @@ -72,6 +74,12 @@ func newControl(parent *gui.Node) *controlBox { c.Maintainer = gadgets.NewOneLiner(c.grid, "Maintainer") c.grid.NextRow() + c.Packager = gadgets.NewBasicEntry(c.grid, "Packager") + c.grid.NextRow() + + c.URL = gadgets.NewBasicEntry(c.grid, "URL") + c.grid.NextRow() + c.Depends = gadgets.NewOneLiner(c.grid, "Depends") c.grid.NextRow() diff --git a/examples/pkgsite/control b/examples/pkgsite/control index dee1b4f..61c3c25 100644 --- a/examples/pkgsite/control +++ b/examples/pkgsite/control @@ -1,11 +1,10 @@ -Source: Package: pkgsite -Build-Depends: -Maintainer: golang +Maintainer: https://golang.org/x/pkgsite Packager: Jeff Carr Architecture: amd64 Depends: -URL: golang.org/x/pkgsite +Source: go-clone golang.org/x/pkgsite +URL: https://golang.org/x/pkgsite Version: 0.0.1 Description: pkgsite This was packaged with go-deb from go.wit.com diff --git a/examples/protoc-gen-go/control b/examples/protoc-gen-go/control index e0b826a..65c7019 100644 --- a/examples/protoc-gen-go/control +++ b/examples/protoc-gen-go/control @@ -1,14 +1,12 @@ -Source: google.golang.org.protobuf +Source: go-clone google.golang.org/protobuf Build-Depends: golang Package: protoc-gen-go-wit -Maintainer: Jeff Carr +Maintainer: https://google.golang.org/protobuf/ Packager: Jeff Carr Architecture: amd64 Depends: protobuf-compiler Conflicts: protoc-gen-go, protoc-gen-go-1-3, protoc-gen-go-1-5 -URL: https://go.wit.com/ Recommends: Version: 1.35.1-devel Description: protoc-gen-go from google.golang.org/protobuf - You need this one until the debian sid packages are updated I didn't change anything, it's a straight build from the sources. diff --git a/readControlFile.go b/readControlFile.go index 50a4fdd..bf55ca9 100644 --- a/readControlFile.go +++ b/readControlFile.go @@ -58,13 +58,17 @@ func (c *controlBox) readControlFile() error { for key, value := range pairs { switch key { case "Source": - // log.Info("FOUND Source!", value) c.Source.SetText(value) + c.Source.SetText(value) case "Build-Depends": c.BuildDepends.SetText(value) case "Description": c.Description.SetText(value) case "Maintainer": c.Maintainer.SetText(value) + case "Packager": + c.Packager.SetText(value) + case "URL": + c.URL.SetText(value) case "Depends": c.Depends.SetText(value) case "Recommends":