version: use OSS repo's version when building.
When building with redo, also include the git commit hash from the proprietary repo, so that we have a precise commit that identifies all build info (including Go toolchain version). Add a top-level build script demonstrating to downstream distros how to burn the right information into builds. Adjust `tailscale version` to print commit hashes when available. Fixes #841. Signed-off-by: David Anderson <danderson@tailscale.com>
This commit is contained in:
committed by
Dave Anderson
parent
a1ccaa9658
commit
54e6c3a290
+32
-4
@@ -4,6 +4,7 @@ set -eu
|
||||
|
||||
mode=$1
|
||||
describe=$2
|
||||
other=$3
|
||||
|
||||
# Git describe output overall looks like
|
||||
# MAJOR.MINOR.PATCH-NUMCOMMITS-GITHASH. Depending on the tag being
|
||||
@@ -55,6 +56,25 @@ case "$suffix" in
|
||||
;;
|
||||
esac
|
||||
|
||||
# The git hash is of the form "gCOMMITHASH". We want to replace the
|
||||
# 'g' with a 't', for "tailscale", to convey that it's specifically
|
||||
# the commit hash of the tailscale repo.
|
||||
if [ -n "$githash" ]; then
|
||||
# POSIX shell doesn't understand ${foo:1:9} syntax, gaaah.
|
||||
githash="$(echo $githash | cut -c2-10)"
|
||||
githash="t${githash}"
|
||||
fi
|
||||
|
||||
# "other" is a second git commit hash for another repository used to
|
||||
# build the Tailscale code. In practice it's either the commit hash in
|
||||
# the Android repository, or the commit hash of Tailscale's
|
||||
# proprietary repository (which pins a bunch things like build scripts
|
||||
# used and Go toolchain version).
|
||||
if [ -n "$other" ]; then
|
||||
other="$(echo $other | cut -c1-9)"
|
||||
other="-o${other}"
|
||||
fi
|
||||
|
||||
# Validate that the version data makes sense. Rules:
|
||||
# - Odd number minors are unstable. Patch must be 0, and gets
|
||||
# replaced by changecount.
|
||||
@@ -82,15 +102,23 @@ else
|
||||
# pbulic, but it's useful to be able to build it for
|
||||
# debugging. Just force the version to 0.0.0, so that we're
|
||||
# forced to rely on the git commit hash.
|
||||
major=0
|
||||
minor=0
|
||||
patch=0
|
||||
major="0"
|
||||
minor="0"
|
||||
patch="0"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$minor" -eq 1 ]; then
|
||||
# Hack for 1.1: add 1000 to the patch number, so that builds that
|
||||
# use the OSS change count order after the builds that used the
|
||||
# proprietary repo's changecount. Otherwise, the version numbers
|
||||
# would go backwards and things would be unhappy.
|
||||
patch=$((patch + 1000))
|
||||
fi
|
||||
|
||||
case "$1" in
|
||||
long)
|
||||
echo "${major}.${minor}.${patch}-${githash}"
|
||||
echo "${major}.${minor}.${patch}-${githash}${other}"
|
||||
;;
|
||||
short)
|
||||
echo "${major}.${minor}.${patch}"
|
||||
|
||||
Reference in New Issue
Block a user