Skip to contentSkip to conversation

docker: override GOROOT at build time

PATCH In review Yunguo Wei 2 participants 2 messages May 30, 2016

lore
Share & tools
lore

Yunguo Wei

author
#0 lore raw

PATCH 1/1 docker: override GOROOT at build time

Usually $GOROOT is set by go tool, but if sstate is specified, $GOROOT is set to the path in the first project. If docker is built in the another project(with same SSTATE_DIR) later, and the first project is removed, the following error will be seen:

| go: cannot find GOROOT directory:
/path/to/previous/project/bitbake_build/tmp/sysroots/x86_64-linux/usr/lib/x86_64-wrs-linux/go

This commit is overriding $GOROOT stored in the go tool in sstate cache, making sure it is set to the correct path in current project.

See more information here: https://golang.org/doc/install#install

---
 recipes-containers/docker/docker_git.bb | 1 +
 1 file changed, 1 insertion(+)
recipes-containers/docker/docker_git.bb +1 -0
index 597ff4f..4eea3f4 100644
@@ -82,6 +82,7 @@ do_compile() {
 	mkdir -p .gopath/src/"$(dirname "${DOCKER_PKG}")"
 	ln -sf ../../../.. .gopath/src/"${DOCKER_PKG}"
 	export GOPATH="${S}/.gopath:${S}/vendor:${STAGING_DIR_TARGET}/${prefix}/local/go"
+	export GOROOT="${STAGING_DIR_NATIVE}/${nonarch_libdir}/${HOST_SYS}/go"
 	cd -
 
 	# Pass the needed cflags/ldflags so that cgo
Signature · 1 line
1.9.1
#1 lore raw

merged.

Bruce

Quoted 39 lines · Yunguo Wei

Usually $GOROOT is set by go tool, but if sstate is specified, $GOROOT is set to the path in the first project. If docker is built in the another project(with same SSTATE_DIR) later, and the first project is removed,
the following error will be seen:

| go: cannot find GOROOT directory:

/path/to/previous/project/bitbake_build/tmp/sysroots/x86_64-linux/usr/lib/x86_64-wrs-linux/go

This commit is overriding $GOROOT stored in the go tool in sstate cache, making sure it is set to the correct path in current project.

See more information here: https://golang.org/doc/install#install

---
 recipes-containers/docker/docker_git.bb | 1 +
 1 file changed, 1 insertion(+)
recipes-containers/docker/docker_git.bb +0 -0
index 597ff4f..4eea3f4 100644
@@ -82,6 +82,7 @@ do_compile() {
        mkdir -p .gopath/src/"$(dirname "${DOCKER_PKG}")"
        ln -sf ../../../.. .gopath/src/"${DOCKER_PKG}"
        export

GOPATH="${S}/.gopath:${S}/vendor:${STAGING_DIR_TARGET}/${prefix}/local/go"
+ export
GOROOT="${STAGING_DIR_NATIVE}/${nonarch_libdir}/${HOST_SYS}/go"
cd -

# Pass the needed cflags/ldflags so that cgo
--
1.9.1

Signature · 2 lines
"Thou shalt not follow the NULL pointer, for chaos and madness await thee
at its end"