Bug 237352 - [NEW PORT] databases/mongodb40-tools: Tools for MongoDB
Summary: [NEW PORT] databases/mongodb40-tools: Tools for MongoDB
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Many People
Assignee: Tobias Kortkamp
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-04-17 23:36 UTC by Andrew Shevchuk
Modified: 2019-04-19 08:48 UTC (History)
2 users (show)

See Also:


Attachments
mongodb40-tools.patch (16.27 KB, patch)
2019-04-17 23:36 UTC, Andrew Shevchuk
no flags Details | Diff
mongodb40-tools.patch v2 (16.10 KB, patch)
2019-04-18 18:53 UTC, Andrew Shevchuk
no flags Details | Diff
monodb40-tools.diff (15.71 KB, patch)
2019-04-19 07:14 UTC, Tobias Kortkamp
dev.ashevchuk: maintainer-approval+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Shevchuk 2019-04-17 23:36:16 UTC
Created attachment 203756 [details]
mongodb40-tools.patch

New port proposal: Tools for MongoDB 4.x
Comment 1 Matthias Fechner freebsd_committer freebsd_triage 2019-04-18 16:28:49 UTC
I get the following error message:
===>  Building for mongodb40-tools-4.0.8
Building mongodump
/usr/bin/env OPENSSLBASE=/usr/local OPENSSLDIR=/usr/local/openssl OPENSSLINC=/usr/local/include OPENSSLLIB=/usr/local/lib OPENSSLRPATH=/usr/local/lib XDG_DATA_HOME=/wrkdirs/usr/ports/databases/mongodb40-tools/work  XDG_CONFIG_HOME=/wrkdirs/usr/ports/databases/mongodb40-tools/work  HOME=/wrkdirs/usr/ports/databases/mongodb40-tools/work TMPDIR="/tmp" PATH=/usr/local/libexec/ccache:/wrkdirs/usr/ports/databases/mongodb40-tools/work/.bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/root/bin NO_PIE=yes MK_DEBUG_FILES=no MK_KERNEL_SYMBOLS=no SHELL=/bin/sh NO_LINT=YES PREFIX=/usr/local  LOCALBASE=/usr/local  CC="clang" CFLAGS="-O2 -pipe  -fstack-protector -isystem /usr/local/include -fno-strict-aliasing "  CPP="cpp" CPPFLAGS="-isystem /usr/local/include"  LDFLAGS=" -Wl,-rpath,/usr/local/lib -fstack-protector " LIBS="-L/usr/local/lib"  CXX="c++" CXXFLAGS="-O2 -pipe -fstack-protector -isystem /usr/local/include -fno-strict-aliasing  -isystem /usr/local/include "  MANPREFIX="/usr/local" CCACHE_DIR="/root/.ccache" BSD_INSTALL_PROGRAM="install  -s -m 555"  BSD_INSTALL_LIB="install  -s -m 0644"  BSD_INSTALL_SCRIPT="install  -m 555"  BSD_INSTALL_DATA="install  -m 0644"  BSD_INSTALL_MAN="install  -m 444"  GOPATH="/wrkdirs/usr/ports/databases/mongodb40-tools/work/mongo-tools-r4.0.8/.gopath:/wrkdirs/usr/ports/databases/mongodb40-tools/work/mongo-tools-r4.0.8/vendor"  CGO_CPPFLAGS="-isystem /usr/local/include"  CGO_LDFLAGS="-L/usr/local/lib"  /usr/local/go14/bin/go build  -o /wrkdirs/usr/ports/databases/mongodb40-tools/work/mongo-tools-r4.0.8/bin/mongodump  -tags "sasl ssl"  /wrkdirs/usr/ports/databases/mongodb40-tools/work/mongo-tools-r4.0.8/mongodump/main/mongodump.go
env: /usr/local/go14/bin/go: No such file or directory
*** Error code 127
Comment 2 Matthias Fechner freebsd_committer freebsd_triage 2019-04-18 16:43:30 UTC
It looks to me that it uses go1.2 to compile and not go1.4 like it is mentioned in the Makefile.

You can find the full build log here:
https://pkg.fechner.net/data/120amd64-gitlab/2019-04-18_18h34m46s/logs/errors/mongodb40-tools-4.0.8.log
Comment 3 Tobias Kortkamp freebsd_committer freebsd_triage 2019-04-18 16:47:33 UTC
Comment on attachment 203756 [details]
mongodb40-tools.patch

+USES=			compiler:c++14-lang localbase go

Why add USES=go if you provide your own do-build, do-install?
It basically doesn't do much anymore after that. ;-)

+CC=			clang

Why?

+SSL_USE=		my_tags=ssl
+SSL_USES=		ssl
+
+SASL_USE=		my_tags=sasl
+SASL_LIB_DEPENDS=	libsasl2.so:security/cyrus-sasl2

Please put these with the rest of the options helpers below.

