aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlawl <github@dumbinter.net>2020-11-12 14:50:42 +0100
committerlawl <github@dumbinter.net>2020-11-12 14:50:42 +0100
commit8ddee5f4bd9209fbfab63e6fd0b815c92c74266b (patch)
tree81323851f4a11a0bd079d6b911b4a42f46f9a921
parent76d5c2e5ff89075c0f4fddfa92e20c285e3da14e (diff)
downloadnoisetorch-8ddee5f4bd9209fbfab63e6fd0b815c92c74266b.tar.gz
noisetorch-8ddee5f4bd9209fbfab63e6fd0b815c92c74266b.zip
Add build flag to enable the update
A regular make will produce a build without the updater. An explicit -tags release is now required to bake the updater in.
-rw-r--r--Makefile2
-rw-r--r--README.md3
-rw-r--r--config.go5
-rw-r--r--update.go2
-rw-r--r--update_noop.go28
5 files changed, 35 insertions, 5 deletions
diff --git a/Makefile b/Makefile
index 75f6ced..661bfce 100644
--- a/Makefile
+++ b/Makefile
@@ -14,7 +14,7 @@ release: rnnoise
mkdir -p tmp/.local/bin/
go generate
- CGO_ENABLED=0 GOOS=linux go build -a -ldflags '-s -w -extldflags "-static"' .
+ CGO_ENABLED=0 GOOS=linux go build -tags release -a -ldflags '-s -w -extldflags "-static"' .
upx noisetorch
mv noisetorch tmp/.local/bin/
cd tmp/; \
diff --git a/README.md b/README.md
index f89f89b..08761fa 100644
--- a/README.md
+++ b/README.md
@@ -94,9 +94,6 @@ Install the Go compiler from [golang.org](https://golang.org/). And make sure yo
make # build it
```
-If you build from source, it's recommended that you disable automatic update checks.
-In `~/.config/noisetorch/config.toml` set `EnableUpdates = false`.
-
## Special thanks to
* [xiph.org](https://xiph.org)/[Mozilla's](https://mozilla.org) excellent [RNNoise](https://jmvalin.ca/demo/rnnoise/).
diff --git a/config.go b/config.go
index de16249..b45e829 100644
--- a/config.go
+++ b/config.go
@@ -20,7 +20,10 @@ const configFile = "config.toml"
func initializeConfigIfNot() {
log.Println("Checking if config needs to be initialized")
- conf := config{Threshold: 95, DisplayMonitorSources: false, EnableUpdates: true}
+ conf := config{Threshold: 95, DisplayMonitorSources: false, EnableUpdates: true} // if you're a package maintainer and you mess with this, we have a problem.
+ // Unless you set -tags release on the build the updater is *not* compiled in any. DO NOT MESS WITH THIS!
+ // This isn't and never was the proper location to disable the updater.
+
configdir := configDir()
ok, err := exists(configdir)
if err != nil {
diff --git a/update.go b/update.go
index 6b83406..aedf33c 100644
--- a/update.go
+++ b/update.go
@@ -1,3 +1,5 @@
+// +build release
+
package main
import (
diff --git a/update_noop.go b/update_noop.go
new file mode 100644
index 0000000..bdd7698
--- /dev/null
+++ b/update_noop.go
@@ -0,0 +1,28 @@
+// +build !release
+
+package main
+
+import "errors"
+
+type updateui struct {
+ serverVersion string
+ available bool
+ triggered bool
+ updatingText string
+}
+
+func updateCheck(ctx *ntcontext) {
+
+}
+
+func update(ctx *ntcontext) {
+
+}
+
+func fetchFile(file string) ([]byte, error) {
+ return make([]byte, 0), errors.New("Disabled by build flags")
+}
+
+func publickey() []byte {
+ return make([]byte, 0)
+}