[OE-core] [PATCH] [RFC] go.bbclass: install dependencies under $GOPATH instead of $GOROOT
Damien Riegel
damien.riegel at gmail.com
Wed Dec 19 17:50:40 UTC 2018
To package a go application in Yocto, one needs to also package its
dependencies to keep the build reproducible and under control. The
default install task of the go class puts the source in ${libdir}/go/src.
${libdir}/go/src is where the standard go packages resides, aka $GOROOT.
When a go package has dependencies on other go packages, they must be
located under $GOPATH, otherwise errors like this one may happen:
Non-standard package <packagename> in standard package <packagename>
This point of this patch is to trigger a discussion on how this issue
can be tackled in Yocto. Following code is working but should not be
considered for inclusion.
Signed-off-by: Damien Riegel <damien.riegel at gmail.com>
---
meta/classes/go.bbclass | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/meta/classes/go.bbclass b/meta/classes/go.bbclass
index 167d02e3fa..c0ed3211cd 100644
--- a/meta/classes/go.bbclass
+++ b/meta/classes/go.bbclass
@@ -111,9 +111,9 @@ do_compile_ptest_base() {
do_compile_ptest_base[dirs] =+ "${GOTMPDIR}"
go_do_install() {
- install -d ${D}${libdir}/go/src/${GO_IMPORT}
+ install -d ${D}/gopath/src/${GO_IMPORT} ${D}${libdir}/go
tar -C ${S}/src/${GO_IMPORT} -cf - --exclude-vcs --exclude '*.test' --exclude 'testdata' . | \
- tar -C ${D}${libdir}/go/src/${GO_IMPORT} --no-same-owner -xf -
+ tar -C ${D}/gopath/src/${GO_IMPORT} --no-same-owner -xf -
tar -C ${B} -cf - pkg | tar -C ${D}${libdir}/go --no-same-owner -xf -
if [ -n "`ls ${B}/${GO_BUILD_BINDIR}/`" ]; then
@@ -172,9 +172,21 @@ do_install_ptest_base() {
chown -R root:root ${D}${PTEST_PATH}
}
+do_fixupdeps() {
+ gopath="${WORKDIR}/recipe-sysroot/gopath"
+ if [ -d ${gopath} ]; then
+ tar -C ${gopath} -cf - src | tar -C ${B} --no-same-owner -k -xf -
+ else
+ echo "no dependencies to fixup"
+ fi
+}
+
EXPORT_FUNCTIONS do_unpack do_configure do_compile do_install
-FILES_${PN}-dev = "${libdir}/go/src"
+addtask do_fixupdeps after do_configure before do_compile
+
+SYSROOT_DIRS_append = "/gopath"
+FILES_${PN}-dev = "/gopath/src"
FILES_${PN}-staticdev = "${libdir}/go/pkg"
INSANE_SKIP_${PN} += "ldflags"
--
2.19.2
More information about the Openembedded-core
mailing list