try to fix 'release' builds

This commit is contained in:
Jeff Carr 2025-02-14 17:11:48 -06:00
parent da425cfb0f
commit 31eac3d915
2 changed files with 23 additions and 19 deletions

View File

@ -3,8 +3,11 @@
VERSION = $(shell git describe --tags) VERSION = $(shell git describe --tags)
DATE = $(shell date +%Y.%m.%d) DATE = $(shell date +%Y.%m.%d)
run: build run: install
./go-deb --forge go.wit.com/apps/autotypist go-deb --release --no-gui --auto --forge go.wit.com/apps/autogenpb --dir ${HOME}/incoming
go-deb --release --no-gui --auto --forge go.wit.com/apps/go-mod-clean --dir ${HOME}/incoming
@#go-deb --forge go.wit.com/apps/autotypist --no-gui --auto
ls -lth ${HOME}/incoming
vet: vet:
@GO111MODULE=off go vet @GO111MODULE=off go vet
@ -13,7 +16,7 @@ vet:
auto-build: build auto-build: build
./go-deb --auto --repo go.wit.com/apps/autotypist ./go-deb --auto --repo go.wit.com/apps/autotypist
build: goimports build: goimports vet
-rm resources/*.so -rm resources/*.so
touch resources/blank.so touch resources/blank.so
GO111MODULE="off" go build -v \ GO111MODULE="off" go build -v \

View File

@ -71,18 +71,22 @@ func (c *controlBox) buildPackage() (bool, error) {
if argv.Release { if argv.Release {
os.Unsetenv("GO111MODULE") os.Unsetenv("GO111MODULE")
path := c.pathL.String() + "@latest" cmd := []string{"forge", "--verbose", "--install", argv.Forge}
cmd := []string{"go", "install", "-v", "-x", path} if err := shell.PathExecVerbose("", cmd); err != nil {
if r := shell.Run(cmd); r.Error == nil { badExit(err)
log.Warn("go install worked") return false, fmt.Errorf("go build err %v", err)
} else {
return false, errors.New("go install")
} }
// must 'go install' then 'go build' so they are both in ~/go/src and in the repo dir
cmd = []string{"forge", "--verbose", "--build", argv.Forge}
if err := shell.PathExecVerbose("", cmd); err != nil {
badExit(err)
return false, fmt.Errorf("go build err %v", err)
}
log.Warn("forge build worked")
} else { } else {
// set the GO111 build var to true. pass the versions to the compiler manually // set the GO111 build var to true. pass the versions to the compiler manually
os.Setenv("GO111MODULE", "off") os.Setenv("GO111MODULE", "off")
cmd := []string{"go", "build"} cmd := []string{"go", "build"}
// set standard ldflag options // set standard ldflag options
now := time.Now() now := time.Now()
datestamp := now.UTC().Format("2006/01/02_1504_UTC") datestamp := now.UTC().Format("2006/01/02_1504_UTC")
@ -100,12 +104,9 @@ func (c *controlBox) buildPackage() (bool, error) {
cmd = append(cmd, "-ldflags", "-X "+flag) cmd = append(cmd, "-ldflags", "-X "+flag)
} }
r := shell.Run(cmd) _, err := shell.RunVerbose(cmd)
if r.Exit != 0 { if err != nil {
return false, errors.New("go build") return false, fmt.Errorf("go build err %v", err)
}
if r.Error != nil {
return false, errors.New("go build")
} }
log.Warn("go build worked") log.Warn("go build worked")
} }
@ -126,7 +127,7 @@ func (c *controlBox) buildPackage() (bool, error) {
if shell.Exists("files") { if shell.Exists("files") {
shell.Run([]string{"rm", "-rf", "files"}) shell.Run([]string{"rm", "-rf", "files"})
log.Info("running sync") // log.Info("running sync")
shell.Run([]string{"sync"}) shell.Run([]string{"sync"})
if shell.Exists("files") { if shell.Exists("files") {
log.Warn("rm failed for some reason") log.Warn("rm failed for some reason")
@ -196,7 +197,7 @@ func (c *controlBox) buildPackage() (bool, error) {
shell.Run([]string{"dpkg-deb", "--build", "files", fulldebname}) shell.Run([]string{"dpkg-deb", "--build", "files", fulldebname})
if shell.Exists(fulldebname) { if shell.Exists(fulldebname) {
} else { } else {
log.Warn("build failed") log.Warn("build failed", fulldebname)
return false, errors.New("dpkg-deb --build failed") return false, errors.New("dpkg-deb --build failed")
} }
shell.Run([]string{"dpkg-deb", "-I", fulldebname}) shell.Run([]string{"dpkg-deb", "-I", fulldebname})
@ -208,7 +209,7 @@ func (c *controlBox) buildPackage() (bool, error) {
log.Info("keeping the build files/") log.Info("keeping the build files/")
} else { } else {
shell.Run([]string{"rm", "-rf", "files"}) shell.Run([]string{"rm", "-rf", "files"})
log.Info("running sync") // log.Info("running sync")
shell.Run([]string{"sync"}) shell.Run([]string{"sync"})
if shell.Exists("files") { if shell.Exists("files") {
log.Warn("rm -rf files/ failed. Run() returned false") log.Warn("rm -rf files/ failed. Run() returned false")