!7 [sync] PR-6: Fix tidb-server -V 'Release Version' not displayed

From: @openeuler-sync-bot
Reviewed-by: @zhengzhenyu
Signed-off-by: @zhengzhenyu
This commit is contained in:
openeuler-ci-bot 2021-10-14 02:33:56 +00:00 committed by Gitee
commit 684c7c0487
2 changed files with 47 additions and 1 deletions

View File

@ -0,0 +1,42 @@
From 3c62ba67a1cbb55636567909f6389e89fe6db7e8 Mon Sep 17 00:00:00 2001
From: baizg1107 <preloyalwhite@163.com>
Date: Mon, 11 Oct 2021 11:04:49 +0800
Subject: [PATCH] fix release version
---
Makefile | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/Makefile b/Makefile
index c36dc47..24ec57e 100644
--- a/Makefile
+++ b/Makefile
@@ -32,6 +32,10 @@ GOTEST := $(GO) test -p $(P)
OVERALLS := GO111MODULE=on overalls
STATICCHECK := GO111MODULE=on staticcheck
TIDB_EDITION ?= Community
+RELEASE_VERSION ?= v4.0.14
+TIDB_BUILDTS ?= None
+TIDB_GITHASH ?= None
+TIDB_GITBRANCH ?= None
# Ensure TIDB_EDITION is set to Community or Enterprise before running build process.
ifneq "$(TIDB_EDITION)" "Community"
@@ -51,10 +55,10 @@ FILES := $$(find $$($(PACKAGE_DIRECTORIES)) -name "*.go")
FAILPOINT_ENABLE := $$(find $$PWD/ -type d | grep -vE "(\.git|tools)" | xargs tools/bin/failpoint-ctl enable)
FAILPOINT_DISABLE := $$(find $$PWD/ -type d | grep -vE "(\.git|tools)" | xargs tools/bin/failpoint-ctl disable)
-LDFLAGS += -X "github.com/pingcap/parser/mysql.TiDBReleaseVersion=$(shell git describe --tags --dirty --always)"
-LDFLAGS += -X "github.com/pingcap/tidb/util/versioninfo.TiDBBuildTS=$(shell date -u '+%Y-%m-%d %I:%M:%S')"
-LDFLAGS += -X "github.com/pingcap/tidb/util/versioninfo.TiDBGitHash=$(shell git rev-parse HEAD)"
-LDFLAGS += -X "github.com/pingcap/tidb/util/versioninfo.TiDBGitBranch=$(shell git rev-parse --abbrev-ref HEAD)"
+LDFLAGS += -X "github.com/pingcap/parser/mysql.TiDBReleaseVersion=$(RELEASE_VERSION)"
+LDFLAGS += -X "github.com/pingcap/tidb/util/versioninfo.TiDBBuildTS=$(TIDB_BUILDTS)"
+LDFLAGS += -X "github.com/pingcap/tidb/util/versioninfo.TiDBGitHash=$(TIDB_GITHASH)"
+LDFLAGS += -X "github.com/pingcap/tidb/util/versioninfo.TiDBGitBranch=$(TIDB_GITBRANCH)"
LDFLAGS += -X "github.com/pingcap/tidb/util/versioninfo.TiDBEdition=$(TIDB_EDITION)"
TEST_LDFLAGS = -X "github.com/pingcap/tidb/config.checkBeforeDropLDFlag=1"
--
2.27.0

View File

@ -1,6 +1,6 @@
Name: tidb
Version: 4.0.14
Release: 2
Release: 3
Summary: TiDB is a distributed NewSQL database compatible with MySQL protocol
License: QL and STRUTIL
@ -11,6 +11,7 @@ Source2: tidb-server.toml
#Go mod for non-extranet environments
Source3: vendor.tar.gz
Patch0: Set-GOFLAG-to-go-mod-vendor.patch
Patch1: 0001-fix-release-version.patch
BuildRequires: golang >= 1.10.0
Requires(pre): shadow-utils
Requires(post): systemd
@ -68,6 +69,9 @@ exit 0
%license LICENSE
%changelog
* Mon Oct 11 2021 baizhonggui <baizhonggui@huawei.com> - 4.0.14-3
- Fix commond tidb-server -V 'Release Version' not displayed
* Thu Sep 02 2021 sunguoshuai <sunguoshuai@huawei.com> - 4.0.14-2
- Fix tidb-server.service start failure