Sun Jul 8 12:55:00 2018 UTC ()
Use the non-symlinked go tool for package builds.

Otherwise, you will not be able to build Go code in pkgsrc if you do not
have pkg_alternatives installed.

Introduce a variable (user-settable for now) GOVERSSUFFIX.
$GO is now the Go tool with full path.

leot@ convinced me to go full Python (e.g. one directory per major version,
GO_VERSION_ACCEPTED etc.) but that will be another series of commits.


(bsiegert)
diff -r1.12 -r1.13 pkgsrc/lang/go/go-package.mk

cvs diff -r1.12 -r1.13 pkgsrc/lang/go/go-package.mk (expand / switch to unified diff)

--- pkgsrc/lang/go/go-package.mk 2018/06/05 15:42:20 1.12
+++ pkgsrc/lang/go/go-package.mk 2018/07/08 12:55:00 1.13
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: go-package.mk,v 1.12 2018/06/05 15:42:20 leot Exp $ 1# $NetBSD: go-package.mk,v 1.13 2018/07/08 12:55:00 bsiegert Exp $
2# 2#
3# This file implements common logic for compiling Go programs in pkgsrc. 3# This file implements common logic for compiling Go programs in pkgsrc.
4# 4#
5# === Package-settable variables === 5# === Package-settable variables ===
6# 6#
7# GO_SRCPATH (required) 7# GO_SRCPATH (required)
8# The patch that can be used with "go get" to import the current 8# The patch that can be used with "go get" to import the current
9# package. This is usually the URL without the leading protocol. 9# package. This is usually the URL without the leading protocol.
10# 10#
11# Examples: 11# Examples:
12# github.com/username/repository 12# github.com/username/repository
13# gopkg.in/check.v1 13# gopkg.in/check.v1
14# 14#
@@ -41,26 +41,31 @@ @@ -41,26 +41,31 @@
41# 2. Install binaries into bin/. 41# 2. Install binaries into bin/.
42# 3. Install source code and packages into a separate gopkg tree. 42# 3. Install source code and packages into a separate gopkg tree.
43# 43#
44# In the future, we may implement buildlink by creating a separate tree during 44# In the future, we may implement buildlink by creating a separate tree during
45# the build and linking only the packages explicitly mentioned in dependencies 45# the build and linking only the packages explicitly mentioned in dependencies
46# there. 46# there.
47# 47#
48# All packages build-depend on the "master" Go release. Go packages 48# All packages build-depend on the "master" Go release. Go packages
49# need to be revbumped when lang/go is updated. 49# need to be revbumped when lang/go is updated.
50# 50#
51 51
52.include "../../lang/go/version.mk" 52.include "../../lang/go/version.mk"
53 53
 54# How to find the Go tool.
 55GOVERSSUFFIX?=
 56GO= ${PREFIX}/go${GOVERSSUFFIX}/bin/go
 57
 58
54_GO_DIST_BASE!= basename ${GO_SRCPATH} 59_GO_DIST_BASE!= basename ${GO_SRCPATH}
55GO_DIST_BASE?= ${_GO_DIST_BASE} 60GO_DIST_BASE?= ${_GO_DIST_BASE}
56GO_BUILD_PATTERN?= ${GO_SRCPATH}/... 61GO_BUILD_PATTERN?= ${GO_SRCPATH}/...
57 62
58WRKSRC= ${WRKDIR}/src/${GO_SRCPATH} 63WRKSRC= ${WRKDIR}/src/${GO_SRCPATH}
59 64
60BUILD_DEPENDS+= go-${GO_VERSION}*:../../lang/go 65BUILD_DEPENDS+= go-${GO_VERSION}*:../../lang/go
61 66
62MAKE_JOBS_SAFE= no 67MAKE_JOBS_SAFE= no
63INSTALLATION_DIRS+= bin gopkg 68INSTALLATION_DIRS+= bin gopkg
64USE_TOOLS+= pax 69USE_TOOLS+= pax
65 70
66GO_PLATFORM= ${LOWER_OPSYS}_${GOARCH} 71GO_PLATFORM= ${LOWER_OPSYS}_${GOARCH}
@@ -69,26 +74,26 @@ GOTOOLDIR= ${PREFIX}/go/pkg/tool/${GO_P @@ -69,26 +74,26 @@ GOTOOLDIR= ${PREFIX}/go/pkg/tool/${GO_P
69PRINT_PLIST_AWK+= /${GO_PLATFORM}/ { gsub(/${GO_PLATFORM}/, \ 74PRINT_PLIST_AWK+= /${GO_PLATFORM}/ { gsub(/${GO_PLATFORM}/, \
70 "$${GO_PLATFORM}"); \ 75 "$${GO_PLATFORM}"); \
71 print; next; } 76 print; next; }
72 77
73.if !target(post-extract) 78.if !target(post-extract)
74post-extract: 79post-extract:
75 ${RUN} ${MKDIR} ${WRKSRC} 80 ${RUN} ${MKDIR} ${WRKSRC}
76 ${RUN} ${RM} -fr ${WRKDIR}/${GO_DIST_BASE}/.hg 81 ${RUN} ${RM} -fr ${WRKDIR}/${GO_DIST_BASE}/.hg
77 ${RUN} ${MV} ${WRKDIR}/${GO_DIST_BASE}/* ${WRKSRC} 82 ${RUN} ${MV} ${WRKDIR}/${GO_DIST_BASE}/* ${WRKSRC}
78.endif 83.endif
79 84
80.if !target(do-build) 85.if !target(do-build)
81do-build: 86do-build:
82 ${RUN} env GOPATH=${WRKDIR}:${BUILDLINK_DIR}/gopkg go install -v ${GO_BUILD_PATTERN} 87 ${RUN} env GOPATH=${WRKDIR}:${BUILDLINK_DIR}/gopkg ${GO} install -v ${GO_BUILD_PATTERN}
83.endif 88.endif
84 89
85.if !target(do-test) 90.if !target(do-test)
86do-test: 91do-test:
87 ${RUN} env GOPATH=${WRKDIR}:${BUILDLINK_DIR}/gopkg go test -v ${GO_BUILD_PATTERN} 92 ${RUN} env GOPATH=${WRKDIR}:${BUILDLINK_DIR}/gopkg ${GO} test -v ${GO_BUILD_PATTERN}
88.endif 93.endif
89 94
90.if !target(do-install) 95.if !target(do-install)
91do-install: 96do-install:
92 ${RUN} cd ${WRKDIR}; [ ! -d bin ] || ${PAX} -rw bin ${DESTDIR}${PREFIX} 97 ${RUN} cd ${WRKDIR}; [ ! -d bin ] || ${PAX} -rw bin ${DESTDIR}${PREFIX}
93 ${RUN} cd ${WRKDIR}; [ ! -d pkg ] || ${PAX} -rw src pkg ${DESTDIR}${PREFIX}/gopkg 98 ${RUN} cd ${WRKDIR}; [ ! -d pkg ] || ${PAX} -rw src pkg ${DESTDIR}${PREFIX}/gopkg
94.endif 99.endif