2015-10-05 20:32:10 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set -eu
|
|
|
|
|
2015-12-20 17:44:11 +01:00
|
|
|
cd "$(dirname "$0")"
|
|
|
|
|
2016-06-29 22:27:32 +02:00
|
|
|
# GOPATH may contain multiple paths separated by ":"
|
2016-10-30 16:13:16 +01:00
|
|
|
GOPATH1=$(echo $GOPATH | cut -f1 -d:)
|
2016-06-29 22:27:32 +02:00
|
|
|
|
2016-04-10 23:16:09 +02:00
|
|
|
# gocryptfs version according to git
|
2015-11-01 13:55:35 +01:00
|
|
|
GITVERSION=$(git describe --tags --dirty)
|
2016-06-19 20:34:54 +02:00
|
|
|
|
2016-04-10 23:16:09 +02:00
|
|
|
# go-fuse version according to git
|
2016-10-30 16:10:40 +01:00
|
|
|
# Note: git in CentOS 7 does not have "git -C" yet. That's why we use
|
|
|
|
# plain "cd" in a subshell.
|
2016-06-19 20:34:54 +02:00
|
|
|
GITVERSIONFUSE=$(
|
2016-10-30 16:13:16 +01:00
|
|
|
cd $GOPATH1/src/github.com/hanwen/go-fuse
|
2016-06-19 20:34:54 +02:00
|
|
|
SHORT=$(git rev-parse --short HEAD)
|
|
|
|
|
2016-10-30 16:10:40 +01:00
|
|
|
if [[ $SHORT == 5e829bc ]] ; then
|
|
|
|
echo "Error: The version $SHORT of the go-fuse library has a known crasher that" >&2
|
|
|
|
echo "has been fixed by https://github.com/hanwen/go-fuse/pull/131 . Please upgrade." >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2016-06-19 20:34:54 +02:00
|
|
|
# Check if the tree is dirty, adapted from
|
|
|
|
# http://stackoverflow.com/a/2659808/1380267
|
2016-10-30 16:10:40 +01:00
|
|
|
if ! git diff-index --quiet HEAD ; then
|
2016-06-19 20:34:54 +02:00
|
|
|
echo $SHORT-dirty
|
|
|
|
else
|
|
|
|
echo $SHORT
|
|
|
|
fi
|
|
|
|
)
|
2015-11-01 13:55:35 +01:00
|
|
|
|
2016-07-03 16:49:42 +02:00
|
|
|
# Build Unix timestamp, something like 1467554204.
|
|
|
|
BUILDTIME=$(date +%s)
|
|
|
|
|
2016-06-14 22:56:28 +02:00
|
|
|
# Make sure we have the go binary
|
|
|
|
go version > /dev/null
|
|
|
|
|
2016-06-19 19:33:15 +02:00
|
|
|
# "go version go1.6.2 linux/amd64" -> "1.6"
|
2015-12-20 17:30:10 +01:00
|
|
|
V=$(go version | cut -d" " -f3 | cut -c3-5)
|
|
|
|
|
2016-10-30 16:10:40 +01:00
|
|
|
if [[ $V == "1.3" || $V == "1.4" ]] ; then
|
2016-10-04 09:51:14 +02:00
|
|
|
go build -ldflags="-X main.GitVersion $GITVERSION -X main.GitVersionFuse $GITVERSIONFUSE -X main.BuildTime $BUILDTIME" $@
|
2015-12-20 17:30:10 +01:00
|
|
|
else
|
2015-12-20 17:44:11 +01:00
|
|
|
# Go 1.5 wants an "=" here
|
2016-10-04 09:51:14 +02:00
|
|
|
go build -ldflags="-X main.GitVersion=$GITVERSION -X main.GitVersionFuse=$GITVERSIONFUSE -X main.BuildTime=$BUILDTIME" $@
|
2015-12-20 17:30:10 +01:00
|
|
|
fi
|
2016-12-06 22:44:58 +01:00
|
|
|
(cd gocryptfs-xray; go build $@)
|
2015-12-20 17:30:10 +01:00
|
|
|
|
|
|
|
./gocryptfs -version
|
2016-01-09 15:31:34 +01:00
|
|
|
|
2016-10-30 16:13:16 +01:00
|
|
|
mkdir -p $GOPATH1/bin
|
|
|
|
cp -af gocryptfs $GOPATH1/bin
|