From 64a044d50cf3f4410dc3044d01dce739dc72e425 Mon Sep 17 00:00:00 2001 From: Oleksandr Hnatiuk Date: Wed, 21 Aug 2024 02:26:31 -0700 Subject: [PATCH] Adhere to SOURCE_DATE_EPOCH specification to fix reproducibility Reproducible builds are ones where the same source code input produces the same binary output. This helps with caching, authentication of binaries, etc. SOURCE_DATE_EPOCH is a standardised variable which allows the build setup to specify date and time to be used in place of "current time" such that it will not change unless the source code changes. See: https://reproducible-builds.org/specs/source-date-epoch/ https://reproducible-builds.org/docs/source-date-epoch/ Signed-off-by: Oleksandr Hnatiuk --- Makefile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Makefile b/Makefile index 21b2fe7d88..90f6583da5 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,12 @@ ifndef CWAGENT_BUILD_MODE CWAGENT_BUILD_MODE=default endif +ifdef SOURCE_DATE_EPOCH +BUILD := $(shell date -u -d @$(SOURCE_DATE_EPOCH) +"%Y-%m-%dT%H:%M:%SZ") +else BUILD := $(shell date -u +"%Y-%m-%dT%H:%M:%SZ") +endif + LDFLAGS = -s -w LDFLAGS += -X github.com/aws/amazon-cloudwatch-agent/cfg/agentinfo.VersionStr=${VERSION} LDFLAGS += -X github.com/aws/amazon-cloudwatch-agent/cfg/agentinfo.BuildStr=${BUILD}