skopeo: reprodicibility enable trimpath and strip

Skopeo is throwing TMPDIR QA warnings due to paths being built
into the binaries. We fix this by creating a new variable to
pass -trimpath into the build, and also by defining the linker
flags -w -s to strip source/path information from the binaries.

Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
This commit is contained in:
Bruce Ashfield 2022-09-13 12:56:27 -04:00
parent 7cea149bb0
commit f6f4f2c1c3
2 changed files with 33 additions and 1 deletions

View File

@ -0,0 +1,29 @@
From 7037cb27718fe23541885684fdacec9c52ee0e30 Mon Sep 17 00:00:00 2001
From: Bruce Ashfield <bruce.ashfield@gmail.com>
Date: Tue, 13 Sep 2022 11:55:45 -0400
Subject: [PATCH] makefile: add GOBUILDFLAGS to go build call
We may need to specify things like -trimpath, so add $(GOBUILDFLAGS)
to allow them to be passed from the recipe to the Makefile.
Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
---
src/import/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/import/Makefile b/src/import/Makefile
index 58ed8d3a..990edd1d 100644
--- a/src/import/Makefile
+++ b/src/import/Makefile
@@ -136,7 +136,7 @@ binary: cmd/skopeo
# Build w/o using containers
.PHONY: bin/skopeo
bin/skopeo:
- $(GO) build $(MOD_VENDOR) ${GO_DYN_FLAGS} ${SKOPEO_LDFLAGS} -gcflags "$(GOGCFLAGS)" -tags "$(BUILDTAGS)" -o $@ ./cmd/skopeo
+ $(GO) build $(GOBUILDFLAGS) $(MOD_VENDOR) ${GO_DYN_FLAGS} ${SKOPEO_LDFLAGS} -gcflags "$(GOGCFLAGS)" -tags "$(BUILDTAGS)" -o $@ ./cmd/skopeo
bin/skopeo.%:
GOOS=$(word 2,$(subst ., ,$@)) GOARCH=$(word 3,$(subst ., ,$@)) $(GO) build $(MOD_VENDOR) ${SKOPEO_LDFLAGS} -tags "containers_image_openpgp $(BUILDTAGS)" -o $@ ./cmd/skopeo
local-cross: bin/skopeo.darwin.amd64 bin/skopeo.linux.arm bin/skopeo.linux.arm64 bin/skopeo.windows.386.exe bin/skopeo.windows.amd64.exe
--
2.19.1

View File

@ -23,6 +23,7 @@ SRC_URI = " \
git://github.com/containers/skopeo;branch=main;protocol=https \
file://storage.conf \
file://registries.conf \
file://0001-makefile-add-GOBUILDFLAGS-to-go-build-call.patch \
"
SRCREV = "b95e081162382f9a28f400bee10046ce72b957fe"
@ -70,6 +71,8 @@ do_compile() {
cd ${S}/src/import
export GO111MODULE=off
export GOBUILDFLAGS="-trimpath"
export EXTRA_LDFLAGS="-s -w"
oe_runmake bin/skopeo
}
@ -98,6 +101,6 @@ do_install:append:class-nativesdk() {
--policy ${sysconfdir}/containers/policy.json
}
INSANE_SKIP:${PN} += "ldflags"
INSANE_SKIP:${PN} += "ldflags already-stripped"
BBCLASSEXTEND = "native nativesdk"