Skip to content

Commit

Permalink
Adhere to SOURCE_DATE_EPOCH specification to fix reproducibility
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
ohnatiuk1 committed Aug 21, 2024
1 parent b2bdade commit d69fb96
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down

0 comments on commit d69fb96

Please sign in to comment.