package main import ( "embed" "errors" "os" "path/filepath" "go.wit.com/lib/config" "go.wit.com/lib/gui/prep" "go.wit.com/lib/gui/shell" "go.wit.com/lib/protobuf/zoopb" "go.wit.com/log" ) // sent via -ldflags var VERSION string var BUILDTIME string // used for shell auto completion var ARGNAME string = "mirrors" // todo: get this from $0 //go:embed resources/* var resources embed.FS func main() { me = new(mainType) me.sh = prep.Bash3(&argv) // add support for bash autocomplete with go-arg // read in protobuf file me.pb = zoopb.NewPackages() me.pb.Filename = config.GetPanic("mirrors.pb") if err := me.pb.Load(); err != nil { me.pb.BaseDir = config.GetPanic("BaseDir") me.pb.Save() me.sh.GoodExit("created new pb file: " + me.pb.Filename + ". rerun mirrors.") } // force check the PB variable // todo: redo all this now that there is a generalized lib/config/ if me.pb.BaseDir != config.GetPanic("BaseDir") { me.pb.BaseDir = config.GetPanic("BaseDir") me.pb.Save() me.sh.BadExit("pb.BaseDir is bank", nil) } if err := os.Chdir(me.pb.BaseDir); err != nil { me.sh.BadExit("no '"+me.pb.BaseDir+"' directory", err) } if !shell.IsDir("pool/") { me.sh.BadExit("no "+filepath.Join(me.pb.BaseDir, "pool")+" directory", errors.New("mount -a ? missing wit/pool/")) } if me.sh.Cmd == "" { // STANDARD START // walk for new .deb files s, err := doWalk() if err != nil { me.sh.BadExit(s, err) } // move files from inccoming into pooo/ s, err = doIncoming(me.pb) if err != nil { me.sh.BadExit(s, err) } me.sh.GoodExit(s) // STANDARD START END } //// start standard argv subcommand processing here //// var s string var err error // handling of argv subcommands if argv.Incoming != nil { s, err = doIncoming(me.pb) } if argv.Walk != nil { s, err = doWalk() } if argv.Newest != nil { all := doGetNewest("amd64") s = "newest .deb files table: " + all.PrintTable() } if argv.List != nil { s, err = doList() } if argv.Verify != nil { s, err = doVerify() } if argv.SignRelease != nil { s, err = doRelease() } if argv.Everything != nil { // move files to the right place s, err = doIncoming(me.pb) if err != nil { me.sh.BadExit(s, err) } // add the filenames to the .pb s, err = doWalk() if err != nil { me.sh.BadExit(s, err) } // verify all the packages s, err = doVerify() if err != nil { me.sh.BadExit(s, err) } // print a table of the newest packages all := doGetNewest("amd64") s = "newest .deb files table: " + all.PrintTable() log.Info("newest files are:", s) // make and GPG sign the Release files s, err = doRelease() } if err != nil { me.sh.BadExit(s, err) } me.sh.GoodExit(s) }