Packaging syncthing (gentoo)

Hi, I am looking at how to improve gentoo’s ebuild for syncthing. There are a few things I am not sure about.

  • How to build the bare minimum for syncthing? That is, without all the tools?

  • Am I correct that the syncthing binary does not need any other files to function?

  • Is there a way to build a tool or a set of tools separately, i.e. relaysrv?

  • Do any of the tools rely on each other? If yes, where do they expect to find other tools?

I recommend looking at what the build script does and reading the documentation. It’s what we use to build the distribution archives that end up on GitHub and so on, so it shows the required setup, build steps and so on. Make sure that you can build Syncthing correctly using the build script before doing anything else. For example, go run build.go tar creates the distribution tar archive for your platform.

But expanding a bit on that;

To build just the “syncthing” binary, you need to 1) create the compiled in assets and 2) build the binary, with automatic upgrades disabled. That becomes two commands:

$ go run script/genassets.go gui
$ go build -i -v -ldflags "-w -X main.Version=v0.13.7+54-gd55850d-protobufs \
  -X main.BuildStamp=1466063965 -X main.BuildUser=jb -X main.BuildHost=syno" \
  -tags noupgrade ./cmd/syncthing

This requires a correct Go setup with $GOPATH etc. You’ll want to learn about building Go projects in general if you’re doing anything more advanced than just running our build script. You’ll see that we set a number of variables above extracted from the environment. You’ll want to get these right as well, however you determine them.

Just running go run build.go -no-upgrade build is the quickest way to get a correctly built syncthing binary and nothing else.

Mostly. When built natively, it tends to depend on the system C library (glibc on Linux etc). It also requires accessing the system CA bundle to verify HTTPS certificates for things like usage reporting and upgrades (when not disabled).

Yes, see above and the build.go file.


Hi Jacob,

ok, thanks a lot! Is there an easy way to compile a specific tool, in a spirit of running

go run build.go relaysrv


P.S.: I see that

go run build.go -no-upgrade build relaysrv

works. Is this the way it was meant to be used?

Yes. There are defined targets for syncthing, discosrv and relaysrv in build.go.