summaryrefslogtreecommitdiff
path: root/keyGetFromPackaagePB.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-10-14 01:51:44 -0500
committerJeff Carr <[email protected]>2025-10-14 01:52:56 -0500
commitd10cf84916f9171ae4eb579cd3871e4ec198f2a0 (patch)
tree0f43c90d95688e3bcb6dff9a6c08513df39a37b1 /keyGetFromPackaagePB.go
parentf8d3817ebee3913bb8aecff6ea5de8fde6a560ec (diff)
move this to lib/debian
Diffstat (limited to 'keyGetFromPackaagePB.go')
-rw-r--r--keyGetFromPackaagePB.go134
1 files changed, 134 insertions, 0 deletions
diff --git a/keyGetFromPackaagePB.go b/keyGetFromPackaagePB.go
new file mode 100644
index 0000000..a97e080
--- /dev/null
+++ b/keyGetFromPackaagePB.go
@@ -0,0 +1,134 @@
+package main
+
+import (
+ "strings"
+
+ "go.wit.com/lib/debian"
+ "go.wit.com/lib/protobuf/zoopb"
+ "go.wit.com/log"
+)
+
+// make a list of the newest .deb files
+func doMakePackagesFile(all *zoopb.Packages) string {
+ var pfile string
+ for p := range all.IterAll() {
+ var controlfile string
+ parts, err := zoopb.GetDebInfoFields(p)
+ if err != nil {
+ log.Info(err)
+ }
+ for _, varname := range parts {
+ varname, varval := debian.GetKeyFromPackagePB(p, varname)
+ varval = strings.TrimSpace(varval)
+ if varval == "" {
+ continue
+ }
+ controlfile += log.Sprintf("%s: %s\n", varname, varval)
+ }
+ controlfile += log.Sprintf("\n")
+ pfile += controlfile
+ }
+ return pfile
+}
+
+/*
+func keyGetFromPackagePB(p *zoopb.Package, varname string) (string, string) {
+ switch varname {
+ case "Package":
+ return "Package", p.Package
+ case "Filename":
+ return "Filename", p.Filename
+ case "Version":
+ return "Version", p.Version
+ case "Architecture":
+ return "Architecture", p.Architecture
+ case "Maintainer":
+ return "Maintainer", p.DebInfo.Maintainer
+ // return "Maintainer", p.Author
+ case "Source":
+ if argv.Verbose {
+ log.Info("skipping from controlfile", varname)
+ // return "Source", p.DebInfo.Source
+ }
+ return "Source", ""
+ case "Conflicts":
+ return "Conflicts", p.DebInfo.Conflicts
+ case "Packager":
+ return "Packager", p.DebInfo.Packager
+ // return "Packager", p.Packager
+ case "Depends":
+ return "Depends", p.DebInfo.Depends
+ case "Namespace":
+ return "Namespace", p.Namespace
+ case "GitHash":
+ return "Last-Git-Hash", p.DebInfo.GitHash
+ case "GitDate":
+ if p.DebInfo.GitDate == "" {
+ return "Git-Hash-Date", ""
+ }
+ return "Git-Hash-Date", cobol.Time(p.DebInfo.GitDate)
+ case "BuildDepends":
+ return "Build-Depends", p.DebInfo.BuildDepends
+ case "InstalledSize":
+ return "Installed-Size", p.DebInfo.InstalledSize
+ case "Homepage":
+ return "Homepage", p.DebInfo.Homepage
+ case "PreDepends":
+ return "Pre-Depends", p.DebInfo.PreDepends
+ case "Suggests":
+ return "Suggests", p.DebInfo.Suggests
+ case "MultiArch":
+ return "Multi-Arch", p.DebInfo.MultiArch
+ case "Tag":
+ return "Tag", p.DebInfo.Tag
+ case "Size":
+ return "Size", p.DebInfo.Size
+ case "Section":
+ return "Section", p.DebInfo.Section
+ case "URL":
+ return "URL", p.DebInfo.URL
+ //case "Size":
+ // return "Size", p.DebInfo.Size
+ case "BuildDate":
+ if p.BuildDate == nil {
+ return "Build-Date", ""
+ }
+ return "Build-Date", cobol.Time(p.BuildDate)
+ case "DebCtime":
+ return "Deb-File-Date", cobol.Time(p.Ctime)
+ case "SHA1":
+ return "SHA1", "" // deprecated
+ // return "SHA1", p.DebInfo.SHA1
+ case "MD5SUM":
+ return "MD5Sum", p.DebInfo.MD5SUM
+ case "SHA256":
+ return "SHA256", p.DebInfo.SHA256
+ case "SHA512":
+ return "SHA512", "" // totally rediculously overkill
+ case "Description":
+ var out string
+ lines := strings.Split(p.DebInfo.Description, "\n")
+ if len(lines) == 0 {
+ return "Description", out
+ }
+ out = "Description: " + strings.TrimSpace(lines[0])
+ if len(lines) == 1 {
+ return "Description", out
+ }
+ for _, line := range lines[1:] {
+ out += " " + strings.TrimSpace(line)
+ }
+ return "Description", out
+ default:
+ dieMaking(varname)
+ }
+ return "", ""
+}
+
+func dieMaking(varname string) {
+ log.Info("DebInfo sent a field we didn't have. fix the code above", varname)
+ log.Printf("UNHANDLED ABOVE DEBINFO VAR: varname:%s\n", varname)
+ // This forces me(it could be you!) to fix this parser
+ panic("fix mirrors makeDebianControlFile()")
+}
+*/