+GO_LANG_VERSION=       1.4
+GO_LANG_VER_PATH_STR=  ${GO_LANG_VERSION:S/.//}

This seems needlessly complicated to me.  lang/go14 should only be
used to bootstrap lang/go and not by individual ports.  Doesn't
this build with lang/go?

+BUILD_DEPENDS=		go>=${GO_LANG_VERSION}:lang/go${GO_LANG_VERSION_PATH_STR}

This is wrong.  It looks for a package named 'go' which only lang/go
provides.  The package name for lang/go14 is 'go14' and it never
provides a 'go' package.  However USES=go adds a correct BUILD_DEPENDS
so the framework never complains.

+MAKE_CMD= ${LOCALBASE}/go${GO_LANG_VER_PATH_STR}/bin/go build

Please do not overwrite MAKE_CMD like this.  It might make sense
if the port provides its own do-build, do-install but this is not
the case here.  AFAICT it's only used in do-build here, so just put
the 'go build' command directly in there.

+MY_TAGS= -tags "${USE_MY_TAGS}"

MY_TAGS is only used in do-install, so this could be placed directly
in it instead of defining it.

+.for TOOL in ${TOOL_BUILD}
+.for DOC in README.md CONTRIBUTING.md LICENSE.md THIRD-PARTY-NOTICES

Use lower case chars for loop variables.

+post-install:
+.for TOOL in ${TOOL_BUILD}
+	@${ECHO_MSG} "Stripping ${TOOL}"
+	${STRIP_CMD} ${STAGEDIR}${PREFIX}/bin/${TOOL}
+.endfor

This should be part of do-install.  post-install is only useful if
the framework default do-install is used, but this is not the case
here.  However ${INSTALL_PROGRAM} already strips binaries so this
is probably not needed at all.
Comment 4 Tobias Kortkamp freebsd_committer freebsd_triage 2019-04-18 16:49:17 UTC
(In reply to Tobias Kortkamp from comment #3)
> if the port provides its own do-build, do-install but this is not

Sorry, I meant "if the port *does not* provide its own do-build, do-install" here.
Comment 5 Andrew Shevchuk 2019-04-18 18:53:21 UTC
Created attachment 203772 [details]
mongodb40-tools.patch v2
Comment 6 Andrew Shevchuk 2019-04-18 19:03:36 UTC
(In reply to Tobias Kortkamp from comment #3)
Thanks for the recommendations.
Makefile fixed.
The port can be built without problems with poudriere.
In addition, the portlint output is clean.
Unfortunately, without redefining (CC=clang) and using "lang/go14", I did not manage to build this port.
Comment 7 Tobias Kortkamp freebsd_committer freebsd_triage 2019-04-19 07:14:07 UTC
Created attachment 203785 [details]
monodb40-tools.diff

(In reply to Andrew Shevchuk from comment #6)
> (In reply to Tobias Kortkamp from comment #3)
> Thanks for the recommendations.
> Makefile fixed.
> The port can be built without problems with poudriere.
> In addition, the portlint output is clean.
> Unfortunately, without redefining (CC=clang) and using "lang/go14", I did
> not manage to build this port.

As I said using lang/go14 as a workaround for build problems is
unacceptable.  The port builds fine with lang/go and without CC=clang.
I'm attaching a cleaned up patch that I'd commit if you give your ok.
Comment 8 commit-hook freebsd_committer freebsd_triage 2019-04-19 07:34:49 UTC
A commit references this bug:

Author: tobik
Date: Fri Apr 19 07:34:45 UTC 2019
New revision: 499327
URL: https://svnweb.freebsd.org/changeset/ports/499327

Log:
  New port: databases/mongodb40-tools

  Useful utilities for managing a MongoDB instance written in Go.

  - bsondump - display BSON files in a human-readable format
  - mongoimport - Convert data from JSON, TSV or CSV and insert them
    into a collection
  - mongoexport - Write an existing collection to CSV or JSON format
  - mongodump/mongorestore - Dump MongoDB backups to disk in .BSON
    format, or restore them to a live database
  - mongostat - Monitor live MongoDB servers, replica sets, or sharded
    clusters
  - mongofiles - Read, write, delete, or update files in GridFS
  - mongotop - Monitor read/write activity on a mongo server
  - mongoreplay - Capture, observe, and replay traffic for MongoDB

  WWW: https://github.com/mongodb/mongo-tools

  PR:		237352
  Submitted by:	Andrew Shevchuk <dev.ashevchuk@gmail.com> (based on)

Changes:
  head/databases/Makefile
  head/databases/mongodb40-tools/
  head/databases/mongodb40-tools/Makefile
  head/databases/mongodb40-tools/distinfo
  head/databases/mongodb40-tools/files/patch-common_util_file.go
  head/databases/mongodb40-tools/files/patch-vendor_github.com_10gen_openssl_build.go
  head/databases/mongodb40-tools/files/patch-vendor_github.com_10gen_openssl_init__posix.go
  head/databases/mongodb40-tools/files/patch-vendor_src_github.com_spacemonkeygo_openssl_build.go
  head/databases/mongodb40-tools/files/patch-vendor_src_github.com_spacemonkeygo_openssl_init__posix.go
  head/databases/mongodb40-tools/pkg-descr
  head/databases/mongodb40-tools/pkg-plist
Comment 9 Tobias Kortkamp freebsd_committer freebsd_triage 2019-04-19 07:35:47 UTC
Committed. Thanks!
Comment 10 Matthias Fechner freebsd_committer freebsd_triage 2019-04-19 08:48:24 UTC
Thanks you both!
Really appreciate having this port now available.