Hi! In attached files are the changes I propose regarding lang/go MODULE. The files are:
* go.port.mk.diff diff for module itself
* goports.diff diff for ports that are using the module
* go-tools.tgz port for official go tools, which should replace
devel/gocover, textproc/godoc and recently
proposed devel/govet
* hub.tgz recently proposed port, that was blocked by
build issues that are solved with proposed
changes.
* port-modules.5.diff diff for port-modules(5) documenting the module
Description of changes (reformatted addition to port-modules(5)):
Adds Go toolchain support. Requires ALL_TARGET to be set to canonical
Go import path of port. (Module sets it automatically for ports that
use GH_ACCOUNT and GH_PROJECT macros.)
During execution of post-patch target module moves source code from
${MODGO_SUBDIR} to ${WRKSRC}, subdirectory of ${MODGO_WORKSPACE} -
specially-crafted Go workspace located at ${WRKDIR}/go. During do-build
module calls ``go install'' with GOPATH set to ${MODGO_WORKSPACE}.
During do-install it copies executables from ${MODGO_WORKSPACE}/bin to
${PREFIX}/bin, and/or directories ${MODGO_WORKSPACE}/pkg and
${MODGO_WORKSPACE}/src to ${PREFIX}/go, depending on MODGO_TYPE
contents.
Sets BUILD_DEPENDS, RUN_DEPENDS, ALL_TARGET, TEST_TARGET,
ONLY_FOR_ARCHS, SEPARATE_BUILD, and WRKSRC.
Defines:
MODGO_TYPE Type of port. May be any combination of:
bin ordinary binary, which should be installed to
${PREFIX}/bin,
lib library, which should come with source code.
Defaults to bin.
MODGO_WORKSPACE Path to Go workspace set up for port build process.
Defaults to ${WRKDIR}/go. See Go documentation for
details.
MODGO_SUBDIR Path to Go source code within port's sources tarball.
Defaults to ${WRKDIST}.
MODGO_SETUP_WORKSPACE
Commands setting up Go workspace for building ports.
By default, happens during execution of post-patch
target.
MODGO_BUILDDEP Controls whether contents of MODGO_BUILD_DEPENDS are
appended to port's BUILD_DEPENDS. Defaults to Yes.
Additionally defines MODGO_PACKAGES, MODGO_SOURCES and MODGO_TOOLS
(paths for installed Go packages, sources and tools respectively),
MODGO_CMD and MODGO_FLAGS (source code build command and flags passed as
its arguments), MODGO_BUILD_CMD and MODGO_TEST_CMD (commands for
building and testing go packages; normally called with canonical Go
package names as arguments), MODGO_{BUILD,INSTALL,TEST}_TARGET and
MODGO_{BUILD,RUN}_DEPENDS.
CC:
* Adam Wolk, Fabian Raetz, Jasper Lievisse Adriaanse, Joel Sing and
Kent R. Spillner, who contributed ports in Go,
* Antoine Jacoutot, Marc Espie and Stuart Henderson, whose input may
save us all from much trouble in future,
* Ingo Schwarze, who will have to cope with manual parsing if
port-modules(5) diff is applied ;)
Comments? OKs?
--
Dmitrij D. Czarkoff
Index: lang/go/go.port.mk
===================================================================
RCS file: /var/cvs/ports/lang/go/go.port.mk,v
retrieving revision 1.1
diff -u -p -r1.1 go.port.mk
--- lang/go/go.port.mk 15 May 2015 07:30:41 -0000 1.1
+++ lang/go/go.port.mk 3 Jun 2015 20:03:32 -0000
@@ -11,8 +11,68 @@ MODGO_BUILD_DEPENDS = lang/go
BUILD_DEPENDS += ${MODGO_BUILD_DEPENDS}
.endif
-GO_PKG ?= pkg/tool/openbsd_${MACHINE_ARCH:S/i386/386/}
+MODGO_PACKAGES = go/pkg/openbsd_${MACHINE_ARCH:S/i386/386/}
+MODGO_SOURCES = go/src
+MODGO_TOOLS =
${MODGO_PACKAGES}/tool/openbsd_${MACHINE_ARCH:S/i386/386/}
-SUBST_VARS += GO_PKG
+SUBST_VARS += MODGO_TOOLS MODGO_PACKAGES MODGO_SOURCES
-GOPATH ?= "${WRKSRC}:${LOCALBASE}/go"
+MODGO_SUBDIR ?= ${WRKDIST}
+MODGO_TYPE ?= bin
+MODGO_WORKSPACE ?= ${WRKDIR}/go
+MODGO_CMD ?= GOPATH="${MODGO_WORKSPACE}" WORK="${WRKBUILD}" go
+MODGO_FLAGS += -x -work
+MODGO_BUILD_CMD = ${MODGO_CMD} install ${MODGO_FLAGS}
+MODGO_TEST_CMD = ${MODGO_CMD} test ${MODGO_FLAGS}
+
+.if ${MODGO_TYPE:L:Mlib}
+RUN_DEPENDS += ${MODGO_RUN_DEPENDS}
+.endif
+
+.if defined(GH_ACCOUNT) && defined(GH_PROJECT)
+ALL_TARGET ?= github.com/${GH_ACCOUNT}/${GH_PROJECT}
+.endif
+TEST_TARGET ?= ${ALL_TARGET}
+
+SEPARATE_BUILD ?= Yes
+WRKSRC ?= ${MODGO_WORKSPACE}/src/${ALL_TARGET}
+
+MODGO_SETUP_WORKSPACE = mkdir -p ${WRKSRC:H}; mv ${MODGO_SUBDIR}
${WRKSRC};
+
+MODGO_BUILD_TARGET = ${MODGO_BUILD_CMD} ${ALL_TARGET}
+
+# Go source files serve the purpose of libraries, so sources should be included
+# with library ports
+.if ${MODGO_TYPE:L:Mlib}
+MODGO_INSTALL_TARGET = ${INSTALL_DATA_DIR} ${PREFIX}/go; \
+ cp -R ${MODGO_WORKSPACE}/pkg \
+ ${MODGO_WORKSPACE}/src \
+ ${PREFIX}/go;
+.endif
+.if ${MODGO_TYPE:L:Mbin}
+MODGO_INSTALL_TARGET += cp ${MODGO_WORKSPACE}/bin/* ${PREFIX}/bin
+.endif
+
+MODGO_TEST_TARGET = ${MODGO_TEST_CMD} ${TEST_TARGET}
+
+.if empty(CONFIGURE_STYLE)
+. if !target(post-patch)
+post-patch:
+ ${MODGO_SETUP_WORKSPACE}
+. endif
+
+. if !target(do-build)
+do-build:
+ ${MODGO_BUILD_TARGET}
+. endif
+
+. if !target(do-install)
+do-install:
+ ${MODGO_INSTALL_TARGET}
+. endif
+
+. if !target(do-test)
+do-test:
+ ${MODGO_TEST_TARGET}
+. endif
+.endif
Index: net/go-websocket/Makefile
===================================================================
RCS file: /var/cvs/ports/net/go-websocket/Makefile,v
retrieving revision 1.2
diff -u -p -r1.2 Makefile
--- net/go-websocket/Makefile 15 May 2015 07:32:00 -0000 1.2
+++ net/go-websocket/Makefile 3 Jun 2015 20:03:32 -0000
@@ -7,7 +7,7 @@ DISTNAME = go-websocket-${VERSION}
GH_COMMIT = 97d8e4e174133a4d1d2171380e510eb4dea8f5ea
GH_ACCOUNT = golang
GH_PROJECT = net
-REVISION = 0
+REVISION = 1
CATEGORIES = net www
@@ -23,25 +23,8 @@ WANTLIB = c pthread
MODULES = lang/go
GO_PKG = pkg/openbsd_${MACHINE_ARCH:S/i386/386/}
-
-post-extract:
- mkdir -p ${WRKSRC}/src/golang.org/x/net
- mv ${WRKSRC}/websocket ${WRKSRC}/src/golang.org/x/net/
-
-do-build:
- GOPATH=${GOPATH} go install golang.org/x/net/websocket
-
-do-test:
- GOPATH=${GOPATH} go test golang.org/x/net/websocket
-
-do-install:
- ${INSTALL_DATA_DIR} ${PREFIX}/go/${GO_PKG}/golang.org/x/net
- ${INSTALL_DATA} -p \
- ${WRKDIST}/${GO_PKG}/golang.org/x/net/websocket.a \
- ${PREFIX}/go/${GO_PKG}/golang.org/x/net/
- ${INSTALL_DATA_DIR} ${PREFIX}/go/src/golang.org/x/net/websocket
- ${INSTALL_DATA} -p \
- ${WRKDIST}/src/golang.org/x/net/websocket/websocket.go \
- ${PREFIX}/go/src/golang.org/x/net/websocket/
+MODGO_TYPE = lib
+MODGO_SUBDIR = ${WRKDIST}/websocket
+ALL_TARGET = golang.org/x/net/websocket
.include <bsd.port.mk>
Index: net/go-websocket/pkg/PLIST
===================================================================
RCS file: /var/cvs/ports/net/go-websocket/pkg/PLIST,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 PLIST
--- net/go-websocket/pkg/PLIST 31 Mar 2015 15:37:06 -0000 1.1.1.1
+++ net/go-websocket/pkg/PLIST 3 Jun 2015 20:03:32 -0000
@@ -1,14 +1,17 @@
@comment $OpenBSD: PLIST,v 1.1.1.1 2015/03/31 15:37:06 kspillner Exp $
-go/
-go/pkg/
-go/${GO_PKG}/
-go/${GO_PKG}/golang.org/
-go/${GO_PKG}/golang.org/x/
-go/${GO_PKG}/golang.org/x/net/
-go/${GO_PKG}/golang.org/x/net/websocket.a
-go/src/
-go/src/golang.org/
-go/src/golang.org/x/
-go/src/golang.org/x/net/
-go/src/golang.org/x/net/websocket/
-go/src/golang.org/x/net/websocket/websocket.go
+${MODGO_PACKAGES}/golang.org/
+${MODGO_PACKAGES}/golang.org/x/
+${MODGO_PACKAGES}/golang.org/x/net/
+${MODGO_PACKAGES}/golang.org/x/net/websocket.a
+${MODGO_SOURCES}/golang.org/
+${MODGO_SOURCES}/golang.org/x/
+${MODGO_SOURCES}/golang.org/x/net/
+${MODGO_SOURCES}/golang.org/x/net/websocket/
+${MODGO_SOURCES}/golang.org/x/net/websocket/client.go
+${MODGO_SOURCES}/golang.org/x/net/websocket/exampledial_test.go
+${MODGO_SOURCES}/golang.org/x/net/websocket/examplehandler_test.go
+${MODGO_SOURCES}/golang.org/x/net/websocket/hybi.go
+${MODGO_SOURCES}/golang.org/x/net/websocket/hybi_test.go
+${MODGO_SOURCES}/golang.org/x/net/websocket/server.go
+${MODGO_SOURCES}/golang.org/x/net/websocket/websocket.go
+${MODGO_SOURCES}/golang.org/x/net/websocket/websocket_test.go
Index: net/websocketd/Makefile
===================================================================
RCS file: /var/cvs/ports/net/websocketd/Makefile,v
retrieving revision 1.3
diff -u -p -r1.3 Makefile
--- net/websocketd/Makefile 15 May 2015 07:32:00 -0000 1.3
+++ net/websocketd/Makefile 3 Jun 2015 20:03:32 -0000
@@ -8,7 +8,7 @@ DISTNAME = websocketd-$V
GH_ACCOUNT = joewalnes
GH_PROJECT = websocketd
GH_TAGNAME = v$V
-REVISION = 0
+REVISION = 1
CATEGORIES = net www
@@ -27,16 +27,7 @@ BUILD_DEPENDS = net/go-websocket
NO_TEST = Yes
-post-extract:
- mkdir -p ${WRKSRC}/src/github.com/joewalnes
- ln -fhs ${WRKSRC} ${WRKSRC}/src/github.com/joewalnes/websocketd
-
-do-build:
- GOPATH=${GOPATH} go build -o ${WRKDIST}/websocketd \
- github.com/joewalnes/websocketd
-
-do-install:
- ${INSTALL_PROGRAM} -p ${WRKDIST}/websocketd ${PREFIX}/bin
+post-install:
${INSTALL_MAN} ${WRKSRC}/release/websocketd.man \
${PREFIX}/man/man8/websocketd.8
${INSTALL_DATA_DIR} ${PREFIX}/share/examples/websocketd
Index: sysutils/logstash/forwarder/Makefile
===================================================================
RCS file: /var/cvs/ports/sysutils/logstash/forwarder/Makefile,v
retrieving revision 1.4
diff -u -p -r1.4 Makefile
--- sysutils/logstash/forwarder/Makefile 15 May 2015 07:37:14 -0000
1.4
+++ sysutils/logstash/forwarder/Makefile 3 Jun 2015 20:03:32 -0000
@@ -6,6 +6,7 @@ GH_ACCOUNT= elastic
GH_PROJECT= logstash-forwarder
GH_TAGNAME= v0.4.0
DISTNAME= ${GH_PROJECT}-${GH_TAGNAME:S/v//}
+REVISION= 0
MODULES= lang/go
@@ -13,14 +14,9 @@ NO_TEST= Yes
WANTLIB += c pthread
-do-build:
- cd ${WRKSRC} && go build -o logstash-forwarder
-
-pre-configure:
- ${SUBST_CMD} ${WRKSRC}/logstash-forwarder.conf.example
-
do-install:
- ${INSTALL_PROGRAM} ${WRKSRC}/logstash-forwarder ${PREFIX}/sbin/
+ ${INSTALL_PROGRAM} ${MODGO_WORKSPACE}/bin/logstash-forwarder \
+ ${PREFIX}/sbin/
${INSTALL_DATA_DIR} ${PREFIX}/share/{doc,examples}/logstash-forwarder/
${INSTALL_DATA} ${WRKSRC}/README.md \
${PREFIX}/share/doc/logstash-forwarder/
go-tools.tgz
Description: application/tar-gz
hub.tgz
Description: application/tar-gz
Index: share/man/man5/port-modules.5
===================================================================
RCS file: /var/cvs/src/share/man/man5/port-modules.5,v
retrieving revision 1.188
diff -u -p -r1.188 port-modules.5
--- share/man/man5/port-modules.5 2 Apr 2015 15:47:40 -0000 1.188
+++ share/man/man5/port-modules.5 3 Jun 2015 20:21:45 -0000
@@ -734,6 +734,117 @@ command can be specified with
.Ev MODGHC_SETUP_CONF_ARGS
and
.Ev MODGHC_SETUP_CONF_ENV .
+.It lang/go
+Adds Go toolchain support.
+Requires
+.Ev ALL_TARGET
+to be set to canonical Go import path of port.
+(Module sets it automatically for ports that use
+.Ev GH_ACCOUNT
+and
+.Ev GH_PROJECT
+macros.)
+.Pp
+During execution of
+.Ar post-patch
+target module moves source code from
+.Pa ${MODGO_SUBDIR}
+to
+.Pa ${WRKSRC} ,
+subdirectory of
+.Pa ${MODGO_WORKSPACE}
+- specially-crafted Go workspace located at
+.Pa ${WRKDIR}/go .
+During
+.Ar do-build
+module calls
+.Dq go install
+with
+.Ev GOPATH
+set to
+.Pa ${MODGO_WORKSPACE} .
+During
+.Ar do-install
+it copies executables from
+.Pa ${MODGO_WORKSPACE}/bin
+to
+.Pa ${PREFIX}/bin ,
+and/or directories
+.Pa ${MODGO_WORKSPACE}/pkg
+and
+.Pa ${MODGO_WORKSPACE}/src
+to
+.Pa ${PREFIX}/go ,
+depending on
+.Ev MODGO_TYPE
+contents.
+.Pp
+Sets
+.Ev BUILD_DEPENDS ,
+.Ev RUN_DEPENDS ,
+.Ev ALL_TARGET ,
+.Ev TEST_TARGET ,
+.Ev ONLY_FOR_ARCHS ,
+.Ev SEPARATE_BUILD ,
+and
+.Ev WRKSRC .
+.Pp
+Defines:
+.Bl -tag -width MODGO_WORKSPACE
+.It Ev MODGO_TYPE
+Type of port.
+May be any combination of:
+.Bl -tag -width lib
+.It bin
+ordinary binary, which should be installed to
+.Pa ${PREFIX}/bin ,
+.It lib
+library, which should come with source code.
+.El
+.Pp
+Defaults to
+.Ar bin .
+.It Ev MODGO_WORKSPACE
+Path to Go workspace set up for port build process.
+Defaults to
+.Pa ${WRKDIR}/go .
+See Go documentation for details.
+.It Ev MODGO_SUBDIR
+Path to Go source code within port's sources tarball.
+Defaults to
+.Pa ${WRKDIST} .
+.It Ev MODGO_SETUP_WORKSPACE
+Commands setting up Go workspace for building ports.
+By default, happens during execution of
+.Ar post-patch
+target.
+.It Ev MODGO_BUILDDEP
+Controls whether contents of
+.Ev MODGO_BUILD_DEPENDS
+are appended to port's
+.Ev BUILD_DEPENDS .
+Defaults to
+.Ar Yes .
+.El
+.Pp
+Additionally defines
+.Ev MODGO_PACKAGES ,
+.Ev MODGO_SOURCES
+and
+.Ev MODGO_TOOLS
+(paths for installed Go packages, sources and tools respectively),
+.Ev MODGO_CMD
+and
+.Ev MODGO_FLAGS
+(source code build command and flags passed as its arguments),
+.Ev MODGO_BUILD_CMD
+and
+.Ev MODGO_TEST_CMD
+(commands for building and testing go packages; normally called with canonical
+Go package names as arguments),
+.Ev MODGO_{BUILD,INSTALL,TEST}_TARGET
+and
+.Ev MODGO_{BUILD,RUN}_DEPENDS .
.It lang/lua
Sets
.Ev MODLUA_BIN ,
