From 5088af68cfa6003416413fecb11613c332b22e4f Mon Sep 17 00:00:00 2001 From: David Anderson Date: Wed, 2 Jun 2021 01:05:13 -0700 Subject: [PATCH] version: remove all the redo stuff, only support embedding via go ldflags. Signed-off-by: David Anderson --- version/GENERATE.go | 9 --- version/all.do | 2 - version/clean.do | 1 - version/mkversion_test.go | 102 ---------------------------- version/ver.go.do | 9 --- version/ver.go.in | 14 ---- version/version-info.sh.do | 3 - version/version.go | 14 ++-- version/version.h.do | 9 --- version/version.sh | 130 ------------------------------------ version/version.xcconfig.do | 14 ---- version/xversion.go | 17 ----- 12 files changed, 6 insertions(+), 318 deletions(-) delete mode 100644 version/GENERATE.go delete mode 100644 version/all.do delete mode 100644 version/clean.do delete mode 100644 version/mkversion_test.go delete mode 100644 version/ver.go.do delete mode 100644 version/ver.go.in delete mode 100644 version/version-info.sh.do delete mode 100644 version/version.h.do delete mode 100755 version/version.sh delete mode 100644 version/version.xcconfig.do delete mode 100644 version/xversion.go diff --git a/version/GENERATE.go b/version/GENERATE.go deleted file mode 100644 index e4160d951..000000000 --- a/version/GENERATE.go +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright (c) 2020 Tailscale Inc & AUTHORS All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Placeholder that indicates this directory is a valid go package, -// but that redo must 'redo all' in this directory before it can -// be imported. - -package version diff --git a/version/all.do b/version/all.do deleted file mode 100644 index d0bdd8ead..000000000 --- a/version/all.do +++ /dev/null @@ -1,2 +0,0 @@ -redo-ifchange ver.go version.xcconfig version.h - diff --git a/version/clean.do b/version/clean.do deleted file mode 100644 index 23e69c8dc..000000000 --- a/version/clean.do +++ /dev/null @@ -1 +0,0 @@ -rm -f *~ .*~ describe.txt long.txt short.txt version.xcconfig ver.go version.h version version-info.sh diff --git a/version/mkversion_test.go b/version/mkversion_test.go deleted file mode 100644 index 0f000bfa8..000000000 --- a/version/mkversion_test.go +++ /dev/null @@ -1,102 +0,0 @@ -// Copyright (c) 2020 Tailscale Inc & AUTHORS All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package version - -import ( - "fmt" - "os/exec" - "runtime" - "strconv" - "strings" - "testing" - - "github.com/google/go-cmp/cmp" -) - -func mkversion(t *testing.T, gitHash, otherHash string, major, minor, patch, changeCount int) (string, bool) { - t.Helper() - bs, err := exec.Command("./version.sh", gitHash, otherHash, strconv.Itoa(major), strconv.Itoa(minor), strconv.Itoa(patch), strconv.Itoa(changeCount)).CombinedOutput() - out := strings.TrimSpace(string(bs)) - if err != nil { - return out, false - } - return out, true -} - -func TestMkversion(t *testing.T) { - if runtime.GOOS == "windows" { - t.Skip("skip test on Windows, because there is no shell to execute mkversion.sh.") - } - tests := []struct { - gitHash, otherHash string - major, minor, patch, changeCount int - want string - }{ - {"abcdef", "", 0, 98, 0, 0, ` - VERSION_SHORT="0.98.0" - VERSION_LONG="0.98.0-tabcdef" - VERSION_GIT_HASH="abcdef" - VERSION_EXTRA_HASH="" - VERSION_XCODE="100.98.0" - VERSION_WINRES="0,98,0,0"`}, - {"abcdef", "", 0, 98, 1, 0, ` - VERSION_SHORT="0.98.1" - VERSION_LONG="0.98.1-tabcdef" - VERSION_GIT_HASH="abcdef" - VERSION_EXTRA_HASH="" - VERSION_XCODE="100.98.1" - VERSION_WINRES="0,98,1,0"`}, - {"abcdef", "", 1, 1, 0, 37, ` - VERSION_SHORT="1.1.1037" - VERSION_LONG="1.1.1037-tabcdef" - VERSION_GIT_HASH="abcdef" - VERSION_EXTRA_HASH="" - VERSION_XCODE="101.1.1037" - VERSION_WINRES="1,1,1037,0"`}, - {"abcdef", "", 1, 2, 9, 0, ` - VERSION_SHORT="1.2.9" - VERSION_LONG="1.2.9-tabcdef" - VERSION_GIT_HASH="abcdef" - VERSION_EXTRA_HASH="" - VERSION_XCODE="101.2.9" - VERSION_WINRES="1,2,9,0"`}, - {"abcdef", "", 1, 15, 0, 129, ` - VERSION_SHORT="1.15.129" - VERSION_LONG="1.15.129-tabcdef" - VERSION_GIT_HASH="abcdef" - VERSION_EXTRA_HASH="" - VERSION_XCODE="101.15.129" - VERSION_WINRES="1,15,129,0"`}, - {"abcdef", "", 1, 2, 0, 17, ` - VERSION_SHORT="1.2.0" - VERSION_LONG="1.2.0-17-tabcdef" - VERSION_GIT_HASH="abcdef" - VERSION_EXTRA_HASH="" - VERSION_XCODE="101.2.0" - VERSION_WINRES="1,2,0,0"`}, - {"abcdef", "defghi", 1, 15, 0, 129, ` - VERSION_SHORT="1.15.129" - VERSION_LONG="1.15.129-tabcdef-gdefghi" - VERSION_GIT_HASH="abcdef" - VERSION_EXTRA_HASH="defghi" - VERSION_XCODE="101.15.129" - VERSION_WINRES="1,15,129,0"`}, - {"abcdef", "", 0, 99, 5, 0, ""}, // unstable, patch number not allowed - {"abcdef", "", 0, 99, 5, 123, ""}, // unstable, patch number not allowed - } - - for _, test := range tests { - want := strings.ReplaceAll(strings.TrimSpace(test.want), " ", "") - got, ok := mkversion(t, test.gitHash, test.otherHash, test.major, test.minor, test.patch, test.changeCount) - invoc := fmt.Sprintf("version.sh %s %s %d %d %d %d", test.gitHash, test.otherHash, test.major, test.minor, test.patch, test.changeCount) - if want == "" && ok { - t.Errorf("%s ok=true, want false", invoc) - continue - } - if diff := cmp.Diff(got, want); want != "" && diff != "" { - t.Errorf("%s wrong output (-got+want):\n%s", invoc, diff) - } - } -} diff --git a/version/ver.go.do b/version/ver.go.do deleted file mode 100644 index 6883fbdfc..000000000 --- a/version/ver.go.do +++ /dev/null @@ -1,9 +0,0 @@ -redo-ifchange version-info.sh ver.go.in - -. ./version-info.sh - -sed -e "s/{LONGVER}/$VERSION_LONG/g" \ - -e "s/{SHORTVER}/$VERSION_SHORT/g" \ - -e "s/{GITCOMMIT}/$VERSION_GIT_HASH/g" \ - -e "s/{EXTRAGITCOMMIT}/$VERSION_EXTRA_HASH/g" \ - $3 diff --git a/version/ver.go.in b/version/ver.go.in deleted file mode 100644 index dc5cbcecf..000000000 --- a/version/ver.go.in +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (c) 2020 Tailscale Inc & AUTHORS All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build redo - -package version - -const Long = "{LONGVER}" -const Short = "{SHORTVER}" -const LONG = Long -const SHORT = Short -const GitCommit = "{GITCOMMIT}" -const ExtraGitCommit = "{EXTRAGITCOMMIT}" diff --git a/version/version-info.sh.do b/version/version-info.sh.do deleted file mode 100644 index f6e3554e2..000000000 --- a/version/version-info.sh.do +++ /dev/null @@ -1,3 +0,0 @@ -./version.sh ../.. >$3 -redo-always -redo-stamp <$3 diff --git a/version/version.go b/version/version.go index 760308bc0..307375c13 100644 --- a/version/version.go +++ b/version/version.go @@ -2,31 +2,29 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build !redo,!xversion - // Package version provides the version that the binary was built at. package version // Long is a full version number for this build, of the form // "x.y.z-commithash", or "date.yyyymmdd" if no actual version was // provided. -const Long = "date.20210505" +var Long = "date.20210505" // Short is a short version number for this build, of the form // "x.y.z", or "date.yyyymmdd" if no actual version was provided. -const Short = Long +var Short = Long // LONG is a deprecated alias for Long. Don't use it. -const LONG = Long +var LONG = Long // SHORT is a deprecated alias for Short. Don't use it. -const SHORT = Short +var SHORT = Short // GitCommit, if non-empty, is the git commit of the // github.com/tailscale/tailscale repository at which Tailscale was // built. Its format is the one returned by `git describe --always // --exclude "*" --dirty --abbrev=200`. -const GitCommit = "" +var GitCommit = "" // ExtraGitCommit, if non-empty, is the git commit of a "supplemental" // repository at which Tailscale was built. Its format is the same as @@ -38,4 +36,4 @@ const GitCommit = "" // Android OSS repository). Together, GitCommit and ExtraGitCommit // exactly describe what repositories and commits were used in a // build. -const ExtraGitCommit = "" +var ExtraGitCommit = "" diff --git a/version/version.h.do b/version/version.h.do deleted file mode 100644 index 7068f08e3..000000000 --- a/version/version.h.do +++ /dev/null @@ -1,9 +0,0 @@ -redo-ifchange version-info.sh - -. ./version-info.sh - -cat >$3 <&2 - exit 1 - else - extra_hash="$extra_hash_or_dir" - fi - - # Load the base version and optional corresponding git hash - # from the VERSION file. If there is no git hash in the file, - # we use the hash of the last change to the VERSION file. - version_file="$(dirname $0)/../VERSION.txt" - IFS=".$IFS" read -r major minor patch base_git_hash <"$version_file" - if [ -z "$base_git_hash" ]; then - base_git_hash=$(git rev-list --max-count=1 HEAD -- "$version_file") - fi - - git_hash=$(git_hash_dirty . HEAD) - # The number of extra commits between the release base to git_hash. - change_count=$(git rev-list --count HEAD "^$base_git_hash") - ;; - 6) - # Test mode: rather than run git commands and whatnot, take in - # all the version pieces as arguments. - git_hash=$1 - extra_hash=$2 - major=$3 - minor=$4 - patch=$5 - change_count=$6 - ;; - *) - echo "Usage: $0 [extra-git-commitid-or-dir]" - exit 1 -esac - -# Shortened versions of git hashes, so that they fit neatly into an -# "elongated" but still human-readable version number. -short_git_hash=$(echo "$git_hash" | cut -c1-9) -short_extra_hash=$(echo "$extra_hash" | cut -c1-9) - -# Convert major/minor/patch/change_count into an adjusted -# major/minor/patch. This block is where all our policies on -# versioning are. -if expr "$minor" : "[0-9]*[13579]$" >/dev/null; then - # Odd minor numbers are unstable builds. - if [ "$patch" != "0" ]; then - # This is a fatal error, because a non-zero patch number - # indicates that we created an unstable VERSION.txt in violation - # of our versioning policy, and we want to blow up loudly to - # get that fixed. - echo "Unstable release $major.$minor.$patch has a non-zero patch number, which is not allowed" >&2 - exit 1 - fi - patch="$change_count" - change_suffix="" -elif [ "$change_count" != "0" ]; then - # Even minor numbers are stable builds, but stable builds are - # supposed to have a zero change count. Therefore, we're currently - # describing a commit that's on a release branch, but hasn't been - # tagged as a patch release yet. - # - # We used to change the version number to 0.0.0 in that case, but that - # caused some features to get disabled due to the low version number. - # Instead, add yet another suffix to the version number, with a change - # count. - change_suffix="-$change_count" -else - # Even minor number with no extra changes. - change_suffix="" -fi - -# Hack for 1.1: add 1000 to the patch number. We switched from using -# the proprietary repo's change_count over to using the OSS repo's -# change_count, and this was necessary to avoid a backwards jump in -# release numbers. -if [ "$major.$minor" = "1.1" ]; then - patch="$((patch + 1000))" -fi - -# At this point, the version number correctly reflects our -# policies. All that remains is to output the various vars that other -# code can use to embed version data. -if [ -z "$extra_hash" ]; then - long_version_suffix="$change_suffix-t$short_git_hash" -else - long_version_suffix="$change_suffix-t$short_git_hash-g$short_extra_hash" -fi -cat < 100.98.3 -echo "VERSION_ID = $VERSION_XCODE" diff --git a/version/xversion.go b/version/xversion.go deleted file mode 100644 index 05b66dc20..000000000 --- a/version/xversion.go +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (c) 2020 Tailscale Inc & AUTHORS All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build !redo,xversion - -package version - -// Replaced at build time with the Go linker flag -X. See -// ../build_dist.sh for example usage, and version.go for field -// documentation. -var Long string = "" -var Short string = "" -var LONG = Long -var SHORT = Short -var GitCommit = "" -var ExtraGitCommit = ""