diff --git a/build.sh b/build.sh index 34f64043..e12d2b3a 100755 --- a/build.sh +++ b/build.sh @@ -4,6 +4,7 @@ export COPYFILE_DISABLE=true distFiles=(README.md LICENSE) # apart from the binary itself version=$(git describe --always --dirty) +date=$(date +%s) build() { if command -v godep >/dev/null ; then @@ -14,8 +15,8 @@ build() { go get -d ./cmd/syncthing godep= fi - ${godep} go build $* -ldflags "-w -X main.Version $version" ./cmd/syncthing - ${godep} go build -ldflags "-w -X main.Version $version" ./cmd/stcli + ${godep} go build $* -ldflags "-w -X main.Version $version -X main.BuildStamp $date" ./cmd/syncthing + ${godep} go build -ldflags "-w -X main.Version $version -X main.BuildStamp $date" ./cmd/stcli } assets() { diff --git a/cmd/syncthing/main.go b/cmd/syncthing/main.go index 98280cad..1ba0a059 100644 --- a/cmd/syncthing/main.go +++ b/cmd/syncthing/main.go @@ -28,10 +28,19 @@ import ( const BlockSize = 128 * 1024 -var cfg Configuration -var Version = "unknown-dev" +var ( + Version = "unknown-dev" + BuildStamp = "0" + BuildDate time.Time +) + +func init() { + stamp, _ := strconv.Atoi(BuildStamp) + BuildDate = time.Unix(int64(stamp), 0) +} var ( + cfg Configuration myID string confDir string rateBucket *ratelimit.Bucket @@ -80,7 +89,8 @@ func main() { } if showVersion { - fmt.Printf("syncthing %s (%s %s-%s)\n", Version, runtime.Version(), runtime.GOOS, runtime.GOARCH) + date := BuildDate.UTC().Format(time.RFC3339) + fmt.Printf("syncthing %s (%s %s-%s) %s\n", Version, runtime.Version(), runtime.GOOS, runtime.GOARCH, date) return }