From a8756abcce9d6ebc486e14b4fa454e910e357d26 Mon Sep 17 00:00:00 2001 From: Alex Demidoff Date: Tue, 5 Nov 2024 23:49:53 +0300 Subject: [PATCH] PMM-12899 pass NO_VCS parameter to go build --- admin/Makefile | 8 ++++++-- agent/Makefile | 8 ++++++-- build/local/build | 2 +- build/scripts/build-client-binary | 2 +- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/admin/Makefile b/admin/Makefile index f6c12416e1..0d29552f70 100644 --- a/admin/Makefile +++ b/admin/Makefile @@ -11,6 +11,10 @@ PMM_RELEASE_VERSION ?= $(shell git describe --always --dirty | cut -b2-) PMM_RELEASE_TIMESTAMP ?= $(shell date '+%s') PMM_RELEASE_FULLCOMMIT ?= $(shell git rev-parse HEAD) PMM_RELEASE_BRANCH ?= $(shell git describe --always --contains --all) + +ifdef NO_VCS + NO_VCS := -buildvcs=false +endif ifeq ($(GOBIN),) GOBIN := $(shell go env GOPATH)/bin endif @@ -31,8 +35,8 @@ clean: ## Remove generated files find . -name *_reform.go -delete release: ## Build pmm-admin release binary - env CGO_ENABLED=0 go build -v $(LD_FLAGS) -o $(PMM_RELEASE_PATH)/pmm-admin ./cmd/pmm-admin/ - env CGO_ENABLED=0 go build -v $(LD_FLAGS) -o $(PMM_RELEASE_PATH)/pmm ./cmd/pmm/ + env CGO_ENABLED=0 go build -v $(NO_VCS) $(LD_FLAGS) -o $(PMM_RELEASE_PATH)/pmm-admin ./cmd/pmm-admin/ + env CGO_ENABLED=0 go build -v $(NO_VCS) $(LD_FLAGS) -o $(PMM_RELEASE_PATH)/pmm ./cmd/pmm/ install: ## Install pmm & pmm-admin binary go build -v $(LD_FLAGS) -o $(GOBIN)/pmm-admin ./cmd/pmm-admin/ diff --git a/agent/Makefile b/agent/Makefile index 2507f82fcb..6c1e863b6a 100644 --- a/agent/Makefile +++ b/agent/Makefile @@ -12,6 +12,10 @@ PMM_RELEASE_TIMESTAMP ?= $(shell date '+%s') PMM_RELEASE_FULLCOMMIT ?= $(shell git rev-parse HEAD) PMM_RELEASE_BRANCH ?= $(shell git describe --always --contains --all) PMM_DEV_SERVER_PORT ?= 8443 + +ifdef NO_VCS + NO_VCS := -buildvcs=false +endif ifeq ($(GOBIN),) GOBIN := $(shell go env GOPATH)/bin endif @@ -25,8 +29,8 @@ VERSION_FLAGS = -X 'github.com/percona/pmm/version.ProjectName=pmm-agent' \ -X 'github.com/percona/pmm/version.Branch=$(PMM_RELEASE_BRANCH)' release: ## Build static pmm-agent release binary (Linux only) - env CGO_ENABLED=1 go build -v -ldflags "-extldflags '-static' $(VERSION_FLAGS)" -tags 'osusergo netgo static_build' -o $(PMM_RELEASE_PATH)/pmm-agent - go build -v -ldflags "-extldflags '-static' $(VERSION_FLAGS)" -tags 'osusergo netgo static_build' -o $(PMM_RELEASE_PATH)/pmm-agent-entrypoint ./cmd/pmm-agent-entrypoint + env CGO_ENABLED=1 go build -v $(NO_VCS) -ldflags "-extldflags '-static' $(VERSION_FLAGS)" -tags 'osusergo netgo static_build' -o $(PMM_RELEASE_PATH)/pmm-agent + go build -v $(NO_VCS) -ldflags "-extldflags '-static' $(VERSION_FLAGS)" -tags 'osusergo netgo static_build' -o $(PMM_RELEASE_PATH)/pmm-agent-entrypoint ./cmd/pmm-agent-entrypoint $(PMM_RELEASE_PATH)/pmm-agent --version ldd $(PMM_RELEASE_PATH)/pmm-agent 2>&1 | grep -Fq 'not a dynamic executable' diff --git a/build/local/build b/build/local/build index 4e51fcc4c4..2c5b549206 100755 --- a/build/local/build +++ b/build/local/build @@ -352,7 +352,7 @@ main() { run_build_script build-client-rpm fi - # Building client docker image takes 17s + # Building client docker image takes from 17s (using docker cache) to 43s (no docker cache). export DOCKER_CLIENT_TAG=percona/pmm-client:${GIT_COMMIT} if [ "$NO_CLIENT_DOCKER" -eq 0 ]; then run_build_script build-client-docker diff --git a/build/scripts/build-client-binary b/build/scripts/build-client-binary index d2dbaac338..8706136537 100755 --- a/build/scripts/build-client-binary +++ b/build/scripts/build-client-binary @@ -39,7 +39,7 @@ gobuild_component() { return fi if [[ ${component} =~ pmm-admin|pmm-agent ]]; then - build_command="cd /tmp/go/src/${extract_path}/${component_path} && make release" + build_command="cd /tmp/go/src/${extract_path}/${component_path} && NO_VCS=1 make release" elif [ ${component} = 'mongodb_exporter' ]; then build_command="cd /tmp/go/src/${extract_path} && make build" elif [[ ${component} =~ node_exporter|mysqld_exporter|proxysql_exporter|rds_exporter|postgres_exporter|azure_metrics_exporter ]]; then