All,

the following backward compatible update makes the go package path
visible to ebuilds and separates the code that installs Go packages into
its own function which can be called by ebuilds.

Let me know what you think.

William

Index: golang-build.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/golang-build.eclass,v
retrieving revision 1.4
diff -u -B -r1.4 golang-build.eclass
--- golang-build.eclass	6 Jul 2015 16:48:21 -0000	1.4
+++ golang-build.eclass	22 Jul 2015 17:13:43 -0000
@@ -48,11 +48,40 @@
 	return 0
 }
 
+# @FUNCTION: _get_golibdir
+# @INTERNAL
+# @DESCRIPTION:
+# Return the non-prefixed library directory where Go packages
+# should be installed
+_get_golibdir() {
+	echo /usr/lib/go-gentoo
+}
+
+# @FUNCTION: get_golibdir
+# @DESCRIPTION:
+# Return the library directory where Go packages should be installed
+get_golibdir() {
+	echo "${EPREFIX}$(_get_golibdir)"
+}
+
+# @FUNCTION: golang_install_pkgs
+# @DESCRIPTION:
+# Install Go packages.
+# This function assumes that $cwd is a Go workspace.
+golang_install_pkgs() {
+	debug-print-function ${FUNCNAME} "$@"
+
+	_golang-build_setup
+	insinto "$(_get_golibdir)"
+	insopts -m0644 -p # preserve timestamps for bug 551486
+	doins -r pkg src
+}
+
 golang-build_src_compile() {
 	debug-print-function ${FUNCNAME} "$@"
 
 	_golang-build_setup
-	set -- env GOPATH="${WORKDIR}/${P}:${EPREFIX}/usr/lib/go-gentoo" \
+	set -- env GOPATH="${WORKDIR}/${P}:$(get_golibdir)" \
 		go build -v -work -x "${EGO_PN}"
 	echo "$@"
 	"$@" || die
@@ -62,20 +91,18 @@
 	debug-print-function ${FUNCNAME} "$@"
 
 	_golang-build_setup
-	set -- env GOPATH="${WORKDIR}/${P}:${EPREFIX}/usr/lib/go-gentoo" \
+	set -- env GOPATH="${WORKDIR}/${P}:$(get_golibdir)" \
 		go install -v -work -x "${EGO_PN}"
 	echo "$@"
 	"$@" || die
-	insinto /usr/lib/go-gentoo
-	insopts -m0644 -p # preserve timestamps for bug 551486
-	doins -r pkg src
+	golang_install_pkgs
 }
 
 golang-build_src_test() {
 	debug-print-function ${FUNCNAME} "$@"
 
 	_golang-build_setup
-	set -- env GOPATH="${WORKDIR}/${P}:${EPREFIX}/usr/lib/go-gentoo" \
+	set -- env GOPATH="${WORKDIR}/${P}:$(get_golibdir)" \
 		go test -v -work -x "${EGO_PN}"
 	echo "$@"
 	"$@" || die

Attachment: signature.asc
Description: Digital signature

Reply via email to