diff options
| author | Jeff Carr <[email protected]> | 2025-10-11 12:15:46 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-10-11 15:17:21 -0500 |
| commit | f321eee82b012144a7273e602fc6cca2d4ba7947 (patch) | |
| tree | b00b1dbbcff68798bfe40af1af934605f6d7008d /printDebInfo.go | |
| parent | 2e4764ef21676da55eaed61b5252bbbf1882c435 (diff) | |
other stuffv0.0.86
Diffstat (limited to 'printDebInfo.go')
| -rw-r--r-- | printDebInfo.go | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/printDebInfo.go b/printDebInfo.go index f0d9337..e87a3d2 100644 --- a/printDebInfo.go +++ b/printDebInfo.go @@ -2,17 +2,44 @@ package zoopb import ( "fmt" + "strings" "go.wit.com/lib/config" + "go.wit.com/lib/gui/shell" "go.wit.com/log" + "google.golang.org/protobuf/encoding/prototext" "google.golang.org/protobuf/proto" "google.golang.org/protobuf/reflect/protoreflect" ) +func (pb *Package) Print() (string, error) { + shell.RunVerbose([]string{"dpkg", "-I", pb.Filename}) + log.Info("\nNEW PB START") + log.Info(strings.TrimSpace(prototext.Format(pb))) + log.Info("NEW PB END\n") + + log.Info("Attempt to walk pb.DebInfo") + if s, err := printDebInfoStrings(pb, true); err != nil { + return s, err + } + return "todo", nil +} + +func (pb *Package) GetDebianControlFile() (string, error) { + var s string + var err error + if s, err = printDebInfoStrings(pb, true); err != nil { + return s, err + } + return s, err +} + // if the varname isn't in the proto msg, then it'll try to read // the same varname from the base message. This allows the // .proto file to define the print order of the fields -func printDebInfoStrings(pb proto.Message, fallback bool) error { +func printDebInfoStrings(pb proto.Message, fallback bool) (string, error) { + var verbose bool + var controlfile string // 1. Get the reflection interface for the top-level message. msg := pb.ProtoReflect() descriptor := msg.Descriptor() @@ -28,7 +55,7 @@ func printDebInfoStrings(pb proto.Message, fallback bool) error { } if debInfoFieldDesc == nil { - return fmt.Errorf("field 'debInfo' or 'deb_info' not found in message %s", descriptor.FullName()) + return controlfile, fmt.Errorf("field 'debInfo' or 'deb_info' not found in message %s", descriptor.FullName()) } // 3. Get the actual nested message object from the parent. @@ -38,7 +65,7 @@ func printDebInfoStrings(pb proto.Message, fallback bool) error { // 4. Check if the nested message is valid and has been set. if !debInfoMsg.IsValid() { fmt.Printf("--- Field '%s' in [%s] is not set. --- \n", debInfoFieldDesc.Name(), descriptor.FullName()) - return nil // Not an error, just nothing to print. + return controlfile, nil // Not an error, just nothing to print. } // 5. Now, iterate over the fields of the nested debInfo message. @@ -83,6 +110,7 @@ func printDebInfoStrings(pb proto.Message, fallback bool) error { // Print the result. fmt.Printf("%s: \"%s\"\n", string(fieldName), value) + controlfile += fmt.Sprintf("%s: %s\n", string(fieldName), value) foundStrings = true } } @@ -91,7 +119,7 @@ func printDebInfoStrings(pb proto.Message, fallback bool) error { fmt.Println(" (No string fields found)") } - return nil + return controlfile, nil } /* |
