oci-image-tools: fix TMPDIR references

The structure of the source code layout that was used by
this recipe required symlinking subirectories of the source
into a location that would be searched by go. While this
fixes the build, and produces a working binary, go stores
the location into the binary itself. Those stored paths
reference the build directory, making the result not
reproducible.

With this change, we create an alternate structure that
doesn't require symlinking and allows go to find the
components during build. This results in a simpler recipe
and binaries without TMPDIR references.

Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
This commit is contained in:
Bruce Ashfield 2022-09-14 22:01:22 -04:00
parent 1242b97f7f
commit 79ff2a5b00
3 changed files with 13 additions and 22 deletions

View File

@ -12,10 +12,10 @@ Signed-off-by: Bruce Ashfield <bruce.ashfield@windriver.com>
image/config.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/import/image/config.go b/src/import/image/config.go
diff --git a/image/config.go b/image/config.go
index d28b1bc4fe5f..37dfd1f14ef7 100644
--- a/src/import/image/config.go
+++ b/src/import/image/config.go
--- a/image/config.go
+++ b/image/config.go
@@ -106,7 +106,7 @@ func (c *config) runtimeSpec(rootfs string) (*specs.Spec, error) {
s.Process.User.UID = uint32(uid)
s.Process.User.GID = uint32(gid)

View File

@ -13,10 +13,10 @@ Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/import/Makefile b/src/import/Makefile
diff --git a/Makefile b/Makefile
index bacb341..1bfe021 100644
--- a/src/import/Makefile
+++ b/src/import/Makefile
--- a/Makefile
+++ b/Makefile
@@ -27,7 +27,7 @@ check-license:
.PHONY: tool

View File

@ -1,7 +1,7 @@
HOMEPAGE = "https://github.com/opencontainers/image-tools"
SUMMARY = "A collection of tools for working with the OCI image format specification"
LICENSE = "Apache-2.0"
LIC_FILES_CHKSUM = "file://src/import/LICENSE;md5=e3fc50a88d0a364313df4b21ef20c29e"
LIC_FILES_CHKSUM = "file://LICENSE;md5=e3fc50a88d0a364313df4b21ef20c29e"
DEPENDS = "\
oci-image-spec \
@ -12,7 +12,7 @@ DEPENDS = "\
spf13-pflag \
"
SRC_URI = "git://github.com/opencontainers/image-tools.git;branch=master;protocol=https \
SRC_URI = "git://github.com/opencontainers/image-tools.git;branch=master;protocol=https;destsuffix=git/src/github.com/opencontainers/image-tools \
file://0001-config-make-Config.User-mapping-errors-a-warning.patch \
file://0001-tool-respect-GO-and-GOBUILDFLAGS-when-building.patch"
@ -27,21 +27,12 @@ inherit go
# go package.
EXTRA_OEMAKE="BUILDTAGS=''"
S = "${WORKDIR}/git/src/github.com/opencontainers/image-tools"
do_compile() {
export GOARCH="${TARGET_GOARCH}"
export GOROOT="${STAGING_LIBDIR}/go"
# Setup vendor directory so that it can be used in GOPATH.
#
# Go looks in a src directory under any directory in GOPATH but riddler
# uses 'vendor' instead of 'vendor/src'. We can fix this with a symlink.
#
# We also need to link in the ipallocator directory as that is not under
# a src directory.
ln -sfn . "${S}/src/import/vendor/src"
mkdir -p "${S}/src/import/vendor/src/github.com/opencontainers/image-tools/"
ln -sfn "${S}/src/import/image" "${S}/src/import/vendor/src/github.com/opencontainers/image-tools/image"
ln -sfn "${S}/src/import/version" "${S}/src/import/vendor/src/github.com/opencontainers/image-tools/version"
export GOPATH="${S}/src/import/vendor"
export GOPATH="${WORKDIR}/git/"
# Pass the needed cflags/ldflags so that cgo
# can find the needed headers files and libraries
@ -54,14 +45,14 @@ do_compile() {
export GOBUILDFLAGS="-trimpath"
cd ${S}/src/import
cd ${S}
oe_runmake tool
}
do_install() {
install -d ${D}/${sbindir}
install ${S}/src/import/oci-image-tool ${D}/${sbindir}/
install ${S}/oci-image-tool ${D}/${sbindir}/
}
INSANE_SKIP:${PN} += "ldflags textrel"