Compare commits
No commits in common. "master" and "v0.0.29" have entirely different histories.
33
Makefile
33
Makefile
|
@ -8,10 +8,6 @@ go-build: goimports
|
|||
GO111MODULE=off go build \
|
||||
-ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}"
|
||||
|
||||
verbose:
|
||||
GO111MODULE=off go build -v -x \
|
||||
-ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}"
|
||||
|
||||
install: goimports
|
||||
GO111MODULE=off go install \
|
||||
-ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}"
|
||||
|
@ -36,32 +32,3 @@ gpl:
|
|||
|
||||
check-git-clean:
|
||||
@git diff-index --quiet HEAD -- || (echo "Git repository is dirty, please commit your changes first"; exit 1)
|
||||
|
||||
old-debian-release: install
|
||||
wit-test debian --dry-run --verbose --release
|
||||
|
||||
debian-release: install
|
||||
forge dirty
|
||||
rm -f ~/incoming/*.deb
|
||||
rm -f ~/go/lib/go-gui/*
|
||||
forge --install go.wit.com/apps/go-deb
|
||||
go-deb -h # check to make sure go-deb builds
|
||||
wit-test debian --verbose
|
||||
ls -hl ~/incoming/
|
||||
do-aptly
|
||||
rm -f ~/go/bin/forged # causes bash completion annoyances
|
||||
|
||||
debian-release-force: install
|
||||
forge dirty
|
||||
rm -f ~/incoming/*.deb
|
||||
rm -f ~/go/lib/go-gui/*
|
||||
forge --install go.wit.com/apps/go-deb
|
||||
go-deb -h # check to make sure go-deb builds
|
||||
wit-test debian --force --verbose
|
||||
ls -hl ~/incoming/
|
||||
-dpkg-deb -c ~/incoming/go-gui-toolkits*.deb
|
||||
do-aptly
|
||||
rm -f ~/go/bin/forged # causes bash completion annoyances
|
||||
|
||||
debian-release-build-only: install
|
||||
wit-test debian --verbose --release
|
||||
|
|
37
argv.go
37
argv.go
|
@ -9,9 +9,6 @@ package main
|
|||
*/
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.wit.com/lib/debugger"
|
||||
"go.wit.com/lib/gui/logsettings"
|
||||
"go.wit.com/log"
|
||||
|
@ -22,20 +19,19 @@ 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"`
|
||||
Test *EmptyCmd `arg:"subcommand:test" help:"test build everything first"`
|
||||
Clone *EmptyCmd `arg:"subcommand:repomap-clone" help:"go-clone from a gowebd repomap"`
|
||||
Upgrade *EmptyCmd `arg:"subcommand:upgrade" help:"apt upgrade packages installed from mirrors.wit.com"`
|
||||
RepoMap string `arg:"--repomap" help:"location of the repomap"`
|
||||
Release bool `arg:"--release" help:"use go-deb --release"`
|
||||
DryRun bool `arg:"--dry-run" help:"only show what would be packaged"`
|
||||
Verbose bool `arg:"--verbose" help:"be loud about it"`
|
||||
Force bool `arg:"--force" help:"rebuild everything"`
|
||||
Recursive bool `arg:"--recursive" help:"go-clone --recursive"`
|
||||
Test bool `arg:"--test" help:"test build after everything else"`
|
||||
WITCOM bool `arg:"--witcom" help:"add the GPL header"`
|
||||
Max int32 `arg:"--max" help:"stop building after max builds"`
|
||||
Bash bool `arg:"--bash" help:"generate bash completion"`
|
||||
BashAuto []string `arg:"--auto-complete" help:"does the actual autocompletion"`
|
||||
}
|
||||
|
||||
type EmptyCmd struct {
|
||||
|
@ -63,30 +59,3 @@ func init() {
|
|||
func (args) Version() string {
|
||||
return "wit-test " + VERSION + " Built on " + BUILDTIME
|
||||
}
|
||||
|
||||
/*
|
||||
handles shell autocomplete
|
||||
*/
|
||||
|
||||
func (a args) DoAutoComplete(argv []string) {
|
||||
switch argv[0] {
|
||||
case "list":
|
||||
fmt.Println("--all --mine --favorites --private")
|
||||
case "debian":
|
||||
fmt.Println("--dry-run --force --release --verbose macos --max")
|
||||
case "upgrade":
|
||||
fmt.Println("--dry-run")
|
||||
case "build":
|
||||
fmt.Println("--verbose --force")
|
||||
case "install":
|
||||
fmt.Println("--verbose")
|
||||
case "repomap-clone":
|
||||
fmt.Println("--repomap")
|
||||
default:
|
||||
if argv[0] == ARGNAME {
|
||||
// list the subcommands here
|
||||
fmt.Println("--bash list build debian install repomap-clone upgrade")
|
||||
}
|
||||
}
|
||||
os.Exit(0)
|
||||
}
|
||||
|
|
|
@ -0,0 +1,94 @@
|
|||
// Copyright 2017-2025 WIT.COM Inc. All rights reserved.
|
||||
// Use of this source code is governed by the GPL 3.0
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
/*
|
||||
handles shell autocomplete
|
||||
*/
|
||||
|
||||
// used for shell auto completion
|
||||
var ARGNAME string = "wit-test" // todo: get this from $0 ?
|
||||
|
||||
func (args) doBashAuto() {
|
||||
argv.doBashHelp()
|
||||
switch argv.BashAuto[0] {
|
||||
case "list":
|
||||
fmt.Println("--all --mine --favorites --private")
|
||||
case "debian":
|
||||
fmt.Println("--dry-run")
|
||||
case "upgrade":
|
||||
fmt.Println("--dry-run")
|
||||
case "build":
|
||||
fmt.Println("--verbose")
|
||||
case "install":
|
||||
fmt.Println("--verbose")
|
||||
case "repomap-clone":
|
||||
fmt.Println("--repomap")
|
||||
default:
|
||||
if strings.HasSuffix(argv.BashAuto[0], ARGNAME) {
|
||||
// list the subcommands here
|
||||
fmt.Println("--bash list build debian install repomap-clone upgrade")
|
||||
}
|
||||
}
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
// prints help to STDERR // TODO: move everything below this to go-args
|
||||
func (args) doBashHelp() {
|
||||
if argv.BashAuto[1] != "''" {
|
||||
// if this is not blank, then the user has typed something
|
||||
return
|
||||
}
|
||||
if argv.BashAuto[0] != ARGNAME {
|
||||
// if this is not the name of the command, the user already started doing something
|
||||
return
|
||||
}
|
||||
if argv.BashAuto[0] == ARGNAME {
|
||||
// me.argpp.WriteHelp(os.Stderr)
|
||||
// return
|
||||
}
|
||||
fmt.Fprintln(os.Stderr, "")
|
||||
fmt.Fprintln(os.Stderr, "list: show every package on mirrors.wit.com")
|
||||
fmt.Fprintln(os.Stderr, "build: go build every package that identifies as a binary")
|
||||
fmt.Fprintln(os.Stderr, "install: go install every package into ~/go/bin")
|
||||
fmt.Fprintln(os.Stderr, "repomap-clone: go-clone every package from a gowebd repomap")
|
||||
fmt.Fprintln(os.Stderr, "")
|
||||
}
|
||||
|
||||
// complete -F forge --bash forge
|
||||
func (args) doBash() {
|
||||
fmt.Println("# add this in your bashrc:")
|
||||
fmt.Println("")
|
||||
fmt.Println("# todo: add this to go-arg as a 'hidden' go-arg option --bash")
|
||||
fmt.Println("#")
|
||||
fmt.Println("# todo: make this output work/parse with:")
|
||||
fmt.Println("# complete -C " + ARGNAME + " --bash go")
|
||||
fmt.Println("")
|
||||
fmt.Println("_" + ARGNAME + "_complete()")
|
||||
fmt.Println("{")
|
||||
fmt.Println(" # sets local to this func vars")
|
||||
fmt.Println(" local cur prev all")
|
||||
fmt.Println(" cur=${COMP_WORDS[COMP_CWORD]}")
|
||||
fmt.Println(" prev=${COMP_WORDS[COMP_CWORD-1]}")
|
||||
fmt.Println(" all=${COMP_WORDS[@]}")
|
||||
fmt.Println("")
|
||||
fmt.Println(" # this is where we generate the go-arg output")
|
||||
fmt.Println(" GOARGS=$(" + ARGNAME + " --auto-complete $prev \\'$cur\\' $all)")
|
||||
fmt.Println("")
|
||||
fmt.Println(" # this compares the command line input from the user")
|
||||
fmt.Println(" # to whatever strings we output")
|
||||
fmt.Println(" COMPREPLY=( $(compgen -W \"$GOARGS\" -- $cur) ) # THIS WORKS")
|
||||
fmt.Println(" return 0")
|
||||
fmt.Println("}")
|
||||
fmt.Println("complete -F _" + ARGNAME + "_complete " + ARGNAME)
|
||||
fmt.Println("")
|
||||
fmt.Println("# copy and paste the above into your bash shell should work")
|
||||
os.Exit(0)
|
||||
}
|
|
@ -22,16 +22,14 @@ func doAptUpgrade() {
|
|||
}
|
||||
|
||||
fmt.Println("Installed Packages:")
|
||||
loop := me.machine.Wit.SortByName()
|
||||
loop := me.forge.Machine.Wit.SortByName()
|
||||
for loop.Scan() {
|
||||
p := loop.Next()
|
||||
// log.Info("apt install", name)
|
||||
if me.machine.IsInstalled(p.Name) {
|
||||
cmd := []string{"apt", "install", p.Name}
|
||||
if me.forge.Machine.IsInstalled(p.Name) {
|
||||
if argv.DryRun {
|
||||
log.Info("--dry-run", cmd)
|
||||
log.Info("--dry-run", []string{"apt", "install", p.Name})
|
||||
} else {
|
||||
log.Info("Running:", cmd)
|
||||
shell.RunRealtime([]string{"apt", "install", p.Name})
|
||||
}
|
||||
}
|
||||
|
@ -43,7 +41,7 @@ func doAptList() {
|
|||
log.DaemonMode(true)
|
||||
defer log.DaemonMode(false)
|
||||
fmt.Println("Installed Packages:")
|
||||
loop := me.machine.Wit.SortByName()
|
||||
loop := me.forge.Machine.Wit.SortByName()
|
||||
for loop.Scan() {
|
||||
p := loop.Next()
|
||||
var end string
|
||||
|
@ -51,12 +49,12 @@ func doAptList() {
|
|||
if me.forge.Config.IsPrivate(p.Name) {
|
||||
end += "(private) "
|
||||
}
|
||||
if actualp := me.machine.FindByVersion(p.Name, p.Version); actualp != nil {
|
||||
if actualp := me.forge.Machine.FindVersion(p.Name, p.Version); actualp != nil {
|
||||
// end += "(version match) "
|
||||
} else {
|
||||
end += "(version mismatch) " + actualp.Version + " " + version + " "
|
||||
}
|
||||
if actualp := me.machine.FindInstalledByName(p.Name); actualp != nil {
|
||||
if actualp := me.forge.Machine.FindInstalledByName(p.Name); actualp != nil {
|
||||
if p.Version != actualp.Version {
|
||||
end += "(installed " + actualp.Version + " vs " + p.Version + ") "
|
||||
} else {
|
||||
|
|
96
doDebian.go
96
doDebian.go
|
@ -6,96 +6,32 @@ package main
|
|||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"go.wit.com/lib/protobuf/gitpb"
|
||||
"go.wit.com/log"
|
||||
)
|
||||
|
||||
func buildDeb() {
|
||||
if argv.DryRun {
|
||||
return
|
||||
}
|
||||
log.DaemonMode(true)
|
||||
defer log.DaemonMode(false)
|
||||
|
||||
if argv.Test != nil {
|
||||
if err := doInstall(); err != nil {
|
||||
log.Info("doInstall() failed", err)
|
||||
badExit(err)
|
||||
}
|
||||
}
|
||||
|
||||
var counter int
|
||||
if int(argv.Max) == 0 {
|
||||
argv.Max = 50
|
||||
}
|
||||
|
||||
all := me.forge.Repos.SortByFullPath()
|
||||
for all.Scan() {
|
||||
var cmd []string
|
||||
check := all.Next()
|
||||
|
||||
outdir := getOutdir(check)
|
||||
os.MkdirAll(outdir, 0755)
|
||||
|
||||
if me.forge.Config.IsReadOnly(check.GetGoPath()) {
|
||||
continue
|
||||
}
|
||||
|
||||
if !check.IsBinary() {
|
||||
continue
|
||||
}
|
||||
|
||||
if check.IsGoPlugin() {
|
||||
continue
|
||||
}
|
||||
|
||||
if argv.Release {
|
||||
cmd = []string{"go-deb", "--release", "--dir", outdir}
|
||||
} else {
|
||||
cmd = []string{"go-deb", "--dir", outdir}
|
||||
}
|
||||
if me.forge.Config.IsPrivate(check.GetGoPath()) {
|
||||
cmd = []string{"go-deb", "--dir", outdir}
|
||||
continue
|
||||
}
|
||||
|
||||
if argv.Verbose {
|
||||
log.Info("build cmd:", cmd)
|
||||
cmd = append(cmd, "--verbose")
|
||||
}
|
||||
if argv.DryRun {
|
||||
continue
|
||||
}
|
||||
|
||||
if argv.Force {
|
||||
// build everything no matter what
|
||||
} else {
|
||||
if state[check] != "need to build" {
|
||||
// log.Info("skipping build for", check.GetGoPath(), state[check])
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
counter += 1
|
||||
outdir := getOutdir(check)
|
||||
os.MkdirAll(outdir, 0755)
|
||||
|
||||
if counter > int(argv.Max) {
|
||||
log.Info("did --max builds", argv.Max)
|
||||
okExit("")
|
||||
}
|
||||
|
||||
/*
|
||||
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 {
|
||||
if debnames[check] == "" {
|
||||
|
@ -104,12 +40,22 @@ func buildDeb() {
|
|||
// already built
|
||||
continue
|
||||
}
|
||||
*/
|
||||
|
||||
if err := check.RunVerbose(cmd); err != nil {
|
||||
log.Info(check.FullPath, cmd)
|
||||
failed[check] = fmt.Sprint("godeb failed", cmd, "with", err)
|
||||
badExit(err)
|
||||
if argv.Release {
|
||||
cmd = []string{"go-deb", "--release", "--auto", "--forge", check.GetGoPath(), "--dir", outdir}
|
||||
} else {
|
||||
cmd = []string{"go-deb", "--auto", "--no-gui", "--forge", check.GetGoPath(), "--dir", outdir}
|
||||
}
|
||||
if me.forge.Config.IsPrivate(check.GetGoPath()) {
|
||||
cmd = []string{"go-deb", "--auto", "--forge", check.GetGoPath(), "--dir", outdir}
|
||||
}
|
||||
log.Info("build cmd:", cmd)
|
||||
if r := check.RunRealtime(cmd); r.Error != nil {
|
||||
log.Info("go-deb failed error:", r.Error, check.GetGoPath())
|
||||
failed[check] = fmt.Sprint("godeb failed", cmd, "with", r.Exit, r.Error)
|
||||
} else if r.Exit != 0 {
|
||||
log.Info("go-deb failed exit =", r.Exit, check.GetGoPath())
|
||||
failed[check] = fmt.Sprint("godeb failed", cmd, "with", r.Exit, r.Error)
|
||||
} else {
|
||||
log.Info("build worked")
|
||||
}
|
||||
|
|
145
doInstall.go
145
doInstall.go
|
@ -1,145 +0,0 @@
|
|||
// Copyright 2017-2025 WIT.COM Inc. All rights reserved.
|
||||
// Use of this source code is governed by the GPL 3.0
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"go.wit.com/log"
|
||||
)
|
||||
|
||||
func doInstall() error {
|
||||
all := me.forge.Repos.SortByFullPath()
|
||||
for all.Scan() {
|
||||
check := all.Next()
|
||||
|
||||
repotype := check.GetRepoType()
|
||||
if repotype == "binary" || repotype == "plugin" {
|
||||
// we only want to process things that can be compiled with 'go build'
|
||||
} else {
|
||||
// log.Info("skipping repo", check.GetGoPath(), repotype)
|
||||
continue
|
||||
}
|
||||
|
||||
if me.forge.Config.IsReadOnly(check.GetGoPath()) {
|
||||
// ignore read only stuff
|
||||
continue
|
||||
}
|
||||
|
||||
// var cmd []string
|
||||
var start string
|
||||
var end string
|
||||
|
||||
// add te repotype
|
||||
end += check.GetRepoType()
|
||||
|
||||
manufactured := check.GetCurrentVersion()
|
||||
ver := trimNonNumericFromStart(manufactured)
|
||||
name := me.forge.Config.DebName(check.GetGoPath())
|
||||
var realver string
|
||||
if installedPackage := me.machine.FindInstalledByName(name); installedPackage != nil {
|
||||
realver = installedPackage.Version
|
||||
}
|
||||
if actualp := me.machine.FindByVersion(name, ver); actualp != nil {
|
||||
end += " (version match) " + actualp.Version + " " + ver + " "
|
||||
state[check] = "on mirrors"
|
||||
} else {
|
||||
if realver != "" {
|
||||
end += fmt.Sprintf(" (version miss) %s vs %s ", realver, ver)
|
||||
}
|
||||
// end += "" + ver + " "
|
||||
}
|
||||
if me.machine.IsInstalled(name) {
|
||||
if actualp := me.machine.FindInstalledByName(name); actualp != nil {
|
||||
if ver != actualp.Version {
|
||||
end += "(installed " + actualp.Version + ") "
|
||||
} else {
|
||||
end += "(installed ok) "
|
||||
}
|
||||
} else {
|
||||
end += "(installed) "
|
||||
}
|
||||
}
|
||||
|
||||
debname := name + "_" + ver + "_amd64.deb"
|
||||
debnames[check] = debname
|
||||
outdir := getOutdir(check)
|
||||
_, err := os.Stat(filepath.Join(outdir, debname))
|
||||
if err == nil {
|
||||
// log.Info("exists", filepath.Join(outdir, debname))
|
||||
state[check] = "in incoming"
|
||||
} else {
|
||||
// log.Info(debname, "does not exist")
|
||||
}
|
||||
|
||||
if state[check] == "" {
|
||||
state[check] = "need to build"
|
||||
}
|
||||
start = fmt.Sprintf("%-15s %-20s %-50s", state[check], ver, debname)
|
||||
|
||||
if state[check] == "need to build" {
|
||||
end += " (will build) "
|
||||
}
|
||||
|
||||
log.Info(start, end)
|
||||
if name == "" {
|
||||
// err := fmt.Sprintf("name is blank error %+v", repo)
|
||||
log.Warn("name is blank error", check.GetGoPath())
|
||||
}
|
||||
|
||||
if argv.DryRun {
|
||||
continue
|
||||
}
|
||||
if argv.TestBuild != nil {
|
||||
if argv.DryRun {
|
||||
continue
|
||||
}
|
||||
if argv.Verbose {
|
||||
verbose := []string{"-v", "-x"}
|
||||
if err := me.forge.Build(check, verbose); err != nil {
|
||||
log.Warn("BUILD FAILED", check.GetGoPath(), err)
|
||||
failed[check] = fmt.Sprintf("%s %s %v", "go build", check.GetGoPath(), err)
|
||||
}
|
||||
} else {
|
||||
if err := me.forge.Build(check, nil); err != nil {
|
||||
log.Warn("BUILD FAILED", check.GetGoPath(), err)
|
||||
failed[check] = fmt.Sprintf("%s %s %v", "go build", check.GetGoPath(), err)
|
||||
}
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
log.Info("STARTING 'make install' in", check.GetGoPath())
|
||||
if argv.DryRun {
|
||||
continue
|
||||
}
|
||||
if argv.Verbose {
|
||||
verbose := []string{"-v", "-x"}
|
||||
if err := me.forge.Install(check, verbose); err != nil {
|
||||
log.Warn("INSTALL FAILED", check.GetGoPath(), err)
|
||||
failed[check] = fmt.Sprintf("%s %s %v", "go install", check.GetGoPath(), err)
|
||||
}
|
||||
} else {
|
||||
if err := me.forge.Install(check, nil); err != nil {
|
||||
log.Warn("INSTALL FAILED", check.GetGoPath(), err)
|
||||
failed[check] = fmt.Sprintf("%s %s %v", "go install", check.GetGoPath(), err)
|
||||
}
|
||||
}
|
||||
}
|
||||
if len(failed) != 0 {
|
||||
log.Info("")
|
||||
log.Info("something failed on:")
|
||||
for repo, cmd := range failed {
|
||||
log.Info("failed cmd :", cmd, repo.GetGoPath())
|
||||
}
|
||||
// me.forge.CheckoutUser()
|
||||
// shell.Run([]string{"forge", "--find-private"})
|
||||
badExit(errors.New("some repos failed"))
|
||||
return errors.New("some repos failed")
|
||||
}
|
||||
return nil
|
||||
}
|
|
@ -1,93 +0,0 @@
|
|||
// Copyright 2017-2025 WIT.COM Inc. All rights reserved.
|
||||
// Use of this source code is governed by the GPL 3.0
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"go.wit.com/log"
|
||||
)
|
||||
|
||||
func doListRepos() {
|
||||
all := me.forge.Repos.SortByFullPath()
|
||||
for all.Scan() {
|
||||
check := all.Next()
|
||||
|
||||
repotype := check.GetRepoType()
|
||||
if repotype == "binary" || repotype == "plugin" {
|
||||
// we only want to process things that can be compiled with 'go build'
|
||||
} else {
|
||||
// log.Info("skipping repo", check.GetGoPath(), repotype)
|
||||
continue
|
||||
}
|
||||
|
||||
if me.forge.Config.IsReadOnly(check.GetGoPath()) {
|
||||
// ignore read only stuff
|
||||
continue
|
||||
}
|
||||
|
||||
// var cmd []string
|
||||
var start string
|
||||
var end string
|
||||
|
||||
// add te repotype
|
||||
end += check.GetRepoType()
|
||||
|
||||
manufactured := check.GetCurrentVersion()
|
||||
ver := trimNonNumericFromStart(manufactured)
|
||||
name := me.forge.Config.DebName(check.GetGoPath())
|
||||
var realver string
|
||||
if installedPackage := me.machine.FindInstalledByName(name); installedPackage != nil {
|
||||
realver = installedPackage.Version
|
||||
}
|
||||
if actualp := me.machine.FindByVersion(name, ver); actualp != nil {
|
||||
end += " (version match) " + actualp.Version + " " + ver + " "
|
||||
state[check] = "on mirrors"
|
||||
} else {
|
||||
if realver != "" {
|
||||
end += fmt.Sprintf(" (version miss) %s vs %s ", realver, ver)
|
||||
}
|
||||
// end += "" + ver + " "
|
||||
}
|
||||
if me.machine.IsInstalled(name) {
|
||||
if actualp := me.machine.FindInstalledByName(name); actualp != nil {
|
||||
if ver != actualp.Version {
|
||||
end += "(installed " + actualp.Version + ") "
|
||||
} else {
|
||||
end += "(installed ok) "
|
||||
}
|
||||
} else {
|
||||
end += "(installed) "
|
||||
}
|
||||
}
|
||||
|
||||
debname := name + "_" + ver + "_amd64.deb"
|
||||
debnames[check] = debname
|
||||
outdir := getOutdir(check)
|
||||
_, err := os.Stat(filepath.Join(outdir, debname))
|
||||
if err == nil {
|
||||
// log.Info("exists", filepath.Join(outdir, debname))
|
||||
state[check] = "in incoming"
|
||||
} else {
|
||||
// log.Info(debname, "does not exist")
|
||||
}
|
||||
|
||||
if state[check] == "" {
|
||||
state[check] = "need to build"
|
||||
}
|
||||
start = fmt.Sprintf("%-15s %-20s %-50s", state[check], ver, debname)
|
||||
|
||||
if state[check] == "need to build" {
|
||||
end += " (will build) "
|
||||
}
|
||||
|
||||
log.Info(start, end)
|
||||
if name == "" {
|
||||
// err := fmt.Sprintf("name is blank error %+v", repo)
|
||||
log.Warn("name is blank error", check.GetGoPath())
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
// Copyright 2017-2025 WIT.COM Inc. All rights reserved.
|
||||
// Use of this source code is governed by the GPL 3.0
|
||||
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
|
@ -103,9 +104,6 @@ func scanForGoFiles(startDir string) ([]string, error) {
|
|||
if strings.HasSuffix(path, ".go") {
|
||||
files = append(files, path)
|
||||
}
|
||||
if strings.HasSuffix(path, ".proto") {
|
||||
files = append(files, path)
|
||||
}
|
||||
|
||||
// don't go into any directories
|
||||
if info.IsDir() {
|
||||
|
|
211
main.go
211
main.go
|
@ -4,46 +4,51 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"debug/buildinfo"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"unicode"
|
||||
|
||||
"go.wit.com/dev/alexflint/arg"
|
||||
"go.wit.com/lib/gui/prep"
|
||||
"go.wit.com/lib/gui/shell"
|
||||
"go.wit.com/log"
|
||||
|
||||
"go.wit.com/gui"
|
||||
"go.wit.com/lib/protobuf/forgepb"
|
||||
"go.wit.com/lib/protobuf/gitpb"
|
||||
"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 = "wit-test" // todo: get this from $0 ?
|
||||
|
||||
var failed map[*gitpb.Repo]string
|
||||
var state map[*gitpb.Repo]string
|
||||
var debnames map[*gitpb.Repo]string
|
||||
|
||||
func main() {
|
||||
me = new(autoType)
|
||||
prep.Bash(ARGNAME, argv.DoAutoComplete) // todo: this line should be: prep.Bash(argv)
|
||||
// me.myGui = prep.Gui() // prepares the GUI package for go-args
|
||||
me.argpp = arg.MustParse(&argv)
|
||||
|
||||
dumpDebug()
|
||||
if argv.Bash {
|
||||
argv.doBash()
|
||||
os.Exit(0)
|
||||
}
|
||||
if len(argv.BashAuto) != 0 {
|
||||
argv.doBashAuto()
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
failed = make(map[*gitpb.Repo]string)
|
||||
state = make(map[*gitpb.Repo]string)
|
||||
debnames = make(map[*gitpb.Repo]string)
|
||||
|
||||
// load the ~/.config/forge/ config
|
||||
me.forge = forgepb.Init()
|
||||
|
||||
me.machine, _ = zoopb.InitMachine()
|
||||
me.myGui = gui.New()
|
||||
me.myGui.Default()
|
||||
|
||||
if argv.Clone != nil {
|
||||
if argv.RepoMap != "" {
|
||||
|
@ -66,7 +71,7 @@ func main() {
|
|||
log.DaemonMode(true)
|
||||
defer log.DaemonMode(false)
|
||||
fmt.Println("Installed Packages:")
|
||||
loop := me.machine.Wit.SortByName()
|
||||
loop := me.forge.Machine.Wit.SortByName()
|
||||
for loop.Scan() {
|
||||
p := loop.Next()
|
||||
var end string
|
||||
|
@ -74,12 +79,12 @@ func main() {
|
|||
if me.forge.Config.IsPrivate(p.Name) {
|
||||
end += "(private) "
|
||||
}
|
||||
if actualp := me.machine.FindByVersion(p.Name, p.Version); actualp != nil {
|
||||
if actualp := me.forge.Machine.FindVersion(p.Name, p.Version); actualp != nil {
|
||||
// end += "(version match) "
|
||||
} else {
|
||||
end += "(version mismatch) " + actualp.Version + " " + version + " "
|
||||
}
|
||||
if actualp := me.machine.FindInstalledByName(p.Name); actualp != nil {
|
||||
if actualp := me.forge.Machine.FindInstalledByName(p.Name); actualp != nil {
|
||||
if p.Version != actualp.Version {
|
||||
end += "(installed " + actualp.Version + " vs " + p.Version + ") "
|
||||
} else {
|
||||
|
@ -97,21 +102,153 @@ func main() {
|
|||
okExit("")
|
||||
}
|
||||
|
||||
doListRepos()
|
||||
all := me.forge.Repos.SortByFullPath()
|
||||
for all.Scan() {
|
||||
check := all.Next()
|
||||
|
||||
if argv.DebBuild != nil {
|
||||
buildDeb()
|
||||
okExit("")
|
||||
repotype := check.GetRepoType()
|
||||
if repotype == "binary" || repotype == "plugin" {
|
||||
// we only want to process things that can be compiled with 'go build'
|
||||
} else {
|
||||
// log.Info("skipping repo", check.GetGoPath(), repotype)
|
||||
continue
|
||||
}
|
||||
|
||||
if me.forge.Config.IsReadOnly(check.GetGoPath()) {
|
||||
// ignore read only stuff
|
||||
continue
|
||||
}
|
||||
|
||||
// var cmd []string
|
||||
var start string
|
||||
var end string
|
||||
|
||||
// add te repotype
|
||||
end += check.GetRepoType()
|
||||
|
||||
manufactured := check.GetCurrentVersion()
|
||||
ver := trimNonNumericFromStart(manufactured)
|
||||
name := me.forge.Config.DebName(check.GetGoPath())
|
||||
var realver string
|
||||
if installedPackage := me.forge.Machine.FindInstalledByName(name); installedPackage != nil {
|
||||
realver = installedPackage.Version
|
||||
}
|
||||
if actualp := me.forge.Machine.FindVersion(name, ver); actualp != nil {
|
||||
end += " (version match) " + actualp.Version + " " + ver + " "
|
||||
state[check] = "on mirrors"
|
||||
} else {
|
||||
if realver != "" {
|
||||
end += fmt.Sprintf(" (version miss) %s vs %s ", realver, ver)
|
||||
}
|
||||
// end += "" + ver + " "
|
||||
}
|
||||
if me.forge.Machine.IsInstalled(name) {
|
||||
if actualp := me.forge.Machine.FindInstalledByName(name); actualp != nil {
|
||||
if ver != actualp.Version {
|
||||
end += "(installed " + actualp.Version + ") "
|
||||
} else {
|
||||
end += "(installed ok) "
|
||||
}
|
||||
} else {
|
||||
end += "(installed) "
|
||||
}
|
||||
}
|
||||
|
||||
debname := name + "_" + ver + "_amd64.deb"
|
||||
debnames[check] = debname
|
||||
outdir := getOutdir(check)
|
||||
_, err := os.Stat(filepath.Join(outdir, debname))
|
||||
if err == nil {
|
||||
// log.Info("exists", filepath.Join(outdir, debname))
|
||||
state[check] = "in incoming"
|
||||
} else {
|
||||
// log.Info(debname, "does not exist")
|
||||
}
|
||||
|
||||
if state[check] == "" {
|
||||
state[check] = "need to build"
|
||||
}
|
||||
start = fmt.Sprintf("%-15s %-20s %-50s", state[check], ver, debname)
|
||||
|
||||
if state[check] == "need to build" {
|
||||
end += " (will build) "
|
||||
}
|
||||
|
||||
log.Info(start, end)
|
||||
if name == "" {
|
||||
// err := fmt.Sprintf("name is blank error %+v", repo)
|
||||
log.Warn("name is blank error", check.GetGoPath())
|
||||
}
|
||||
|
||||
if argv.DryRun {
|
||||
continue
|
||||
}
|
||||
if argv.TestBuild != nil {
|
||||
if argv.DryRun {
|
||||
continue
|
||||
}
|
||||
if argv.Verbose {
|
||||
verbose := []string{"-v", "-x"}
|
||||
if err := me.forge.Build(check, verbose); err != nil {
|
||||
log.Warn("BUILD FAILED", check.GetGoPath(), err)
|
||||
failed[check] = fmt.Sprintf("%s %s %v", "go build", check.GetGoPath(), err)
|
||||
}
|
||||
} else {
|
||||
if err := me.forge.Build(check, nil); err != nil {
|
||||
log.Warn("BUILD FAILED", check.GetGoPath(), err)
|
||||
failed[check] = fmt.Sprintf("%s %s %v", "go build", check.GetGoPath(), err)
|
||||
}
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
if argv.MakeInstall != nil {
|
||||
if err := doInstall(); err != nil {
|
||||
log.Info("doInstall() failed", err)
|
||||
log.Info("STARTING 'make install' in", check.GetGoPath())
|
||||
if argv.DryRun {
|
||||
continue
|
||||
}
|
||||
if argv.Verbose {
|
||||
verbose := []string{"-v", "-x"}
|
||||
if err := me.forge.Install(check, verbose); err != nil {
|
||||
log.Warn("INSTALL FAILED", check.GetGoPath(), err)
|
||||
failed[check] = fmt.Sprintf("%s %s %v", "go install", check.GetGoPath(), err)
|
||||
}
|
||||
} else {
|
||||
if err := me.forge.Install(check, nil); err != nil {
|
||||
log.Warn("INSTALL FAILED", check.GetGoPath(), err)
|
||||
failed[check] = fmt.Sprintf("%s %s %v", "go install", check.GetGoPath(), err)
|
||||
}
|
||||
}
|
||||
continue
|
||||
}
|
||||
}
|
||||
if argv.DebBuild != nil {
|
||||
buildDeb()
|
||||
}
|
||||
if len(failed) != 0 {
|
||||
log.Info("")
|
||||
log.Info("something failed on:")
|
||||
for repo, cmd := range failed {
|
||||
log.Info("failed cmd :", cmd, repo.GetGoPath())
|
||||
}
|
||||
// me.forge.CheckoutUser()
|
||||
// shell.Run([]string{"forge", "--find-private"})
|
||||
badExit(errors.New("some repos failed"))
|
||||
}
|
||||
if argv.Test {
|
||||
homeDir, _ := os.UserHomeDir()
|
||||
|
||||
testdir := filepath.Join(homeDir, "go/src/go.wit.com/apps/utils/wit-utils/go-clone-test/")
|
||||
os.Chdir(testdir)
|
||||
shell.RunRealtime([]string{"go", "install"})
|
||||
|
||||
workdir := filepath.Join(homeDir, "gowork")
|
||||
if err := os.MkdirAll(workdir, os.ModePerm); err != nil {
|
||||
badExit(err)
|
||||
}
|
||||
okExit("EVERYTHING BUILT!")
|
||||
os.Chdir(workdir)
|
||||
shell.RunRealtime([]string{"go-clone-test"})
|
||||
}
|
||||
|
||||
okExit("everything compiled")
|
||||
}
|
||||
|
||||
|
@ -134,34 +271,6 @@ func okExit(thing string) {
|
|||
}
|
||||
|
||||
func badExit(err error) {
|
||||
log.Info("go-clean failed: ", err, me.forge.Config.ReposDir)
|
||||
log.Info("go-clean failed: ", err, me.forge.GetGoSrc())
|
||||
os.Exit(-1)
|
||||
}
|
||||
|
||||
func dumpDebug() {
|
||||
// Get absolute path of the currently running binary
|
||||
exePath, err := os.Executable()
|
||||
if err != nil {
|
||||
fmt.Println("Error getting executable path:", err)
|
||||
return
|
||||
}
|
||||
|
||||
// Resolve symlinks if necessary
|
||||
exePath, err = filepath.EvalSymlinks(exePath)
|
||||
if err != nil {
|
||||
fmt.Println("Error resolving symlink:", err)
|
||||
return
|
||||
}
|
||||
|
||||
// Read build info
|
||||
bi, err := buildinfo.ReadFile(exePath)
|
||||
if err != nil {
|
||||
fmt.Println("Error reading build info:", err)
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Println("Go Version:", bi.GoVersion)
|
||||
for _, dep := range bi.Deps {
|
||||
fmt.Printf("Dependency: %s %s\n", dep.Path, dep.Version)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,8 +5,8 @@ package main
|
|||
|
||||
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
|
||||
|
@ -14,6 +14,6 @@ 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
|
||||
machine *zoopb.Machine // your customized repo preferences and settings
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue