diff options
| author | Jeff Carr <[email protected]> | 2025-10-08 01:23:12 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-10-08 01:23:12 -0500 |
| commit | 1f321bc8c3b7bb19f443d73334c6cdcc45a9c75a (patch) | |
| tree | 02e3b3d4209dc735d85ed04040a8af1cbf135aac | |
| parent | febcf44d5386f8fc20ab752f0416955f35375335 (diff) | |
usability cleanups
| -rw-r--r-- | Makefile | 4 | ||||
| -rw-r--r-- | argv.go | 11 | ||||
| -rw-r--r-- | doBuild.debian.go (renamed from doDebian.go) | 63 | ||||
| -rw-r--r-- | doGit.go | 20 | ||||
| -rw-r--r-- | structs.go | 1 | ||||
| -rw-r--r-- | tablePackaging.go | 39 |
6 files changed, 96 insertions, 42 deletions
@@ -81,6 +81,10 @@ deb: wit build deb --verbose forge normal +deb-forcedirty: + wit build deb --verbose --force + forge normal + deb-all: wit build deb --verbose --all forge normal @@ -81,11 +81,12 @@ type DefaultCmd struct { } type GitCmd struct { - Log *EmptyCmd `arg:"subcommand:log" help:"git log"` - Who *EmptyCmd `arg:"subcommand:who" help:"git who"` - Tag *EmptyCmd `arg:"subcommand:tag" help:"show tags"` - Pull *EmptyCmd `arg:"subcommand:pull" help:"pull the wit standard paths"` - Push *EmptyCmd `arg:"subcommand:push" help:"push the wit standard paths"` + Log *EmptyCmd `arg:"subcommand:log" help:"git log"` + Who *EmptyCmd `arg:"subcommand:who" help:"git who"` + Tag *EmptyCmd `arg:"subcommand:tag" help:"show tags"` + Pull *EmptyCmd `arg:"subcommand:pull" help:"pull the wit standard paths"` + Push *EmptyCmd `arg:"subcommand:push" help:"push the wit standard paths"` + DeleteUntracked bool `arg:"--delete-untracked" help:"delete the untracked files"` } type EmptyCmd struct { diff --git a/doDebian.go b/doBuild.debian.go index 00a62bb..e252074 100644 --- a/doDebian.go +++ b/doBuild.debian.go @@ -7,11 +7,15 @@ import ( "os" "path/filepath" + "go.wit.com/lib/debian" "go.wit.com/lib/fhelp" + "go.wit.com/lib/gui/shell" "go.wit.com/lib/protobuf/gitpb" "go.wit.com/log" ) +var totalBuilt int + func doBuildDeb() error { // clean out old deb files globPattern := filepath.Join(me.homedir, "incoming", "*.deb") @@ -39,12 +43,13 @@ func doBuildDeb() error { continue } - if shouldBuild(check) == "yes" { - found.Append(check) - } + found.Append(check) } printPackagingTable(found) + found.ActualSort() + printPackagingTable(found) + // me.forge.PrintTable(found) me.forge.ConfigRill(16, 16) stats := me.forge.RunOnRepos(found, buildDeb) @@ -54,6 +59,15 @@ func doBuildDeb() error { return stat.Err } } + if totalBuilt == 0 { + // nothing built, no need to talk to mirrors + return nil + } + + if _, err := shell.RunVerbose([]string{"ls", "-l", "/home/jcarr/incoming"}); err != nil { + me.sh.BadExit("aptly failed", nil) + } + if _, err := fhelp.RunRealtimeError([]string{"do-aptly"}); err != nil { me.sh.BadExit("aptly failed", nil) } @@ -71,44 +85,61 @@ func isDebianRelease() bool { return argv.Build.Debian.Release } -var totalBuilt int +func shouldBuild(repo *gitpb.Repo) string { + if repo.IsDirty() && !argv.Force { + return "no" + } + ver := repo.GetCurrentVersion() + debname := getDebFilename(repo) + if !debian.DebFilenameMatchesVersion(debname, ver) { + return "yes" + } + if argv.All { + return "yes" + } + return "" +} -func buildDeb(check *gitpb.Repo) error { +func buildDeb(repo *gitpb.Repo) error { var cmd []string - outdir := getOutdir(check) + outdir := getOutdir(repo) os.MkdirAll(outdir, 0755) if isDebianRelease() { - cmd = []string{"go-deb", "--release", "--namespace", check.Namespace, "--dir", outdir} + cmd = []string{"go-deb", "--release", "--namespace", repo.Namespace, "--dir", outdir} } else { - cmd = []string{"go-deb", "--namespace", check.Namespace, "--dir", outdir} + cmd = []string{"go-deb", "--namespace", repo.Namespace, "--dir", outdir} } - if me.forge.Config.IsPrivate(check.GetNamespace()) { - cmd = []string{"go-deb", "--namespace", check.Namespace, "--dir", outdir} + if me.forge.Config.IsPrivate(repo.GetNamespace()) { + cmd = []string{"go-deb", "--namespace", repo.Namespace, "--dir", outdir} // return nil } + if shouldBuild(repo) != "yes" { + return nil + } + if argv.Verbose { // log.Info("build cmd:", cmd) cmd = append(cmd, "--verbose") } if argv.DryRun { - log.Info("RUN:", check.FullPath, cmd) + log.Info("RUN:", repo.FullPath, cmd) return nil } - log.Info("Building .deb", cmd) + log.Info("Building .deb", me.forge.GetPackageVersion(repo), cmd) var err error - if _, err = check.RunVerboseOnError(cmd); err != nil { - totalBuilt += 1 - log.Info(check.FullPath, cmd) + if _, err = repo.RunVerboseOnError(cmd); err != nil { + log.Info(repo.FullPath, cmd) return err } - log.Info("build worked", cmd, check.FullPath) + totalBuilt += 1 + log.Info("build worked", cmd, repo.FullPath) return nil } @@ -63,6 +63,26 @@ func doGit() error { me.sh.GoodExit("") } + if argv.Git.DeleteUntracked { + initForge() + for repo := range me.forge.Repos.IterAll() { + if !strings.HasPrefix(repo.Namespace, "go.wit.com") { + continue + } + files, _ := repo.GitDeleteOthers() + log.Info(len(files), repo.Namespace) + log.Info(strings.Join(files, "\n")) + if argv.Force { + if len(files) > 0 { + cmd := []string{"rm"} + cmd = append(cmd, files...) + _, err := fhelp.RunRealtimeError(cmd) + return err + } + } + } + } + return nil } @@ -26,6 +26,7 @@ type mainType struct { func initForge() { if me.forge == nil { me.forge = forgepb.Init() + me.forge.ScanRepoDir() me.forge.Config.DumpENV() } initMachine() diff --git a/tablePackaging.go b/tablePackaging.go index 497a9d9..0da43b1 100644 --- a/tablePackaging.go +++ b/tablePackaging.go @@ -38,39 +38,29 @@ func getDebFilename(repo *gitpb.Repo) string { return "" } -func shouldBuild(repo *gitpb.Repo) string { - if repo.IsDirty() { - return "no" - } - ver := repo.GetCurrentVersion() - debname := getDebFilename(repo) - if !debian.DebFilenameMatchesVersion(debname, ver) { - return "yes" - } - if argv.All { - return "yes" - } - return "" +func printPackagingTable(pb *gitpb.Repos) { + tablePB := makePackagingTable(pb) + tablePB.PrintTable() + log.Printf("wit.packagingTable() %d repos\n", pb.Len()) } -func printPackagingTable(pb *gitpb.Repos) { +func makePackagingTable(pb *gitpb.Repos) *gitpb.ReposTable { tablePB := pb.NewTable("deb details") tablePB.NewUuid() - var col *gitpb.RepoFunc - col = tablePB.AddNamespace() - col.Width = 32 + col = tablePB.AddFullPath() + col.Width = 56 col = tablePB.AddStringFunc("RepoType", func(r *gitpb.Repo) string { return me.forge.GetRepoType(r) }) col.Width = 8 - col = tablePB.AddStringFunc("Build Version", func(r *gitpb.Repo) string { + col = tablePB.AddStringFunc("new .deb Version", func(r *gitpb.Repo) string { return me.forge.GetPackageVersion(r) }) - col.Width = 12 + col.Width = 16 /* col = tablePB.AddStringFunc("is old", func(r *gitpb.Repo) string { @@ -111,6 +101,14 @@ func printPackagingTable(pb *gitpb.Repos) { }) col.Width = 4 + col = tablePB.AddStringFunc("dirty", func(r *gitpb.Repo) string { + if r.IsDirty() { + return "yes" + } + return "" + }) + col.Width = 5 + col = tablePB.AddStringFunc("build", func(r *gitpb.Repo) string { return shouldBuild(r) }) @@ -128,6 +126,5 @@ func printPackagingTable(pb *gitpb.Repos) { }) col.Width = -1 - tablePB.PrintTable() - log.Printf("wit.packagingTable() %d repos\n", pb.Len()) + return tablePB } |
