The relay and discosrv didn't use the new lib/build package, now they do. Conversely the lib/build package wasn't aware there might be other users and hard coded the program name - now it's set by the build script
This commit is contained in:
parent
999d4a0e23
commit
67b8ef1f3e
61
build.go
61
build.go
|
@ -24,6 +24,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"os/user"
|
"os/user"
|
||||||
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
@ -59,7 +60,7 @@ type target struct {
|
||||||
debpre string
|
debpre string
|
||||||
debpost string
|
debpost string
|
||||||
description string
|
description string
|
||||||
buildPkg string
|
buildPkgs []string
|
||||||
binaryName string
|
binaryName string
|
||||||
archiveFiles []archiveFile
|
archiveFiles []archiveFile
|
||||||
systemdServices []string
|
systemdServices []string
|
||||||
|
@ -76,9 +77,8 @@ type archiveFile struct {
|
||||||
var targets = map[string]target{
|
var targets = map[string]target{
|
||||||
"all": {
|
"all": {
|
||||||
// Only valid for the "build" and "install" commands as it lacks all
|
// Only valid for the "build" and "install" commands as it lacks all
|
||||||
// the archive creation stuff.
|
// the archive creation stuff. buildPkgs gets filled out in init()
|
||||||
buildPkg: "github.com/syncthing/syncthing/cmd/...",
|
tags: []string{"purego"},
|
||||||
tags: []string{"purego"},
|
|
||||||
},
|
},
|
||||||
"syncthing": {
|
"syncthing": {
|
||||||
// The default target for "build", "install", "tar", "zip", "deb", etc.
|
// The default target for "build", "install", "tar", "zip", "deb", etc.
|
||||||
|
@ -87,7 +87,7 @@ var targets = map[string]target{
|
||||||
debdeps: []string{"libc6", "procps"},
|
debdeps: []string{"libc6", "procps"},
|
||||||
debpost: "script/post-upgrade",
|
debpost: "script/post-upgrade",
|
||||||
description: "Open Source Continuous File Synchronization",
|
description: "Open Source Continuous File Synchronization",
|
||||||
buildPkg: "github.com/syncthing/syncthing/cmd/syncthing",
|
buildPkgs: []string{"github.com/syncthing/syncthing/cmd/syncthing"},
|
||||||
binaryName: "syncthing", // .exe will be added automatically for Windows builds
|
binaryName: "syncthing", // .exe will be added automatically for Windows builds
|
||||||
archiveFiles: []archiveFile{
|
archiveFiles: []archiveFile{
|
||||||
{src: "{{binary}}", dst: "{{binary}}", perm: 0755},
|
{src: "{{binary}}", dst: "{{binary}}", perm: 0755},
|
||||||
|
@ -131,7 +131,7 @@ var targets = map[string]target{
|
||||||
debdeps: []string{"libc6"},
|
debdeps: []string{"libc6"},
|
||||||
debpre: "cmd/stdiscosrv/scripts/preinst",
|
debpre: "cmd/stdiscosrv/scripts/preinst",
|
||||||
description: "Syncthing Discovery Server",
|
description: "Syncthing Discovery Server",
|
||||||
buildPkg: "github.com/syncthing/syncthing/cmd/stdiscosrv",
|
buildPkgs: []string{"github.com/syncthing/syncthing/cmd/stdiscosrv"},
|
||||||
binaryName: "stdiscosrv", // .exe will be added automatically for Windows builds
|
binaryName: "stdiscosrv", // .exe will be added automatically for Windows builds
|
||||||
archiveFiles: []archiveFile{
|
archiveFiles: []archiveFile{
|
||||||
{src: "{{binary}}", dst: "{{binary}}", perm: 0755},
|
{src: "{{binary}}", dst: "{{binary}}", perm: 0755},
|
||||||
|
@ -159,7 +159,7 @@ var targets = map[string]target{
|
||||||
debdeps: []string{"libc6"},
|
debdeps: []string{"libc6"},
|
||||||
debpre: "cmd/strelaysrv/scripts/preinst",
|
debpre: "cmd/strelaysrv/scripts/preinst",
|
||||||
description: "Syncthing Relay Server",
|
description: "Syncthing Relay Server",
|
||||||
buildPkg: "github.com/syncthing/syncthing/cmd/strelaysrv",
|
buildPkgs: []string{"github.com/syncthing/syncthing/cmd/strelaysrv"},
|
||||||
binaryName: "strelaysrv", // .exe will be added automatically for Windows builds
|
binaryName: "strelaysrv", // .exe will be added automatically for Windows builds
|
||||||
archiveFiles: []archiveFile{
|
archiveFiles: []archiveFile{
|
||||||
{src: "{{binary}}", dst: "{{binary}}", perm: 0755},
|
{src: "{{binary}}", dst: "{{binary}}", perm: 0755},
|
||||||
|
@ -187,7 +187,7 @@ var targets = map[string]target{
|
||||||
debname: "syncthing-relaypoolsrv",
|
debname: "syncthing-relaypoolsrv",
|
||||||
debdeps: []string{"libc6"},
|
debdeps: []string{"libc6"},
|
||||||
description: "Syncthing Relay Pool Server",
|
description: "Syncthing Relay Pool Server",
|
||||||
buildPkg: "github.com/syncthing/syncthing/cmd/strelaypoolsrv",
|
buildPkgs: []string{"github.com/syncthing/syncthing/cmd/strelaypoolsrv"},
|
||||||
binaryName: "strelaypoolsrv", // .exe will be added automatically for Windows builds
|
binaryName: "strelaypoolsrv", // .exe will be added automatically for Windows builds
|
||||||
archiveFiles: []archiveFile{
|
archiveFiles: []archiveFile{
|
||||||
{src: "{{binary}}", dst: "{{binary}}", perm: 0755},
|
{src: "{{binary}}", dst: "{{binary}}", perm: 0755},
|
||||||
|
@ -217,6 +217,18 @@ var dependencyRepos = []dependencyRepo{
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
all := targets["all"]
|
||||||
|
pkgs, _ := filepath.Glob("cmd/*")
|
||||||
|
for _, pkg := range pkgs {
|
||||||
|
pkg = filepath.Base(pkg)
|
||||||
|
if strings.HasPrefix(pkg, ".") {
|
||||||
|
// ignore dotfiles
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
all.buildPkgs = append(all.buildPkgs, fmt.Sprintf("github.com/syncthing/syncthing/cmd/%s", pkg))
|
||||||
|
}
|
||||||
|
targets["all"] = all
|
||||||
|
|
||||||
// The "syncthing" target includes a few more files found in the "etc"
|
// The "syncthing" target includes a few more files found in the "etc"
|
||||||
// and "extra" dirs.
|
// and "extra" dirs.
|
||||||
syncthingPkg := targets["syncthing"]
|
syncthingPkg := targets["syncthing"]
|
||||||
|
@ -382,9 +394,6 @@ func install(target target, tags []string) {
|
||||||
}
|
}
|
||||||
os.Setenv("GOBIN", filepath.Join(cwd, "bin"))
|
os.Setenv("GOBIN", filepath.Join(cwd, "bin"))
|
||||||
|
|
||||||
args := []string{"install", "-v"}
|
|
||||||
args = appendParameters(args, tags, target)
|
|
||||||
|
|
||||||
os.Setenv("GOOS", goos)
|
os.Setenv("GOOS", goos)
|
||||||
os.Setenv("GOARCH", goarch)
|
os.Setenv("GOARCH", goarch)
|
||||||
os.Setenv("CC", cc)
|
os.Setenv("CC", cc)
|
||||||
|
@ -400,19 +409,20 @@ func install(target target, tags []string) {
|
||||||
defer shouldCleanupSyso(sysoPath)
|
defer shouldCleanupSyso(sysoPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
runPrint(goCmd, args...)
|
for _, pkg := range target.buildPkgs {
|
||||||
|
args := []string{"install", "-v"}
|
||||||
|
args = appendParameters(args, tags, pkg)
|
||||||
|
|
||||||
|
runPrint(goCmd, args...)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func build(target target, tags []string) {
|
func build(target target, tags []string) {
|
||||||
lazyRebuildAssets()
|
lazyRebuildAssets()
|
||||||
|
|
||||||
tags = append(target.tags, tags...)
|
tags = append(target.tags, tags...)
|
||||||
|
|
||||||
rmr(target.BinaryName())
|
rmr(target.BinaryName())
|
||||||
|
|
||||||
args := []string{"build", "-v"}
|
|
||||||
args = appendParameters(args, tags, target)
|
|
||||||
|
|
||||||
os.Setenv("GOOS", goos)
|
os.Setenv("GOOS", goos)
|
||||||
os.Setenv("GOARCH", goarch)
|
os.Setenv("GOARCH", goarch)
|
||||||
os.Setenv("CC", cc)
|
os.Setenv("CC", cc)
|
||||||
|
@ -432,10 +442,15 @@ func build(target target, tags []string) {
|
||||||
defer shouldCleanupSyso(sysoPath)
|
defer shouldCleanupSyso(sysoPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
runPrint(goCmd, args...)
|
for _, pkg := range target.buildPkgs {
|
||||||
|
args := []string{"build", "-v"}
|
||||||
|
args = appendParameters(args, tags, pkg)
|
||||||
|
|
||||||
|
runPrint(goCmd, args...)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func appendParameters(args []string, tags []string, target target) []string {
|
func appendParameters(args []string, tags []string, pkg string) []string {
|
||||||
if pkgdir != "" {
|
if pkgdir != "" {
|
||||||
args = append(args, "-pkgdir", pkgdir)
|
args = append(args, "-pkgdir", pkgdir)
|
||||||
}
|
}
|
||||||
|
@ -451,7 +466,7 @@ func appendParameters(args []string, tags []string, target target) []string {
|
||||||
|
|
||||||
if !debugBinary {
|
if !debugBinary {
|
||||||
// Regular binaries get version tagged and skip some debug symbols
|
// Regular binaries get version tagged and skip some debug symbols
|
||||||
args = append(args, "-ldflags", ldflags())
|
args = append(args, "-ldflags", ldflags(path.Base(pkg)))
|
||||||
} else {
|
} else {
|
||||||
// -gcflags to disable optimizations and inlining. Skip -ldflags
|
// -gcflags to disable optimizations and inlining. Skip -ldflags
|
||||||
// because `Could not launch program: decoding dwarf section info at
|
// because `Could not launch program: decoding dwarf section info at
|
||||||
|
@ -460,7 +475,7 @@ func appendParameters(args []string, tags []string, target target) []string {
|
||||||
args = append(args, "-gcflags", "-N -l")
|
args = append(args, "-gcflags", "-N -l")
|
||||||
}
|
}
|
||||||
|
|
||||||
return append(args, target.buildPkg)
|
return append(args, pkg)
|
||||||
}
|
}
|
||||||
|
|
||||||
func buildTar(target target) {
|
func buildTar(target target) {
|
||||||
|
@ -708,6 +723,7 @@ func listFiles(dir string) []string {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if fi.Mode().IsRegular() {
|
if fi.Mode().IsRegular() {
|
||||||
res = append(res, path)
|
res = append(res, path)
|
||||||
}
|
}
|
||||||
|
@ -789,7 +805,7 @@ func transifex() {
|
||||||
runPrint(goCmd, "run", "../../../../script/transifexdl.go")
|
runPrint(goCmd, "run", "../../../../script/transifexdl.go")
|
||||||
}
|
}
|
||||||
|
|
||||||
func ldflags() string {
|
func ldflags(program string) string {
|
||||||
sep := '='
|
sep := '='
|
||||||
if goVersion > 0 && goVersion < 1.5 {
|
if goVersion > 0 && goVersion < 1.5 {
|
||||||
sep = ' '
|
sep = ' '
|
||||||
|
@ -801,8 +817,9 @@ func ldflags() string {
|
||||||
fmt.Fprintf(b, " -X github.com/syncthing/syncthing/lib/build.Stamp%c%d", sep, buildStamp())
|
fmt.Fprintf(b, " -X github.com/syncthing/syncthing/lib/build.Stamp%c%d", sep, buildStamp())
|
||||||
fmt.Fprintf(b, " -X github.com/syncthing/syncthing/lib/build.User%c%s", sep, buildUser())
|
fmt.Fprintf(b, " -X github.com/syncthing/syncthing/lib/build.User%c%s", sep, buildUser())
|
||||||
fmt.Fprintf(b, " -X github.com/syncthing/syncthing/lib/build.Host%c%s", sep, buildHost())
|
fmt.Fprintf(b, " -X github.com/syncthing/syncthing/lib/build.Host%c%s", sep, buildHost())
|
||||||
|
fmt.Fprintf(b, " -X github.com/syncthing/syncthing/lib/build.Program%c%s", sep, program)
|
||||||
if v := os.Getenv("EXTRA_LDFLAGS"); v != "" {
|
if v := os.Getenv("EXTRA_LDFLAGS"); v != "" {
|
||||||
fmt.Fprintf(b, " %s", v);
|
fmt.Fprintf(b, " %s", v)
|
||||||
}
|
}
|
||||||
return b.String()
|
return b.String()
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,6 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/AudriusButkevicius/recli"
|
"github.com/AudriusButkevicius/recli"
|
||||||
"github.com/flynn-archive/go-shlex"
|
"github.com/flynn-archive/go-shlex"
|
||||||
|
@ -128,7 +127,7 @@ func main() {
|
||||||
app.HelpName = app.Name
|
app.HelpName = app.Name
|
||||||
app.Author = "The Syncthing Authors"
|
app.Author = "The Syncthing Authors"
|
||||||
app.Usage = "Syncthing command line interface"
|
app.Usage = "Syncthing command line interface"
|
||||||
app.Version = strings.Replace(build.LongVersion, "syncthing", app.Name, 1)
|
app.Version = build.Version
|
||||||
app.Flags = fakeFlags
|
app.Flags = fakeFlags
|
||||||
app.Metadata = map[string]interface{}{
|
app.Metadata = map[string]interface{}{
|
||||||
"client": client,
|
"client": client,
|
||||||
|
|
|
@ -9,17 +9,15 @@ package main
|
||||||
import (
|
import (
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
|
||||||
"log"
|
"log"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"runtime"
|
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||||
|
"github.com/syncthing/syncthing/lib/build"
|
||||||
"github.com/syncthing/syncthing/lib/protocol"
|
"github.com/syncthing/syncthing/lib/protocol"
|
||||||
"github.com/syncthing/syncthing/lib/tlsutil"
|
"github.com/syncthing/syncthing/lib/tlsutil"
|
||||||
"github.com/syndtr/goleveldb/leveldb/opt"
|
"github.com/syndtr/goleveldb/leveldb/opt"
|
||||||
|
@ -65,24 +63,6 @@ var levelDBOptions = &opt.Options{
|
||||||
WriteBuffer: 32 << 20, // default 4<<20
|
WriteBuffer: 32 << 20, // default 4<<20
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
|
||||||
Version string
|
|
||||||
BuildStamp string
|
|
||||||
BuildUser string
|
|
||||||
BuildHost string
|
|
||||||
|
|
||||||
BuildDate time.Time
|
|
||||||
LongVersion string
|
|
||||||
)
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
stamp, _ := strconv.Atoi(BuildStamp)
|
|
||||||
BuildDate = time.Unix(int64(stamp), 0)
|
|
||||||
|
|
||||||
date := BuildDate.UTC().Format("2006-01-02 15:04:05 MST")
|
|
||||||
LongVersion = fmt.Sprintf(`stdiscosrv %s (%s %s-%s) %s@%s %s`, Version, runtime.Version(), runtime.GOOS, runtime.GOARCH, BuildUser, BuildHost, date)
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
var (
|
||||||
debug = false
|
debug = false
|
||||||
)
|
)
|
||||||
|
@ -109,9 +89,13 @@ func main() {
|
||||||
flag.StringVar(&metricsListen, "metrics-listen", "", "Metrics listen address")
|
flag.StringVar(&metricsListen, "metrics-listen", "", "Metrics listen address")
|
||||||
flag.StringVar(&replicationPeers, "replicate", "", "Replication peers, id@address, comma separated")
|
flag.StringVar(&replicationPeers, "replicate", "", "Replication peers, id@address, comma separated")
|
||||||
flag.StringVar(&replicationListen, "replication-listen", ":19200", "Replication listen address")
|
flag.StringVar(&replicationListen, "replication-listen", ":19200", "Replication listen address")
|
||||||
|
showVersion := flag.Bool("version", false, "Show version")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
log.Println(LongVersion)
|
log.Println(build.LongVersion)
|
||||||
|
if *showVersion {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
cert, err := tls.LoadX509KeyPair(certFile, keyFile)
|
cert, err := tls.LoadX509KeyPair(certFile, keyFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -14,12 +14,12 @@ import (
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/syncthing/syncthing/lib/build"
|
||||||
"github.com/syncthing/syncthing/lib/events"
|
"github.com/syncthing/syncthing/lib/events"
|
||||||
"github.com/syncthing/syncthing/lib/osutil"
|
"github.com/syncthing/syncthing/lib/osutil"
|
||||||
"github.com/syncthing/syncthing/lib/relay/protocol"
|
"github.com/syncthing/syncthing/lib/relay/protocol"
|
||||||
|
@ -34,24 +34,6 @@ import (
|
||||||
syncthingprotocol "github.com/syncthing/syncthing/lib/protocol"
|
syncthingprotocol "github.com/syncthing/syncthing/lib/protocol"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
|
||||||
Version string
|
|
||||||
BuildStamp string
|
|
||||||
BuildUser string
|
|
||||||
BuildHost string
|
|
||||||
|
|
||||||
BuildDate time.Time
|
|
||||||
LongVersion string
|
|
||||||
)
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
stamp, _ := strconv.Atoi(BuildStamp)
|
|
||||||
BuildDate = time.Unix(int64(stamp), 0)
|
|
||||||
|
|
||||||
date := BuildDate.UTC().Format("2006-01-02 15:04:05 MST")
|
|
||||||
LongVersion = fmt.Sprintf(`strelaysrv %s (%s %s-%s) %s@%s %s`, Version, runtime.Version(), runtime.GOOS, runtime.GOARCH, BuildUser, BuildHost, date)
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
var (
|
||||||
listen string
|
listen string
|
||||||
debug bool
|
debug bool
|
||||||
|
@ -117,8 +99,14 @@ func main() {
|
||||||
flag.IntVar(&natTimeout, "nat-timeout", 10, "NAT discovery timeout in seconds")
|
flag.IntVar(&natTimeout, "nat-timeout", 10, "NAT discovery timeout in seconds")
|
||||||
flag.BoolVar(&pprofEnabled, "pprof", false, "Enable the built in profiling on the status server")
|
flag.BoolVar(&pprofEnabled, "pprof", false, "Enable the built in profiling on the status server")
|
||||||
flag.IntVar(&networkBufferSize, "network-buffer", 2048, "Network buffer size (two of these per proxied connection)")
|
flag.IntVar(&networkBufferSize, "network-buffer", 2048, "Network buffer size (two of these per proxied connection)")
|
||||||
|
showVersion := flag.Bool("version", false, "Show version")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
|
if *showVersion {
|
||||||
|
fmt.Println(build.LongVersion)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if extAddress == "" {
|
if extAddress == "" {
|
||||||
extAddress = listen
|
extAddress = listen
|
||||||
}
|
}
|
||||||
|
@ -147,7 +135,7 @@ func main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Println(LongVersion)
|
log.Println(build.LongVersion)
|
||||||
|
|
||||||
maxDescriptors, err := osutil.MaximizeOpenFileLimit()
|
maxDescriptors, err := osutil.MaximizeOpenFileLimit()
|
||||||
if maxDescriptors > 0 {
|
if maxDescriptors > 0 {
|
||||||
|
|
|
@ -10,6 +10,8 @@ import (
|
||||||
"runtime"
|
"runtime"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/syncthing/syncthing/lib/build"
|
||||||
)
|
)
|
||||||
|
|
||||||
var rc *rateCalculator
|
var rc *rateCalculator
|
||||||
|
@ -40,10 +42,10 @@ func getStatus(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
sessionMut.Lock()
|
sessionMut.Lock()
|
||||||
// This can potentially be double the number of pending sessions, as each session has two keys, one for each side.
|
// This can potentially be double the number of pending sessions, as each session has two keys, one for each side.
|
||||||
status["version"] = Version
|
status["version"] = build.Version
|
||||||
status["buildHost"] = BuildHost
|
status["buildHost"] = build.Host
|
||||||
status["buildUser"] = BuildUser
|
status["buildUser"] = build.User
|
||||||
status["buildDate"] = BuildDate
|
status["buildDate"] = build.Date
|
||||||
status["startTime"] = rc.startTime
|
status["startTime"] = rc.startTime
|
||||||
status["uptimeSeconds"] = time.Since(rc.startTime) / time.Second
|
status["uptimeSeconds"] = time.Since(rc.startTime) / time.Second
|
||||||
status["numPendingSessionKeys"] = len(pendingSessions)
|
status["numPendingSessionKeys"] = len(pendingSessions)
|
||||||
|
|
|
@ -1,39 +0,0 @@
|
||||||
// Copyright (C) 2014 The Syncthing Authors.
|
|
||||||
//
|
|
||||||
// This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
||||||
// You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
||||||
|
|
||||||
// +build ignore
|
|
||||||
|
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bytes"
|
|
||||||
"fmt"
|
|
||||||
"io"
|
|
||||||
"os"
|
|
||||||
)
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
buf := make([]byte, 4096)
|
|
||||||
var err error
|
|
||||||
for err == nil {
|
|
||||||
n, err := io.ReadFull(os.Stdin, buf)
|
|
||||||
if n > 0 {
|
|
||||||
buf = buf[:n]
|
|
||||||
repl := bytes.Replace(buf, []byte("\n"), []byte("\r\n"), -1)
|
|
||||||
_, err = os.Stdout.Write(repl)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if err == io.EOF {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
buf = buf[:cap(buf)]
|
|
||||||
}
|
|
||||||
fmt.Println(err)
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
|
@ -18,10 +18,11 @@ import (
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// Injected by build script
|
// Injected by build script
|
||||||
|
Program = "syncthing"
|
||||||
Version = "unknown-dev"
|
Version = "unknown-dev"
|
||||||
Host = "unknown" // Set by build script
|
Host = "unknown"
|
||||||
User = "unknown" // Set by build script
|
User = "unknown"
|
||||||
Stamp = "0" // Set by build script
|
Stamp = "0"
|
||||||
|
|
||||||
// Static
|
// Static
|
||||||
Codename = "Fermium Flea"
|
Codename = "Fermium Flea"
|
||||||
|
@ -73,7 +74,7 @@ func setBuildData() {
|
||||||
Date = time.Unix(int64(stamp), 0)
|
Date = time.Unix(int64(stamp), 0)
|
||||||
|
|
||||||
date := Date.UTC().Format("2006-01-02 15:04:05 MST")
|
date := Date.UTC().Format("2006-01-02 15:04:05 MST")
|
||||||
LongVersion = fmt.Sprintf(`syncthing %s "%s" (%s %s-%s) %s@%s %s`, Version, Codename, runtime.Version(), runtime.GOOS, runtime.GOARCH, User, Host, date)
|
LongVersion = fmt.Sprintf(`%s %s "%s" (%s %s-%s) %s@%s %s`, Program, Version, Codename, runtime.Version(), runtime.GOOS, runtime.GOARCH, User, Host, date)
|
||||||
|
|
||||||
if len(Tags) > 0 {
|
if len(Tags) > 0 {
|
||||||
LongVersion = fmt.Sprintf("%s [%s]", LongVersion, strings.Join(Tags, ", "))
|
LongVersion = fmt.Sprintf("%s [%s]", LongVersion, strings.Join(Tags, ", "))
|
||||||
|
|
Loading…
Reference in New Issue