[meta-virtualization][PATCH 10/15] docker-distribution: set go buildid to empty for improving reproducibility

<[email protected]>
Newsgroups org.yoctoproject.lists.meta-virtualization
Message-ID <[email protected]>
From: Changqing Li <[email protected]>

Signed-off-by: Changqing Li <[email protected]>
---
 .../docker-distribution_git.bb                |  2 +
 ...01-Makefile-remove-duplicate-ldflags.patch | 39 +++++++++++++++++++
 2 files changed, 41 insertions(+)
 create mode 100644 recipes-containers/docker-distribution/files/0001-Makefile-remove-duplicate-ldflags.patch

diff --git a/recipes-containers/docker-distribution/docker-distribution_git.bb b/recipes-containers/docker-distribution/docker-distribution_git.bb
index 5e37fe74..90ad5680 100644
--- a/recipes-containers/docker-distribution/docker-distribution_git.bb
+++ b/recipes-containers/docker-distribution/docker-distribution_git.bb
@@ -7,6 +7,7 @@ SRCREV_distribution = "76fe6170526f0a1046c340c20b041a090d8dbfc9"
 SRC_URI = "git://github.com/docker/distribution.git;branch=main;name=distribution;destsuffix=git/src/github.com/distribution/distribution/v3;protocol=https \
            file://docker-registry.service \
            file://0001-build-use-to-use-cross-go-compiler.patch \
+           file://0001-Makefile-remove-duplicate-ldflags.patch \
           "
 
 PACKAGES =+ "docker-registry"
@@ -36,6 +37,7 @@ do_compile() {
 	export CGO_LDFLAGS="${TARGET_LDFLAGS}"
 	export GO111MODULE=off
 	export GO_BUILD_FLAGS="-trimpath"
+    export EXTRA_LDFLAGS="-buildid="
 
 	cd ${S}
 
diff --git a/recipes-containers/docker-distribution/files/0001-Makefile-remove-duplicate-ldflags.patch b/recipes-containers/docker-distribution/files/0001-Makefile-remove-duplicate-ldflags.patch
new file mode 100644
index 00000000..5f01e0b8
--- /dev/null
+++ b/recipes-containers/docker-distribution/files/0001-Makefile-remove-duplicate-ldflags.patch
@@ -0,0 +1,39 @@
+From 06af6fa59fc39e15aac8f57f2c9f0b87a47ef125 Mon Sep 17 00:00:00 2001
+From: Changqing Li <[email protected]>
+Date: Sun, 4 Jan 2026 17:30:46 +0800
+Subject: [PATCH] Makefile: remove duplicate ldflags
+
+The second ldflags will override the first one in GO_LDFLAGS, and make
+user cannot set GO_LDFLAGS by passing this variable
+
+Upstream-Status: Submitted [https://github.com/distribution/distribution/pull/4762]
+
+Signed-off-by: Changqing Li <[email protected]>
+---
+ Makefile | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/Makefile b/Makefile
+index d958e75..b987bb1 100644
+--- a/Makefile
++++ b/Makefile
+@@ -60,14 +60,14 @@ version/version.go:
+ 
+ bin/%: cmd/% FORCE ## build individual binary
+ 	@echo "$(WHALE) $@${BINARY_SUFFIX}"
+-	@${GO} build -buildmode=pie ${GO_GCFLAGS} ${GO_BUILD_FLAGS} -o $@${BINARY_SUFFIX} ${GO_LDFLAGS} --ldflags '-extldflags "-Wl,-z,now" -s' ${GO_TAGS}  ./$<
++	@${GO} build -buildmode=pie ${GO_GCFLAGS} ${GO_BUILD_FLAGS} -o $@${BINARY_SUFFIX} ${GO_LDFLAGS} ${GO_TAGS}  ./$<
+ 
+ binaries: $(BINARIES) ## build binaries
+ 	@echo "$(WHALE) $@"
+ 
+ build: ## build go packages
+ 	@echo "$(WHALE) $@"
+-	@go build -buildmode=pie ${GO_GCFLAGS} ${GO_BUILD_FLAGS} ${GO_LDFLAGS} --ldflags '-extldflags "-Wl,-z,now" -s' ${GO_TAGS} $(PACKAGES)
++	@go build -buildmode=pie ${GO_GCFLAGS} ${GO_BUILD_FLAGS} ${GO_LDFLAGS} ${GO_TAGS} $(PACKAGES)
+ 
+ image: ## build docker image IMAGE_NAME=<name>
+ 	docker buildx bake --set "*.tags=${IMAGE_NAME}" image-local
+-- 
+2.34.1
+
-- 
2.34.1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.