From 3d20fd20d0d631e1ccb3d97b7d22bbab22e12a99 Mon Sep 17 00:00:00 2001 From: Lapo Luchini Date: Sat, 10 Apr 2021 14:46:53 +0200 Subject: [PATCH] Allow specifying build date from a variable (#1200) Just like the existing infrastructure for `BUILDINFO_TAG`, this can ease the production of [reproducible builds](https://wiki.freebsd.org/ReproducibleBuilds). (e.g. in FreeBSD the date the port was committed is used at build time, not the actual build time, so that an identical port produced at different times produces an identical executable) --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 6daefb453..67d6767de 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,6 @@ PKG_PREFIX := github.com/VictoriaMetrics/VictoriaMetrics +DATEINFO_TAG ?= $(shell date -u +'%Y%m%d-%H%M%S') BUILDINFO_TAG ?= $(shell echo $$(git describe --long --all | tr '/' '-')$$( \ git diff-index --quiet HEAD -- || echo '-dirty-'$$(git diff-index -u HEAD | openssl sha1 | cut -c 10-17))) @@ -8,7 +9,7 @@ ifeq ($(PKG_TAG),) PKG_TAG := $(BUILDINFO_TAG) endif -GO_BUILDINFO = -X '$(PKG_PREFIX)/lib/buildinfo.Version=$(APP_NAME)-$(shell date -u +'%Y%m%d-%H%M%S')-$(BUILDINFO_TAG)' +GO_BUILDINFO = -X '$(PKG_PREFIX)/lib/buildinfo.Version=$(APP_NAME)-$(DATEINFO_TAG)-$(BUILDINFO_TAG)' .PHONY: $(MAKECMDGOALS)