improve reproducibility
PATCH v2 1/2 improve reproducibility
From: Changqing Li <[email protected]>
Refer [1], cgo will embeded cgo_ldflags in the intermediary output, which make content ID will be incfluenced by cgo_ldflags. '--sysroot=xxx' includes build path, which will make the binary not reproducible, these recipes can build successfully without --sysroot, so remove it
[1] https://git.openembedded.org/openembedded-core/commit/?id=1797741aad02b8bf429fac4b81e30cdda64b5448
Signed-off-by Changqing Li <[email protected]>
--- recipes-containers/containerd/containerd_git.bb | 4 ++-- recipes-containers/cri-tools/cri-tools_git.bb | 4 ++-- recipes-containers/docker-compose/docker-compose_git.bb | 6 +++--- recipes-containers/docker/docker.inc | 4 ++-- recipes-containers/kubernetes/kubernetes_git.bb | 7 +++++-- recipes-containers/nerdctl/nerdctl_git.bb | 4 ++-- recipes-containers/podman/podman_git.bb | 4 ++-- recipes-containers/runc/runc.inc | 4 ++-- 8 files changed, 20 insertions(+), 17 deletions(-)
recipes-containers/containerd/containerd_git.bb +2 -2
@@ -48,8 +48,8 @@ do_compile() { # Pass the needed cflags/ldflags so that cgo # can find the needed headers files and libraries export CGO_ENABLED="1" - export CGO_CFLAGS="${CFLAGS} --sysroot=${STAGING_DIR_TARGET}" - export CGO_LDFLAGS="${LDFLAGS} --sysroot=${STAGING_DIR_TARGET}" + export CGO_CFLAGS="${CFLAGS}" + export CGO_LDFLAGS="${LDFLAGS}" export BUILDTAGS="no_btrfs static_build netgo" export CFLAGS="${CFLAGS}" export LDFLAGS="${LDFLAGS}"
recipes-containers/cri-tools/cri-tools_git.bb +2 -2
@@ -50,8 +50,8 @@ do_compile() { export GOARCH="${TARGET_GOARCH}" # Pass the needed cflags/ldflags so that cgo can find the needed headers files and libraries export CGO_ENABLED="1" - export CGO_CFLAGS="${CFLAGS} --sysroot=${STAGING_DIR_TARGET}" - export CGO_LDFLAGS="${LDFLAGS} --sysroot=${STAGING_DIR_TARGET}" + export CGO_CFLAGS="${CFLAGS}" + export CGO_LDFLAGS="${LDFLAGS}" export CFLAGS="" export LDFLAGS="" export CC="${CC}"
recipes-containers/docker-compose/docker-compose_git.bb +3 -3
@@ -58,8 +58,8 @@ do_compile() { # Pass the needed cflags/ldflags so that cgo # can find the needed headers files and libraries export GOARCH=${TARGET_GOARCH} - export CGO_CFLAGS="${CFLAGS} --sysroot=${STAGING_DIR_TARGET}" - export CGO_LDFLAGS="${LDFLAGS} --sysroot=${STAGING_DIR_TARGET}" + export CGO_CFLAGS="${CFLAGS}" + export CGO_LDFLAGS="${LDFLAGS}" GO_LDFLAGS="-s -w -X internal.Version=${PV} -X ${COMPOSE_PKG}/internal.Version=${PV}" GO_BUILDTAGS=""
@@ -85,4 +85,4 @@ INSANE_SKIP:${PN} += "ldflags already-stripped" # the AWS dependency is 8GB, try and control the # size of the clones -BB_GIT_SHALLOW = "1" +BB_GIT_SHALLOW = "1"
recipes-containers/docker/docker.inc +2 -2
@@ -82,8 +82,8 @@ do_compile() { # can find the needed headers files and libraries export GOARCH=${TARGET_GOARCH} export CGO_ENABLED="1" - export CGO_CFLAGS="${CFLAGS} --sysroot=${STAGING_DIR_TARGET}" - export CGO_LDFLAGS="${LDFLAGS} --sysroot=${STAGING_DIR_TARGET}" + export CGO_CFLAGS="${CFLAGS}" + export CGO_LDFLAGS="${LDFLAGS}" export DOCKER_BUILDTAGS='${BUILD_TAGS} ${PACKAGECONFIG_CONFARGS}' export GO111MODULE=off
recipes-containers/kubernetes/kubernetes_git.bb +5 -2
@@ -54,6 +54,9 @@ inherit cni_networking COMPATIBLE_HOST = '(x86_64.*|arm.*|aarch64.*)-linux' +CGO_LDFLAGS ?= "${LDFLAGS}" +CGO_LDFLAGS:remove = "${DEBUG_PREFIX_MAP}" + do_compile() { export GOPATH="${S}/src/import/.gopath:${S}/src/import/vendor:${STAGING_DIR_TARGET}/${prefix}/local/go:${UNPACKDIR}/git/" cd ${S}
@@ -85,8 +88,8 @@ do_compile() { export GOARCH="${TARGET_GOARCH}" # Pass the needed cflags/ldflags so that cgo can find the needed headers files and libraries export CGO_ENABLED="1" - export CGO_CFLAGS="${CFLAGS} --sysroot=${STAGING_DIR_TARGET}" - export CGO_LDFLAGS="${LDFLAGS} --sysroot=${STAGING_DIR_TARGET}" + export CGO_CFLAGS="${CFLAGS}" + export CGO_LDFLAGS="${LDFLAGS}" export CFLAGS="" export LDFLAGS="" export CC="${CC}"
recipes-containers/nerdctl/nerdctl_git.bb +2 -2
@@ -74,8 +74,8 @@ do_compile() { # Pass the needed cflags/ldflags so that cgo # can find the needed headers files and libraries export GOARCH=${TARGET_GOARCH} - export CGO_CFLAGS="${CFLAGS} --sysroot=${STAGING_DIR_TARGET}" - export CGO_LDFLAGS="${LDFLAGS} --sysroot=${STAGING_DIR_TARGET}" + export CGO_CFLAGS="${CFLAGS}" + export CGO_LDFLAGS="${LDFLAGS}" # -trimpath removes build paths from the binary (required for reproducible builds) oe_runmake GO=${GO} BUILDTAGS="${BUILDTAGS}" GO_BUILD_FLAGS="-trimpath" binaries
recipes-containers/podman/podman_git.bb +2 -2
@@ -88,8 +88,8 @@ do_compile() { # can find the needed headers files and libraries export GOARCH=${TARGET_GOARCH} export CGO_ENABLED="1" - export CGO_CFLAGS="${CFLAGS} --sysroot=${STAGING_DIR_TARGET}" - export CGO_LDFLAGS="${LDFLAGS} --sysroot=${STAGING_DIR_TARGET}" + export CGO_CFLAGS="${CFLAGS}" + export CGO_LDFLAGS="${LDFLAGS}" # podman now builds go-md2man and requires the host/build details export NATIVE_GOOS=${BUILD_GOOS}
recipes-containers/runc/runc.inc +2 -2
@@ -58,8 +58,8 @@ do_compile() { # Pass the needed cflags/ldflags so that cgo # can find the needed headers files and libraries export CGO_ENABLED="1" - export CGO_CFLAGS="${CFLAGS} --sysroot=${STAGING_DIR_TARGET}" - export CGO_LDFLAGS="${LDFLAGS} --sysroot=${STAGING_DIR_TARGET}" + export CGO_CFLAGS="${CFLAGS}" + export CGO_LDFLAGS="${LDFLAGS}" export GO=${GO} export CFLAGS=""
Signature · 1 line
2.34.1
PATCH v2 2/2 podman: improve reproducibility
From: Changqing Li <[email protected]>
disable buildvcs to improve reproducibility
Signed-off-by Changqing Li <[email protected]>
--- recipes-containers/podman/podman_git.bb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
recipes-containers/podman/podman_git.bb +1 -1
@@ -48,7 +48,7 @@ export LDFLAGS = "" TOOLCHAIN = "gcc" # podmans Makefile expects BUILDFLAGS to be set but go.bbclass defines them in GOBUILDFLAGS -export BUILDFLAGS = "${GOBUILDFLAGS}" +export BUILDFLAGS = "${GOBUILDFLAGS} -buildvcs=false" inherit go goarch inherit container-host
Signature · 1 line
2.34.1