build_dist.sh: add a command to output the shell vars.

Some downstream distros eval'd version/version.sh to get at the shell variables
within their own build process. They can now `./build_dist.sh shellvars` to get
those.

Fixes #2058.

Signed-off-by: David Anderson <dave@natulte.net>
This commit is contained in:
David Anderson 2021-06-05 19:02:12 -07:00
parent e92fd19484
commit dfb1385fcc

View File

@ -30,9 +30,17 @@ else
fi fi
long_suffix="$change_suffix-t$short_hash" long_suffix="$change_suffix-t$short_hash"
echo $change_count
SHORT="$major.$minor.$patch" SHORT="$major.$minor.$patch"
LONG="${SHORT}$long_suffix" LONG="${SHORT}$long_suffix"
GIT_HASH="$git_hash" GIT_HASH="$git_hash"
if [ "$1" = "shellvars" ]; then
cat <<EOF
VERSION_SHORT="$SHORT"
VERSION_LONG="$LONG"
VERSION_GIT_HASH="$GIT_HASH"
EOF
exit 0
fi
exec go build -ldflags "-X tailscale.com/version.Long=${LONG} -X tailscale.com/version.Short=${SHORT} -X tailscale.com/version.GitCommit=${GIT_HASH}" "$@" exec go build -ldflags "-X tailscale.com/version.Long=${LONG} -X tailscale.com/version.Short=${SHORT} -X tailscale.com/version.GitCommit=${GIT_HASH}" "$@"