Skip to content

Commit 0280d06

Browse files
author
Mrunal Patel
authored
Merge pull request opencontainers#3142 from kolyshkin/1.0-reproducible-builds
[1.0] script/release.sh: make builds reproducible
2 parents ed60a98 + e2e5267 commit 0280d06

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ endif
2727
GO_BUILD := $(GO) build -trimpath $(MOD_VENDOR) $(GO_BUILDMODE) $(EXTRA_FLAGS) -tags "$(BUILDTAGS)" \
2828
-ldflags "-X main.gitCommit=$(COMMIT) -X main.version=$(VERSION) $(EXTRA_LDFLAGS)"
2929
GO_BUILD_STATIC := CGO_ENABLED=1 $(GO) build -trimpath $(MOD_VENDOR) $(EXTRA_FLAGS) -tags "$(BUILDTAGS) netgo osusergo" \
30-
-ldflags "-w -extldflags -static -X main.gitCommit=$(COMMIT) -X main.version=$(VERSION) $(EXTRA_LDFLAGS)"
30+
-ldflags "-extldflags -static -X main.gitCommit=$(COMMIT) -X main.version=$(VERSION) $(EXTRA_LDFLAGS)"
3131

3232
.DEFAULT: runc
3333

script/release.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,17 @@ function build_project() {
4343
)
4444
mv "$tarball"{,.asc} "$builddir"
4545

46+
# For reproducible builds, add these to EXTRA_LDFLAGS:
47+
# -w to disable DWARF generation;
48+
# -s to disable symbol table;
49+
# -buildid= to remove variable build id.
50+
local ldflags="-w -s -buildid="
4651
# Add -a to go build flags to make sure it links against
4752
# the provided libseccomp, not the system one (otherwise
4853
# it can reuse cached pkg-config results).
49-
make -C "$root" PKG_CONFIG_PATH="${prefix}/lib/pkgconfig" COMMIT_NO= EXTRA_FLAGS="-a" static
54+
make -C "$root" PKG_CONFIG_PATH="${prefix}/lib/pkgconfig" COMMIT_NO= EXTRA_FLAGS="-a" EXTRA_LDFLAGS="${ldflags}" static
5055
rm -rf "$prefix"
56+
strip "$root/$project"
5157
mv "$root/$project" "$1"
5258
}
5359

0 commit comments

Comments
 (0)