diff options
| author | Jeff Carr <[email protected]> | 2025-10-09 06:23:27 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-10-09 06:44:13 -0500 |
| commit | ba18b532de1b19d634b7a275f14c9d846bcc0121 (patch) | |
| tree | 9991ca26e67e92601973aabc781b07a80fe0c788 | |
| parent | 4b2374728c07acc3eb809a8ed3cc03150f6b8027 (diff) | |
cleanup the .proto
| -rw-r--r-- | package.proto | 59 | ||||
| -rw-r--r-- | tableDefault.go | 17 | ||||
| -rw-r--r-- | tablePackages.go | 48 | ||||
| -rw-r--r-- | wit.go | 34 |
4 files changed, 100 insertions, 58 deletions
diff --git a/package.proto b/package.proto index 9ba9055..7470c8d 100644 --- a/package.proto +++ b/package.proto @@ -8,37 +8,34 @@ import "google/protobuf/timestamp.proto"; // Import the well-known type for Time // global settings for autogenpb `autogenpb:mutex` message Package { - string name = 1; // `autogenpb:unique` `autogenpb:sort` - google.protobuf.Timestamp laststamp = 2; // the last time this package was seen (used to timeout entries) - google.protobuf.Timestamp ctime = 3; // the last time this package was seen (used to timeout entries) - string Namespace = 4; // path to the sources (go.wit.com/apps/zookeeper) - bool installed = 5; // if installed on your machine, this should be set to true - string pkgName = 6; // the apt filename pool/main/f/foo/foo_2.2.2_riscv64.deb - string Version = 7; // version: 0.0.3 - string Architecture = 8; // - string Source = 9; // - string Package = 10; // - string Size = 11; // - string Depends = 12; // - string Maintainer = 13; // - string Filename = 14; // - string Description = 15; // - string Packager = 16; // - string Conflicts = 17; // - string BuildDepends = 18; // - string PackageBuildDate = 19; // - string GitTagDate = 20; // - string URL = 21; // - string SHA1 = 22; // - string MD5SUM = 23; // - string SHA256 = 24; // - string SHA512 = 25; // - map<string, string> core = 26; // catch all for whatever is left over + string Package = 1; // `autogenpb:unique` `autogenpb:sort` + string Filename = 2; // `autogenpb:unique` `autogenpb:sort` + string Namespace = 3; // path to the sources (go.wit.com/apps/zookeeper) + string Version = 4; // version: 0.0.3 + string Architecture = 5; // + string Depends = 6; // + string Maintainer = 7; // + string Description = 8; // + string Packager = 9; // + string Source = 10; // + string Size = 11; // + string Conflicts = 12; // + string BuildDepends = 13; // + string URL = 14; // + string SHA1 = 15; // + string MD5SUM = 16; // + string SHA256 = 17; // + string SHA512 = 18; // + bool installed = 19; // if installed on your machine, this should be set to true + google.protobuf.Timestamp BuildDate = 20; // + google.protobuf.Timestamp GitDate = 21; // + google.protobuf.Timestamp ctime = 22; // create time on the mirrors + map<string, string> core = 23; // catch all for whatever is left over } -message Packages { // `autogenpb:marshal` `autogenpb:gui` `autogenpb:http` - string uuid = 1; // `autogenpb:uuid:2f26cc03-ea30-4481-a333-ad0acc86e1d3` - string version = 2; // `autogenpb:version:v0.0.1` - repeated Package packages = 3; - string filename = 4; // `autogenpb:save` -- this enables autogenerated pb.Load() and pb.Save() +message Packages { // `autogenpb:marshal` `autogenpb:gui` `autogenpb:http` + string uuid = 1; // `autogenpb:uuid:2f26cc03-ea30-4481-a333-ad0acc86e1d3` + string version = 2; // `autogenpb:version:v0.0.1` + repeated Package packages = 3; + string filename = 4; // `autogenpb:save` -- this enables autogenerated pb.Load() and pb.Save() } diff --git a/tableDefault.go b/tableDefault.go index 4d39176..bc3ef86 100644 --- a/tableDefault.go +++ b/tableDefault.go @@ -51,7 +51,7 @@ func (m *Machine) PrintTable(pb *Packages) { tablePB.PrintTable() var i int for p := range pb.IterAll() { - if m.IsInstalled(p.Name) { + if m.IsInstalled(p.Package) { i += 1 } } @@ -62,7 +62,7 @@ func (m *Machine) PrintTable(pb *Packages) { func (m *Machine) PrintInstalledTable() { installed := NewPackages() for p := range m.Wit.IterAll() { - if m.IsInstalled(p.Name) { + if m.IsInstalled(p.Package) { installed.Append(p) } } @@ -78,7 +78,7 @@ func (m *Machine) makeSmartTable(pb *Packages) *PackagesTable { var col *PackageFunc col = t.AddStringFunc(" I", func(p *Package) string { - if m.IsInstalled(p.Name) { + if m.IsInstalled(p.Package) { return " X" } return "" @@ -101,7 +101,7 @@ func (m *Machine) makeSmartTable(pb *Packages) *PackagesTable { }) col.Width = 3 - col = t.AddName() + col = t.AddPackage() col.Width = 16 col = t.AddVersion() @@ -110,10 +110,7 @@ func (m *Machine) makeSmartTable(pb *Packages) *PackagesTable { col = t.AddMD5SUM() col.Width = 8 - col = t.AddPackageBuildDate() - col.Width = 20 - - col = t.AddPkgName() + col = t.AddFilename() col.Width = -1 col.Header.Name = "apt package path" @@ -122,7 +119,7 @@ func (m *Machine) makeSmartTable(pb *Packages) *PackagesTable { // true if the package 'p' is newer than the installed package func (m *Machine) WillUpgrade(p *Package) bool { - check := m.FindInstalledByName(p.Name) + check := m.FindInstalledByName(p.Package) if check == nil { // not installed. can not upgrade return false @@ -144,7 +141,7 @@ func (m *Machine) WillUpgrade(p *Package) bool { // this means somehow this machine has a newer version than the mirrors have // true if the package 'p' is newer than the installed package func (m *Machine) MirrorsOutOfDate(p *Package) bool { - check := m.FindInstalledByName(p.Name) + check := m.FindInstalledByName(p.Package) if check == nil { // not installed return false diff --git a/tablePackages.go b/tablePackages.go new file mode 100644 index 0000000..0a95ef6 --- /dev/null +++ b/tablePackages.go @@ -0,0 +1,48 @@ +// Copyright 2025 WIT.COM Inc Licensed GPL 3.0 + +package zoopb + +import ( + "go.wit.com/log" +) + +// this is the default table layout for repos in forge + +func (pb *Packages) PrintTable() string { + tablePB := pb.MakeDefaultTable() + tablePB.PrintTable() + return log.Sprintf("pb.DefaultTable: %d packages", pb.Len()) +} + +func (pb *Packages) MakeDefaultTable() *PackagesTable { + t := pb.NewTable("apt packages") + t.NewUuid() + + var col *PackageFunc + + col = t.AddStringFunc(" I", func(p *Package) string { + if p.Installed { + return " X" + } + return "" + }) + col.Width = 3 + + col = t.AddMD5SUM() + col.Width = 6 + + col = t.AddSHA256() + col.Width = 6 + + col = t.AddPackage() + col.Width = 30 + + col = t.AddVersion() + col.Width = 20 + + col = t.AddFilename() + col.Width = -1 + col.Header.Name = "apt package path" + + return t +} @@ -11,9 +11,9 @@ func (m *Machine) IsInstalled(name string) bool { if m.Packages == nil { panic("m.Packages nil in zoopb") } - for p := range m.Packages.IterByName() { - if name == p.Name { - // log.Info("package installed:", p.Name, p.Version, p.PkgName) + for p := range m.Packages.IterByPackage() { + if name == p.Package { + // log.Info("package installed:", p.Package, p.Version, p.PkgName) return true } } @@ -30,11 +30,11 @@ func (m *Machine) FindInstalledByName(name string) *Package { panic("m.Packages == nil") } // log.Info("FindInstalledByName len=", m.Packages.Len()) - return m.Packages.FindByName(name) + return m.Packages.FindByPackage(name) /* for p := range m.Packages.IterByName() { - if name == p.Name { - // log.Info("package installed:", p.Name, p.Version, p.PkgName) + if name == p.Package { + // log.Info("package installed:", p.Package, p.Version, p.PkgName) return p } } @@ -48,8 +48,8 @@ func (m *Machine) FindInstalledByName(name string) *Package { // if version == "", return the first name found func (m *Machine) FindVersion(name string) string { // first check all installed versions - for p := range m.Packages.IterByName() { - if name == p.Name { + for p := range m.Packages.IterByPackage() { + if name == p.Package { return p.Version } } @@ -59,13 +59,13 @@ func (m *Machine) FindVersion(name string) string { func (m *Machine) FindInstalledPackage(check *Package) *Package { /* for p := range m.Packages.IterByName() { - if (check.Name == p.Name) && (check.Version == p.Version) { + if (check.Package == p.Package) && (check.Version == p.Version) { return p } } */ - for p := range m.Wit.IterByName() { - if (check.Name == p.Name) && (check.Version == p.Version) { + for p := range m.Wit.IterByPackage() { + if (check.Package == p.Package) && (check.Version == p.Version) { return p } } @@ -76,8 +76,8 @@ func (m *Machine) FindInstalledPackage(check *Package) *Package { // if version == "", return the first name found func (m *Machine) FindByVersion(name string, version string) *Package { // first check all installed versions - for p := range m.Packages.IterByName() { - if name == p.Name { + for p := range m.Packages.IterByPackage() { + if name == p.Package { if version == "" { return p } else { @@ -89,8 +89,8 @@ func (m *Machine) FindByVersion(name string, version string) *Package { } // check all wit packages - for p := range m.Wit.IterByName() { - if name == p.Name { + for p := range m.Wit.IterByPackage() { + if name == p.Package { if version == "" { return p } @@ -106,8 +106,8 @@ func (m *Machine) FindByVersion(name string, version string) *Package { } } // give anything with the same name - for p := range m.Wit.IterByName() { - if name == p.Name { + for p := range m.Wit.IterByPackage() { + if name == p.Package { return p } } |
