// Copyright 2017-2025 WIT.COM Inc. All rights reserved. // Use of this source code is governed by the GPL 3.0 package main import ( "os" "path/filepath" "go.wit.com/lib/gui/shell" "go.wit.com/lib/protobuf/gitpb" "go.wit.com/log" ) func doDebian() { // clean out old deb files globPattern := filepath.Join(me.homedir, "incoming", "*.deb") files, err := filepath.Glob(globPattern) if err != nil { log.Info("Error during globbing:", err) badExit(err) } if len(files) > 0 { cmd := []string{"rm"} cmd = append(cmd, files...) exitOnErrorRealtime(cmd) } initForge() doInstallScan() found := gitpb.NewRepos() for check := range me.forge.Repos.IterAll() { if me.forge.Config.IsReadOnly(check.GetNamespace()) { continue } if !check.IsBinary() { continue } if check.IsGoPlugin() { continue } found.Append(check) } me.forge.PrintForgedTable(found) if !argv.DryRun { me.forge.ConfigRill(16, 16) stats := me.forge.RunOnRepos(found, doInstallRepo) for s, stat := range stats { if stat.Err == nil { continue } dur := stat.End.Sub(stat.Start) log.Info("CRAP. INSTALL FAILED", shell.FormatDuration(dur), s, stat.Err) badExit(stat.Err) } } me.forge.ConfigRill(16, 16) log.Info("STARTING .deb BUILDS repo len =", found.Len()) stats := me.forge.RunOnRepos(found, buildDeb) for s, stat := range stats { if stat.Err != nil { log.Info("ERROR WITH buildDeb", s, stat.Err) badExit(stat.Err) } } if argv.DryRun { return } exitOnErrorRealtime([]string{"do-aptly"}) } func buildDeb(check *gitpb.Repo) error { var cmd []string outdir := getOutdir(check) os.MkdirAll(outdir, 0755) if argv.Build.Debian.Release { cmd = []string{"go-deb", "--release", "--dir", outdir} } else { cmd = []string{"go-deb", "--dir", outdir} } if me.forge.Config.IsPrivate(check.GetNamespace()) { cmd = []string{"go-deb", "--dir", outdir} return nil } if argv.Force { // build everything no matter what } else { if check.GetState() != "need to build" { // log.Info("skipping build for", check.GetGoPath(), state[check]) return nil } } if argv.Verbose || argv.Force { // log.Info("build cmd:", cmd) cmd = append(cmd, "--verbose") } if argv.DryRun { return nil } log.Info("Building .deb", cmd) var err error if _, err = check.RunVerboseOnError(cmd); err != nil { log.Info(check.FullPath, cmd) return err } log.Info("build worked", cmd, check.FullPath) return nil } func getOutdir(repo *gitpb.Repo) string { if me.forge.Config.IsPrivate(repo.GetNamespace()) { return "/home/jcarr/incoming-private" } if argv.Force { return "/home/jcarr/incoming" } if repo.GetLastTag() != repo.GetMasterVersion() { return "/home/jcarr/incoming-devel" } if repo.GetCurrentBranchVersion() != repo.GetMasterVersion() { return "/home/jcarr/incoming-devel" } if repo.CheckDirty() { return "/home/jcarr/incoming-devel" } return "/home/jcarr/incoming" }