diff --git a/Makefile b/Makefile index 2d58f65..bf0bda0 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,6 @@ +UPDATE_URL=https://noisetorch.epicgamer.org +UPDATE_PUBKEY=3mL+rBi4yBZ1wGimQ/oSQCjxELzgTh+673H4JdzQBOk= + dev: rnnoise mkdir -p bin/ go generate @@ -14,7 +17,7 @@ release: rnnoise mkdir -p tmp/.local/bin/ go generate - CGO_ENABLED=0 GOOS=linux go build -tags release -a -ldflags '-s -w -extldflags "-static"' . + CGO_ENABLED=0 GOOS=linux go build -tags release -a -ldflags '-s -w -extldflags "-static" -X main.distribution=official -X main.updateURL=${UPDATE_URL} -X main.publicKeyString=${UPDATE_PUBKEY}' . upx noisetorch mv noisetorch tmp/.local/bin/ cd tmp/; \ diff --git a/main.go b/main.go index 0ec62c6..7eea556 100644 --- a/main.go +++ b/main.go @@ -41,6 +41,10 @@ type device struct { } const appName = "NoiseTorch" +var distribution = "custom" // will be changed by build + +var updateURL = "" // ditto +var publicKeyString = "" // ditto func main() { opt := parseCLIOpts() @@ -50,7 +54,7 @@ func main() { } else { log.SetOutput(ioutil.Discard) } - log.Printf("Application starting. Version: %s\n", version) + log.Printf("Application starting. Version: %s (%s)\n", version, distribution) log.Printf("CAP_SYS_RESOURCE: %t\n", hasCapSysResource(getCurrentCaps())) initializeConfigIfNot() diff --git a/ui.go b/ui.go index af4421a..bbab17f 100644 --- a/ui.go +++ b/ui.go @@ -345,7 +345,7 @@ func versionView(ctx *ntcontext, w *nucular.Window) { w.Row(50).Dynamic(1) w.Label("Version", "CB") w.Row(50).Dynamic(1) - w.Label(version, "CB") + w.Label(fmt.Sprintf("%s (%s)", version, distribution), "CB") w.Row(50).Dynamic(1) w.Spacing(1) w.Row(20).Dynamic(2) diff --git a/update.go b/update.go index aedf33c..286a905 100644 --- a/update.go +++ b/update.go @@ -14,9 +14,6 @@ import ( "strings" ) -var updateURL = "https://noisetorch.epicgamer.org" -var publicKeyString = "3mL+rBi4yBZ1wGimQ/oSQCjxELzgTh+673H4JdzQBOk=" - type updateui struct { serverVersion string available bool @@ -24,7 +21,14 @@ type updateui struct { updatingText string } +func updateable() bool { + return updateURL != "" && publicKeyString != "" +} + func updateCheck(ctx *ntcontext) { + if !updateable() { + return + } log.Println("Checking for updates") bodybuf, err := fetchFile("version.txt") if err != nil { @@ -41,6 +45,9 @@ func updateCheck(ctx *ntcontext) { } func update(ctx *ntcontext) { + if !updateable() { + return + } sig, err := fetchFile("NoiseTorch_x64.tgz.sig") if err != nil { log.Println("Couldn't fetch signature", err) diff --git a/update_noop.go b/update_noop.go index 91fdc38..c9de84e 100644 --- a/update_noop.go +++ b/update_noop.go @@ -9,6 +9,10 @@ type updateui struct { updatingText string } +func updateable() bool { + return false +} + func updateCheck(ctx *ntcontext) { // noop for non-release versions }