From 1242b97f7f488180554dabc65a1d5c5e140a5876 Mon Sep 17 00:00:00 2001 From: Bruce Ashfield Date: Wed, 14 Sep 2022 20:34:11 -0400 Subject: oci-runtime-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 --- .../files/0001-build-use-for-cross-compiler.patch | 8 +++---- .../oci-runtime-tools/oci-runtime-tools_git.bb | 27 ++++++++-------------- 2 files changed, 13 insertions(+), 22 deletions(-) diff --git a/recipes-containers/oci-runtime-tools/files/0001-build-use-for-cross-compiler.patch b/recipes-containers/oci-runtime-tools/files/0001-build-use-for-cross-compiler.patch index 98194265..1c4addab 100644 --- a/recipes-containers/oci-runtime-tools/files/0001-build-use-for-cross-compiler.patch +++ b/recipes-containers/oci-runtime-tools/files/0001-build-use-for-cross-compiler.patch @@ -5,13 +5,13 @@ Subject: [PATCH] build: use for cross compiler Signed-off-by: Bruce Ashfield --- - a/src/import/Makefile | 4 ++-- + a/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -Index: oci-runtime-tools-0.9.0+gitAUTOINC+0105384f68/src/import/Makefile +Index: oci-runtime-tools-0.9.0+gitAUTOINC+0105384f68/Makefile =================================================================== ---- oci-runtime-tools-0.9.0+gitAUTOINC+0105384f68.orig/src/import/Makefile -+++ oci-runtime-tools-0.9.0+gitAUTOINC+0105384f68/src/import/Makefile +--- oci-runtime-tools-0.9.0+gitAUTOINC+0105384f68.orig/Makefile ++++ oci-runtime-tools-0.9.0+gitAUTOINC+0105384f68/Makefile @@ -13,11 +13,11 @@ all: tool runtimetest validation-executables diff --git a/recipes-containers/oci-runtime-tools/oci-runtime-tools_git.bb b/recipes-containers/oci-runtime-tools/oci-runtime-tools_git.bb index 0ba0b56c..8eb272ae 100644 --- a/recipes-containers/oci-runtime-tools/oci-runtime-tools_git.bb +++ b/recipes-containers/oci-runtime-tools/oci-runtime-tools_git.bb @@ -1,9 +1,9 @@ HOMEPAGE = "https://github.com/opencontainers/runtime-tools" SUMMARY = "oci-runtime-tool is a collection of tools for working with the OCI runtime specification" LICENSE = "GPL-2.0-only" -LIC_FILES_CHKSUM = "file://src/import/LICENSE;md5=b355a61a394a504dacde901c958f662c" +LIC_FILES_CHKSUM = "file://LICENSE;md5=b355a61a394a504dacde901c958f662c" -SRC_URI = "git://github.com/opencontainers/runtime-tools.git;branch=master;protocol=https \ +SRC_URI = "git://github.com/opencontainers/runtime-tools.git;branch=master;protocol=https;destsuffix=git/src/github.com/opencontainers/runtime-tools \ file://0001-build-use-for-cross-compiler.patch \ " @@ -16,10 +16,12 @@ INSANE_SKIP:${PN} += "ldflags textrel" inherit goarch inherit go +S = "${WORKDIR}/git/src/github.com/opencontainers/runtime-tools" + do_compile() { export GOARCH="${TARGET_GOARCH}" + export GOPATH="${WORKDIR}/git/" export GOROOT="${STAGING_LIBDIR}/go" - export GOPATH="${S}/src/import:${S}/src/import/vendor" # Pass the needed cflags/ldflags so that cgo # can find the needed headers files and libraries @@ -29,34 +31,23 @@ do_compile() { export CGO_CFLAGS="${TARGET_CFLAGS}" export CGO_LDFLAGS="${TARGET_LDFLAGS}" export GO111MODULE=off + export GOFLAGS="-mod=vendor" # fixes: # cannot find package runtime/cgo (using -importcfg) # ... recipe-sysroot-native/usr/lib/aarch64-poky-linux/go/pkg/tool/linux_amd64/link: # cannot open file : open : no such file or directory - export GO_BUILD_FLAGS="-a -pkgdir dontusecurrentpkgs" + # export GO_BUILD_FLAGS="-a -pkgdir dontusecurrentpkgs" export EXTRA_FLAGS="-trimpath" - # link fixups for compilation - rm -f ${S}/src/import/vendor/src - ln -sf ./ ${S}/src/import/vendor/src - mkdir -p ${S}/src/import/vendor/github.com/opencontainers/runtime-tools - ln -sf ../../../../generate ${S}/src/import/vendor/github.com/opencontainers/runtime-tools/generate - ln -sf ../../../../validate ${S}/src/import/vendor/github.com/opencontainers/runtime-tools/validate - ln -sf ../../../../cmd ${S}/src/import/vendor/github.com/opencontainers/runtime-tools/cmd - ln -sf ../../../../error ${S}/src/import/vendor/github.com/opencontainers/runtime-tools/error - ln -sf ../../../../specerror ${S}/src/import/vendor/github.com/opencontainers/runtime-tools/specerror - ln -sf ../../../../cgroups ${S}/src/import/vendor/github.com/opencontainers/runtime-tools/cgroups - ln -sf ../../../../filepath ${S}/src/import/vendor/github.com/opencontainers/runtime-tools/filepath - ln -sf ../../../../validation ${S}/src/import/vendor/github.com/opencontainers/runtime-tools/validation - cd ${S}/src/import + cd ${S} oe_runmake tool } do_install() { install -d ${D}/${sbindir} - install ${S}/src/import/oci-runtime-tool ${D}/${sbindir}/oci-runtime-tool + install ${S}/oci-runtime-tool ${D}/${sbindir}/oci-runtime-tool } deltask compile_ptest_base -- cgit v1.2.3-54-g00ecf