package main import ( "embed" "os" "path/filepath" "time" "go.wit.com/lib/debian" "go.wit.com/lib/protobuf/argvpb" "go.wit.com/lib/protobuf/gitpb" "go.wit.com/lib/protobuf/zoopb" "go.wit.com/log" ) //go:embed resources/* var resources embed.FS func main() { me = new(mainType) me.argv = argvpb.Autocomplete(&argv) // adds shell auto complete to go-args me.pb = new(zoopb.Package) wd, err := os.Getwd() if err != nil { me.argv.BadExit("your current directory does not exist err=", err) } if argv.Arch == "" { // looking forward to the day when this default is "riscv64" argv.Arch = "amd64" } me.repo, err = gitpb.NewRepo(wd) if err != nil { me.argv.BadExit("is this really a .git directory? err=", err) } data, err := os.ReadFile("control") log.Info("INITIAL PARSE:") if err == nil { debian.ParseDpkgOutputIntoPB(me.pb, string(data)) log.Info(string(data)) } else { // make up a new control file _, dirname := filepath.Split(me.repo.Namespace) fake := "Package: " + dirname + "\n" fake += "Maintainer: " + os.Getenv("GIT_AUTHOR_NAME") + "\n" fake += "URL: " + me.repo.URL + "\n" fake += "Homepage: " + me.repo.URL + "\n" // deprecate? fake += "Namespace: " + me.repo.Namespace + "\n" fake += "Build-Depends: golang\n" fake += "Description: built with go.wit.com/apps/go-deb\n" debian.ParseDpkgOutputIntoPB(me.pb, fake) log.Info(fake) } if argv.Arch == "" { me.pb.Architecture = "amd64" } else { me.pb.Architecture = argv.Arch } me.pb.Version = me.repo.DebianCurrentVersion(argv.BuildVersion) me.pb.DebInfo.InstalledSize = "2222" // just to make the control file work me.pb.DebInfo.URL = me.repo.URL me.pb.DebInfo.Homepage = me.repo.URL // deprecate this usage (?) log.Info("INITIAL PARSE RESULT:") controlfile := debian.MakeControlFile(me.pb) log.Info(controlfile) log.Info("INITIAL PARSE END") // me.argv.GoodExit("rewriting this app") // build() if argv.Show != nil { log.Info("todo: show", me.repo.Namespace) okExit("") } if argv.Namespace != "" { me.repo.Namespace = argv.Namespace } log.Info("Namespace:", me.repo.GetNamespace(), "Fullpath:", me.repo.GetFullPath()) // figure out where we are working from // os.Chdir to that directory var debpath string if me.repo == nil { os.Setenv("GO_DEB_CUSTOM", "true") debpath, _ = os.Getwd() } else { debpath = me.repo.GetFullPath() } _, basename := filepath.Split(debpath) me.repo.Namespace = basename os.Chdir(debpath) /* // look for a 'config' file in the repo if readControlFile(me.repo) == nil { log.Warn("scan worked") } else { log.Warn("scan failed") } // computeControlValues(me.repo) */ if me.argv.Gui() { // only load teh toolkit if you get this far me.myGui.Start() // loads the GUI toolkit doGui() debug() } log.Info("go-deb: attempting to build package") if ok, err := buildPackage(me.repo); ok { me.argv.GoodExit("build worked") } else { me.argv.BadExit("build failed", err) } os.Exit(0) } func debug() { time.Sleep(2 * time.Second) for { log.Info("idle loop() todo: could check for things here") time.Sleep(90 * time.Second) } }