From 3961caa1792c68dc215a9b8c51965e6fd0518f2f Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Thu, 7 Nov 2024 07:03:13 -0600 Subject: [PATCH] attempt to make a fake control file --- Makefile | 31 ++++++++++++++++++++++--------- argv.go | 4 ++++ buildPackage.go | 4 ++++ main.go | 3 +++ readControlFile.go | 15 ++++++++++----- 5 files changed, 43 insertions(+), 14 deletions(-) diff --git a/Makefile b/Makefile index f1282d3..400a544 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,7 @@ .PHONY: debian +VERSION = $(shell git describe --tags) + run: build ./go-deb --repo go.wit.com/apps/autotypist @@ -12,12 +14,15 @@ no-gui: build build: -rm resources/*.so + touch resources/blank.so # embed the andlabs plugin -cp -a ~/go/src/go.wit.com/toolkits/andlabs.so resources/ - GO111MODULE="off" go build -v + GO111MODULE="off" go build -v \ + -ldflags "-X main.VERSION=${VERSION} -X gui.GUIVERSION=${VERSION}" install: - GO111MODULE="off" go install -v + GO111MODULE="off" go install -v \ + -ldflags "-X main.VERSION=${VERSION} -X gui.GUIVERSION=${VERSION}" goimports: goimports -w *.go @@ -51,17 +56,25 @@ build-test-keep-files: build ./go-deb --no-gui --keep-files --repo go.wit.com/apps/go-deb build-all: + go-deb --no-gui --repo go.wit.com/apps/go-deb + go-deb --no-gui --repo go.wit.com/apps/go-clone + go-deb --no-gui --repo go.wit.com/apps/autotypist + go-deb --no-gui --repo go.wit.com/apps/virtigoctl + go-deb --no-gui --repo go.wit.com/apps/virtigo go-deb --no-gui --repo go.wit.com/apps/autotypist - go-deb --no-gui --repo go.wit.com/apps/control-panel-digitalocean - go-deb --no-gui --repo go.wit.com/apps/control-panel-vpn - go-deb --no-gui --repo go.wit.com/apps/go-gui-toolkits go-deb --no-gui --repo go.wit.com/apps/guireleaser + go-deb --no-gui --repo go.wit.com/apps/gowebd + go-deb --no-gui --repo go.wit.com/apps/networkQuality + go-deb --no-gui --repo go.wit.com/apps/helloworld + go-deb --no-gui --repo go.wit.com/apps/basicwindow + go-deb --no-gui --repo go.wit.com/apps/gadgetwindow + go-deb --no-gui --repo go.wit.com/apps/powerpaneld + go-deb --no-gui --repo go.wit.com/lib/daemons/virtigod go-deb --no-gui --repo go.wit.com/apps/control-panel-cloudflare go-deb --no-gui --repo go.wit.com/apps/control-panel-dns - go-deb --no-gui --repo go.wit.com/apps/go-deb - go-deb --no-gui --repo go.wit.com/apps/go.wit.com - go-deb --no-gui --repo go.wit.com/apps/helloworld - go-deb --no-gui --repo golang.org/x/tools/cmd/goimports + go-deb --no-gui --repo go.wit.com/apps/control-panel-droplet + go-deb --no-gui --repo go.wit.com/apps/control-panel-vpn + # go-deb --no-gui --repo golang.org/x/tools/cmd/goimports build-releases: -go-deb --release --no-gui --repo go.wit.com/apps/autotypist diff --git a/argv.go b/argv.go index ea1ec8d..f7697d3 100644 --- a/argv.go +++ b/argv.go @@ -32,3 +32,7 @@ func init() { log.Info("cmd line --debugger == false") } } + +func (args) Version() string { + return "go-clone " + VERSION +} diff --git a/buildPackage.go b/buildPackage.go index 36f83dc..bf0657f 100644 --- a/buildPackage.go +++ b/buildPackage.go @@ -98,6 +98,8 @@ func (c *controlBox) buildPackage() (bool, error) { if shell.Exists("files") { shell.Run([]string{"rm", "-rf", "files"}) + log.Info("running sync") + shell.Run([]string{"sync"}) if shell.Exists("files") { log.Warn("rm failed for some reason") return false, errors.New("rm files/") @@ -183,6 +185,8 @@ func (c *controlBox) buildPackage() (bool, error) { log.Info("keeping the build files/") } else { shell.Run([]string{"rm", "-rf", "files"}) + log.Info("running sync") + shell.Run([]string{"sync"}) if shell.Exists("files") { log.Warn("rm -rf files/ failed. Run() returned false") return false, errors.New("rm files/") diff --git a/main.go b/main.go index e40bc7b..edc3fda 100644 --- a/main.go +++ b/main.go @@ -12,6 +12,9 @@ import ( "go.wit.com/log" ) +// sent from -ldflags +var VERSION string + // This is the beginning of the binary tree of GUI widgets var myGui *gui.Node diff --git a/readControlFile.go b/readControlFile.go index 9def952..b307849 100644 --- a/readControlFile.go +++ b/readControlFile.go @@ -2,7 +2,6 @@ package main import ( "bufio" - "errors" "os" "strings" @@ -11,16 +10,22 @@ import ( // readGitConfig reads and parses the control file func (c *controlBox) readControlFile() error { + pairs := make(map[string]string) + var key string + file, err := os.Open("control") if err != nil { log.Warn("readControlFile() could not find the file") - return errors.New("'control': file not found") + // return errors.New("'control': file not found") + // if this happens, make up a fake control file + pairs["Maintainer"] = "go-deb build" + pairs["Architecture"] = "x86" + pairs["Recommends"] = "" + pairs["Source"] = "notsure" + pairs["Description"] = "put something here" } defer file.Close() - pairs := make(map[string]string) - var key string - scanner := bufio.NewScanner(file) for scanner.Scan() { line := scanner.Text()