From d687de6c043b6f3fd67827fd9f12e8af3ece0d68 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sat, 22 Feb 2025 07:17:13 -0600 Subject: [PATCH] fix build with zoopb out of forge --- argv.go | 1 + doAptUpgrade.go | 10 +++++----- doDebian.go | 14 ++++++++++++++ doInstall.go | 8 ++++---- doListRepos.go | 8 ++++---- main.go | 21 ++++++++++++++------- structs.go | 8 +++++--- 7 files changed, 47 insertions(+), 23 deletions(-) diff --git a/argv.go b/argv.go index d3d1449..c25659e 100644 --- a/argv.go +++ b/argv.go @@ -19,6 +19,7 @@ var argv args type args struct { TestBuild *EmptyCmd `arg:"subcommand:build" help:"try appropriate 'go build'"` DebBuild *EmptyCmd `arg:"subcommand:debian" help:"build missing .deb packages"` + MacBuild *EmptyCmd `arg:"subcommand:macos" help:"build macos packages"` MakeInstall *EmptyCmd `arg:"subcommand:install" help:"run make install in each repo"` ListPkgs *EmptyCmd `arg:"subcommand:list" help:"list all the packages on mirrors.wit.com"` Clone *EmptyCmd `arg:"subcommand:repomap-clone" help:"go-clone from a gowebd repomap"` diff --git a/doAptUpgrade.go b/doAptUpgrade.go index f737e16..63ef6b1 100644 --- a/doAptUpgrade.go +++ b/doAptUpgrade.go @@ -22,11 +22,11 @@ func doAptUpgrade() { } fmt.Println("Installed Packages:") - loop := me.forge.Machine.Wit.SortByName() + loop := me.machine.Wit.SortByName() for loop.Scan() { p := loop.Next() // log.Info("apt install", name) - if me.forge.Machine.IsInstalled(p.Name) { + if me.machine.IsInstalled(p.Name) { cmd := []string{"apt", "install", p.Name} if argv.DryRun { log.Info("--dry-run", cmd) @@ -43,7 +43,7 @@ func doAptList() { log.DaemonMode(true) defer log.DaemonMode(false) fmt.Println("Installed Packages:") - loop := me.forge.Machine.Wit.SortByName() + loop := me.machine.Wit.SortByName() for loop.Scan() { p := loop.Next() var end string @@ -51,12 +51,12 @@ func doAptList() { if me.forge.Config.IsPrivate(p.Name) { end += "(private) " } - if actualp := me.forge.Machine.FindVersion(p.Name, p.Version); actualp != nil { + if actualp := me.machine.FindVersion(p.Name, p.Version); actualp != nil { // end += "(version match) " } else { end += "(version mismatch) " + actualp.Version + " " + version + " " } - if actualp := me.forge.Machine.FindInstalledByName(p.Name); actualp != nil { + if actualp := me.machine.FindInstalledByName(p.Name); actualp != nil { if p.Version != actualp.Version { end += "(installed " + actualp.Version + " vs " + p.Version + ") " } else { diff --git a/doDebian.go b/doDebian.go index 32aa538..219a80b 100644 --- a/doDebian.go +++ b/doDebian.go @@ -67,6 +67,20 @@ func buildDeb() { } } + /* + build-darwin: + GOOS=darwin GOARCH=amd64 GO111MODULE=off go build -v -o go-clone-darwin.x86 \ + -ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}" + + build-darwin-arm64: + GOOS=darwin GOARCH=arm64 GO111MODULE=off go build -v -o go-clone-darwin.arm \ + -ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}" + */ + if argv.MacBuild != nil { + log.Info("todo: add mac builds") + continue + } + /* _, err := os.Stat(filepath.Join(outdir, debnames[check])) if err == nil { diff --git a/doInstall.go b/doInstall.go index bfa77e4..51b99c4 100644 --- a/doInstall.go +++ b/doInstall.go @@ -41,10 +41,10 @@ func doInstall() error { ver := trimNonNumericFromStart(manufactured) name := me.forge.Config.DebName(check.GetGoPath()) var realver string - if installedPackage := me.forge.Machine.FindInstalledByName(name); installedPackage != nil { + if installedPackage := me.machine.FindInstalledByName(name); installedPackage != nil { realver = installedPackage.Version } - if actualp := me.forge.Machine.FindVersion(name, ver); actualp != nil { + if actualp := me.machine.FindVersion(name, ver); actualp != nil { end += " (version match) " + actualp.Version + " " + ver + " " state[check] = "on mirrors" } else { @@ -53,8 +53,8 @@ func doInstall() error { } // end += "" + ver + " " } - if me.forge.Machine.IsInstalled(name) { - if actualp := me.forge.Machine.FindInstalledByName(name); actualp != nil { + if me.machine.IsInstalled(name) { + if actualp := me.machine.FindInstalledByName(name); actualp != nil { if ver != actualp.Version { end += "(installed " + actualp.Version + ") " } else { diff --git a/doListRepos.go b/doListRepos.go index e5f34c6..72b562c 100644 --- a/doListRepos.go +++ b/doListRepos.go @@ -40,10 +40,10 @@ func doListRepos() { ver := trimNonNumericFromStart(manufactured) name := me.forge.Config.DebName(check.GetGoPath()) var realver string - if installedPackage := me.forge.Machine.FindInstalledByName(name); installedPackage != nil { + if installedPackage := me.machine.FindInstalledByName(name); installedPackage != nil { realver = installedPackage.Version } - if actualp := me.forge.Machine.FindVersion(name, ver); actualp != nil { + if actualp := me.machine.FindVersion(name, ver); actualp != nil { end += " (version match) " + actualp.Version + " " + ver + " " state[check] = "on mirrors" } else { @@ -52,8 +52,8 @@ func doListRepos() { } // end += "" + ver + " " } - if me.forge.Machine.IsInstalled(name) { - if actualp := me.forge.Machine.FindInstalledByName(name); actualp != nil { + if me.machine.IsInstalled(name) { + if actualp := me.machine.FindInstalledByName(name); actualp != nil { if ver != actualp.Version { end += "(installed " + actualp.Version + ") " } else { diff --git a/main.go b/main.go index 417b227..bd87ba8 100644 --- a/main.go +++ b/main.go @@ -15,6 +15,7 @@ import ( "go.wit.com/lib/gui/shell" "go.wit.com/lib/protobuf/forgepb" "go.wit.com/lib/protobuf/gitpb" + "go.wit.com/lib/protobuf/zoopb" "go.wit.com/log" ) @@ -47,6 +48,12 @@ func main() { // load the ~/.config/forge/ config me.forge = forgepb.Init() + me.machine = new(zoopb.Machine) + if err := me.machine.ConfigLoad(); err != nil { + log.Info("zoopb.ConfigLoad() failed", err) + } + me.machine.InitWit() + me.myGui = gui.New() me.myGui.Default() @@ -71,7 +78,7 @@ func main() { log.DaemonMode(true) defer log.DaemonMode(false) fmt.Println("Installed Packages:") - loop := me.forge.Machine.Wit.SortByName() + loop := me.machine.Wit.SortByName() for loop.Scan() { p := loop.Next() var end string @@ -79,12 +86,12 @@ func main() { if me.forge.Config.IsPrivate(p.Name) { end += "(private) " } - if actualp := me.forge.Machine.FindVersion(p.Name, p.Version); actualp != nil { + if actualp := me.machine.FindVersion(p.Name, p.Version); actualp != nil { // end += "(version match) " } else { end += "(version mismatch) " + actualp.Version + " " + version + " " } - if actualp := me.forge.Machine.FindInstalledByName(p.Name); actualp != nil { + if actualp := me.machine.FindInstalledByName(p.Name); actualp != nil { if p.Version != actualp.Version { end += "(installed " + actualp.Version + " vs " + p.Version + ") " } else { @@ -163,10 +170,10 @@ func main() { ver := trimNonNumericFromStart(manufactured) name := me.forge.Config.DebName(check.GetGoPath()) var realver string - if installedPackage := me.forge.Machine.FindInstalledByName(name); installedPackage != nil { + if installedPackage := me.machine.FindInstalledByName(name); installedPackage != nil { realver = installedPackage.Version } - if actualp := me.forge.Machine.FindVersion(name, ver); actualp != nil { + if actualp := me.machine.FindVersion(name, ver); actualp != nil { end += " (version match) " + actualp.Version + " " + ver + " " state[check] = "on mirrors" } else { @@ -175,8 +182,8 @@ func main() { } // end += "" + ver + " " } - if me.forge.Machine.IsInstalled(name) { - if actualp := me.forge.Machine.FindInstalledByName(name); actualp != nil { + if me.machine.IsInstalled(name) { + if actualp := me.machine.FindInstalledByName(name); actualp != nil { if ver != actualp.Version { end += "(installed " + actualp.Version + ") " } else { diff --git a/structs.go b/structs.go index 9307b0e..e3c170c 100644 --- a/structs.go +++ b/structs.go @@ -7,13 +7,15 @@ import ( "go.wit.com/dev/alexflint/arg" "go.wit.com/gui" "go.wit.com/lib/protobuf/forgepb" + "go.wit.com/lib/protobuf/zoopb" ) var me *autoType // this app's variables type autoType struct { - argpp *arg.Parser // go-arg preprocessor - myGui *gui.Node // the gui handle - forge *forgepb.Forge // your customized repo preferences and settings + argpp *arg.Parser // go-arg preprocessor + myGui *gui.Node // the gui handle + forge *forgepb.Forge // your customized repo preferences and settings + machine *zoopb.Machine // your customized repo preferences and settings }