summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Unterwurzacher2017-08-02 23:34:14 +0200
committerJakob Unterwurzacher2017-08-02 23:41:20 +0200
commite4fdb424964599db2e8d0ab273b6be804c6c9c12 (patch)
tree358e489ce40a86cfe5963d6f303d859396947d11
parent1f39ede4b46ec3609ccbe1d54402f4a17f3d697e (diff)
build.bash: implement "you need Go 1.5" lockout in pure Go
As noticed by @riking, the logic in the bash script will break when Go 1 version numbers reach double-digits. Instead, use a build tag "!go1.5" to cause a syntax error: $ /opt/go1.4.3/bin/go build can't load package: package github.com/rfjakob/gocryptfs: go1.4.go:5:1: expected 'package', found 'STRING' "You need Go 1.5 or higher to compile gocryptfs!" Fixes https://github.com/rfjakob/gocryptfs/issues/133
-rwxr-xr-xbuild.bash10
-rw-r--r--go1.4.go5
2 files changed, 5 insertions, 10 deletions
diff --git a/build.bash b/build.bash
index 7100bb9..5c13536 100755
--- a/build.bash
+++ b/build.bash
@@ -30,16 +30,6 @@ BUILDTIME=$(date +%s)
# Make sure we have the go binary
go version > /dev/null
-# Parse "go version go1.6.2 linux/amd64" to "1.6"
-V=$(go version | cut -d" " -f3 | cut -c3-5)
-# Reject old Go versions already here. It would fail with compile
-# errors anyway.
-if [[ $V == "1.3" || $V == "1.4" ]] ; then
- echo "Error: you need Go 1.5 or higher to compile gocryptfs"
- echo -n "You have: "
- go version
-fi
-
LDFLAGS="-X main.GitVersion=$GITVERSION -X main.GitVersionFuse=$GITVERSIONFUSE -X main.BuildTime=$BUILDTIME"
go build "-ldflags=$LDFLAGS" $@
diff --git a/go1.4.go b/go1.4.go
new file mode 100644
index 0000000..939fe91
--- /dev/null
+++ b/go1.4.go
@@ -0,0 +1,5 @@
+// +build !go1.5
+
+// Cause an early compile error on Go 1.4 an lower. We need Go 1.5 for a number
+// of reasons, among them NewGCMWithNonceSize and RawURLEncoding.
+"You need Go 1.5 or higher to compile gocryptfs!"