Skip to content

Commit

Permalink
[tailscale1.20] cmd/dist: support embedding of toolchain rev by env var
Browse files Browse the repository at this point in the history
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 <danderson@tailscale.com>
(cherry picked from commit 4cbd268)
  • Loading branch information
josharian authored and bradfitz committed Jan 31, 2023
1 parent e858fd8 commit 6a17f14
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/cmd/dist/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 6a17f14

Please sign in to comment.