meta-virtualization/recipes-networking/netns/netns_git.bb
Mark Asselstine fb524ca5a2 netns: change build target to 'build' instead of 'static'
Attempting to build for x86-64 will result in an error:
   cannot find package runtime/cgo (using -importcfg)
   ...go/pkg/tool/linux_amd64/link: cannot open file : open : no such file or directory

As a workaround we switch the build target to 'build' which results in
a slightly smaller executable but does mean that several dynamic
libraries are required to run the generated executable. This shouldn't
be a problem as the build system will ensure the libraries are present
on images where the executable will be included. This change only
means the executable can't be copied as a single entity to a different
machine and run.

We do also patch the Makefile to allow the 'static' target to build
successfully and in the patch commit log we describe the issue in full
(at least in as much detail as we currently have on the issue). But
since the issue isn't fully understood we don't recommend the 'static'
build to be used at this time, thus default to the 'build' target.

Signed-off-by: Mark Asselstine <mark.asselstine@windriver.com>
Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
2019-03-20 14:42:42 -04:00

55 lines
1.9 KiB
BlitzBasic

HOMEPAGE = "https://github.com/jfrazelle/netns"
SUMMARY = "Runc hook for setting up default bridge networking."
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://src/import/LICENSE;md5=48ef0979a2bcc3fae14ff30b8a7f5dbf"
SRC_URI = "git://github.com/genuinetools/netns;branch=master \
file://0001-Allow-selection-of-go-compiler.patch \
file://Makefile-force-rebuilding-all-packages-to-avoid-cgo.patch \
"
SRCREV = "0da6ab0997707024debe68c91e940c9168041bf8"
PV = "0.4.0"
GO_IMPORT = "import"
S = "${WORKDIR}/git"
inherit goarch
inherit go
EXTRA_OEMAKE = "GO='${GO}'"
do_compile() {
export GOARCH="${TARGET_GOARCH}"
export GOROOT="${STAGING_LIBDIR_NATIVE}/${TARGET_SYS}/go"
# Setup vendor directory so that it can be used in GOPATH.
#
# Go looks in a src directory under any directory in GOPATH but netns
# uses 'vendor' instead of 'vendor/src'. We can fix this with a symlink.
#
# We also need to link in the ipallocator and version directories as
# they are not under the src directory.
ln -sfn . "${S}/src/import/vendor/src"
mkdir -p "${S}/src/import/vendor/src/github.com/genuinetools/netns"
ln -sfn "${S}/src/import/ipallocator" "${S}/src/import/vendor/src/github.com/genuinetools/netns/ipallocator"
ln -sfn "${S}/src/import/version" "${S}/src/import/vendor/src/github.com/genuinetools/netns/version"
export GOPATH="${S}/src/import/vendor"
# Pass the needed cflags/ldflags so that cgo
# can find the needed headers files and libraries
export CGO_ENABLED="1"
export CFLAGS=""
export LDFLAGS=""
export CGO_CFLAGS="${BUILDSDK_CFLAGS} --sysroot=${STAGING_DIR_TARGET}"
export CGO_LDFLAGS="${BUILDSDK_LDFLAGS} --sysroot=${STAGING_DIR_TARGET}"
cd ${S}/src/import
# Static builds work but are not recommended. See Makefile*cgo patch.
#oe_runmake static
oe_runmake build
}
do_install() {
install -d ${D}/${sbindir}
install ${S}/src/import/netns ${D}/${sbindir}/netns
}