From 6a17f14c058e230cc620b72cf80099c2aa7f7335 Mon Sep 17 00:00:00 2001 From: Josh Bleecher Snyder Date: Tue, 15 Mar 2022 12:53:24 -0700 Subject: [PATCH] [tailscale1.20] cmd/dist: support embedding of toolchain rev by env var Git checkouts are not reproducible (in particular, the .git directory's hashes vary according to the moods of git re: packing and other local settings), so building our Go toolchain via Nix leads to source hashes that change from machine to machine and over time. Since Nix already knows the exact git revision it's building from, this change lets Nix provide that hash to cmd/dist directly, skipping the rooting around in .git to find the right hash. Signed-off-by: David Anderson (cherry picked from commit 4cbd2683f8f31b9498dec50d0180106bb2d8a875) --- src/cmd/dist/build.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/cmd/dist/build.go b/src/cmd/dist/build.go index 4eab37327b162e..56f4ed06aa8b42 100644 --- a/src/cmd/dist/build.go +++ b/src/cmd/dist/build.go @@ -364,6 +364,11 @@ func findgoversion() string { } if isGitRepo() { b += "-ts" + chomp(run(goroot, CheckExit, "git", "log", "-n", "1", "--format=format:%h", "HEAD")) + } else if rev := os.Getenv("TAILSCALE_TOOLCHAIN_REV"); rev != "" { + if len(rev) > 10 { + rev = rev[:10] + } + b += "-ts" + chomp(rev) } return b }