git: 27c280e07686 - main - textproc/kibana8: Add new port

From: Juraj Lutter <otis_at_FreeBSD.org>
Date: Sat, 26 Nov 2022 21:04:04 UTC
The branch main has been updated by otis:

URL: https://cgit.FreeBSD.org/ports/commit/?id=27c280e07686be9ca08a1d2f8899c52777560684

commit 27c280e07686be9ca08a1d2f8899c52777560684
Author:     Juraj Lutter <otis@FreeBSD.org>
AuthorDate: 2022-11-26 15:46:12 +0000
Commit:     Juraj Lutter <otis@FreeBSD.org>
CommitDate: 2022-11-26 21:03:17 +0000

    textproc/kibana8: Add new port
    
    Kibana is a visualisation tool for elasticsearch.
---
 UPDATING                                           |  22 ++++
 textproc/Makefile                                  |   1 +
 textproc/kibana8/Makefile                          | 118 +++++++++++++++++++++
 textproc/kibana8/distinfo                          |   7 ++
 .../kibana8/files/extra-node-re2-binding-gyp.patch |  51 +++++++++
 textproc/kibana8/files/kibana.in                   |  84 +++++++++++++++
 textproc/kibana8/files/patch-config_kibana.yml     |  11 ++
 ...rc_setup__node__env_node__version__validator.js |  18 ++++
 textproc/kibana8/files/pkg-deinstall.in            |  20 ++++
 textproc/kibana8/files/pkg-message.in              |   9 ++
 textproc/kibana8/pkg-descr                         |   6 ++
 11 files changed, 347 insertions(+)

diff --git a/UPDATING b/UPDATING
index e759bf0445f5..ceeb09a4fb81 100644
--- a/UPDATING
+++ b/UPDATING
@@ -5,6 +5,28 @@ they are unavoidable.
 You should get into the habit of checking this file for changes each time
 you update your ports collection, before attempting any port upgrades.
 
+20221126:
+  AFFECTS: textproc/kibana8
+  AUTHOR: otis@FreeBSD.org
+
+  kibana8 now installs kibana-specific utilities into LOCALBASE/bin as symbolic
+  links.
+
+  Please check whether it will overwrite your local files with names same as
+  these utilities and if so, please rename them or move out of the way in a
+  different manner.
+
+20221126:
+  AFFECTS: textproc/elasticsearch8
+  AUTHOR: otis@FreeBSD.org
+
+  elasticsearch8 now installs elasticsearch-specific utilities into
+  LOCALBASE/bin as symbolic links (i.e. elasticsearch-cli and similar).
+
+  Please check whether it will overwrite your local files with names same
+  as these utilities and if so, please rename them or move out of the way
+  in a different manner.
+
 20221126:
   AFFECTS: users of lang/php80
   AUTHOR: bofh@FreeBSD.org
diff --git a/textproc/Makefile b/textproc/Makefile
index 5c63ba34faa4..4b01a1cd4dd4 100644
--- a/textproc/Makefile
+++ b/textproc/Makefile
@@ -341,6 +341,7 @@
     SUBDIR += kf5-sonnet
     SUBDIR += kf5-syntax-highlighting
     SUBDIR += kibana7
+    SUBDIR += kibana8
     SUBDIR += kiss-templates
     SUBDIR += kmfl-european-latin
     SUBDIR += kmfl-khmer
diff --git a/textproc/kibana8/Makefile b/textproc/kibana8/Makefile
new file mode 100644
index 000000000000..eee28b4a18c7
--- /dev/null
+++ b/textproc/kibana8/Makefile
@@ -0,0 +1,118 @@
+PORTNAME=	kibana
+DISTVERSION=	8.5.2
+DISTVERSIONSUFFIX=	-darwin-x86_64
+CATEGORIES=	textproc www
+MASTER_SITES=	https://artifacts.elastic.co/downloads/kibana/ \
+		http://artifacts.elastic.co/downloads/kibana/
+PKGNAMESUFFIX=	8
+DISTFILES=	${DISTNAME}${EXTRACT_SUFX}
+
+MAINTAINER=	elastic@FreeBSD.org
+COMMENT=	Browser based analytics and search interface to ElasticSearch
+WWW=		https://www.elastic.co/products/kibana
+
+LICENSE=	APACHE20
+
+BUILD_DEPENDS=	${LOCALBASE}/bin/npm:www/npm-node16
+LIB_DEPENDS=	libre2.so:devel/re2 \
+		libuv.so:devel/libuv
+RUN_DEPENDS=	${LOCALBASE}/bin/node:www/node16
+
+USES=		compiler:c++14-lang cpe nodejs:16,build,run python:build
+CPE_VENDOR=	elastic
+
+USE_GITHUB=	nodefault
+GH_TUPLE=	nodejs:nan:v${_NODE_NAN_VER}:node_nan \
+		uhop:node-re2:${_NODE_RE2_VER}:node_re2
+
+USE_RC_SUBR=	${PORTNAME}
+
+CONFLICTS=	kibana7
+
+WWWDIR=		${PREFIX}/www/${PORTNAME}${PKGNAMESUFFIX}
+
+PORTSCOUT=	limit:^8
+
+SUB_FILES=	pkg-deinstall pkg-message
+SUB_LIST+=	BINDIR=${PREFIX}/bin \
+		PKGNAMESUFFIX=${PKGNAMESUFFIX} \
+		PORTNAME=${PORTNAME}
+
+WRKSRC=		${WRKDIR}/${PORTNAME}-${DISTVERSION}
+
+BINS=		kibana-encryption-keys kibana-keystore kibana-plugin \
+		kibana-setup kibana-verification-code
+
+#######################################################################
+# Set node-nan version here
+_NODE_NAN_VER=	2.17.0
+# Set node-re version here
+_NODE_RE2_VER=	1.17.8
+#######################################################################
+
+_NODECMD=	${LOCALBASE}/bin/node --version
+_DEVDIR:=	${WRKDIR}/.devdir
+
+_RE2DIR=	${WRKDIR}/node-re2-${_NODE_RE2_VER}
+
+# Extra patch files must be updated whenever node-re2 changes
+_RE2PATCHES=	${PATCHDIR}/extra-node-re2-binding-gyp.patch
+
+post-patch:
+	${FIND} -s ${WRKSRC}/node_modules -type d -empty -delete
+	cd ${_RE2DIR} && ${PATCH} -p0 < ${_RE2PATCHES}
+	${REINPLACE_CMD} -e "s|%%PREFIX%%|${PREFIX}|g" \
+	-e "s|%%DEVDIR%%|${_DEVDIR}|g" ${_RE2DIR}/binding.gyp \
+
+pre-configure:
+	( \
+	_NODEVER=$$(${_NODECMD} | ${SED} -n 's|^v\(.*\)|\1|p') && \
+	${MKDIR} ${_DEVDIR}/$${_NODEVER}/include && \
+	${RLN} ${LOCALBASE}/include/node ${_DEVDIR}/$${_NODEVER}/include/node && \
+	${ECHO} "9" > ${_DEVDIR}/$${_NODEVER}/installVersion \
+	)
+
+do-configure:
+	${MKDIR} ${_DEVDIR}/nan
+	(cd ${WRKDIR}/nan-${_NODE_NAN_VER} && ${COPYTREE_SHARE} . \
+		${_DEVDIR}/nan \
+		"! ( -name \.* -or -path *\/test\/* -or -name test )")
+	(cd ${_RE2DIR} && \
+		${SETENV} HOME=${WRKDIR} \
+		${LOCALBASE}/lib/node_modules/npm/bin/node-gyp-bin/node-gyp configure \
+		--python=${PYTHON_CMD} \
+		--devdir=${_DEVDIR})
+
+do-build:
+	(cd ${_RE2DIR} && \
+		${SETENV} HOME=${WRKDIR} \
+		${LOCALBASE}/lib/node_modules/npm/bin/node-gyp-bin/node-gyp build \
+		--devdir=${_DEVDIR})
+
+do-install:
+	${MKDIR} ${STAGEDIR}${WWWDIR} ${STAGEDIR}${ETCDIR}
+	${INSTALL_DATA} ${WRKSRC}/config/kibana.yml ${STAGEDIR}${ETCDIR}/kibana.yml.sample
+	(cd ${WRKSRC} && \
+		${RM} -r config node optimize && \
+		${COPYTREE_SHARE} . ${STAGEDIR}${WWWDIR} && \
+		${COPYTREE_BIN} bin ${STAGEDIR}${WWWDIR})
+	${INSTALL} -lrs ${STAGEDIR}${ETCDIR} ${STAGEDIR}${WWWDIR}/config
+	${MKDIR} ${STAGEDIR}${WWWDIR}/node/bin
+	${LN} -s ${LOCALBASE}/bin/node ${STAGEDIR}${WWWDIR}/node/bin/node
+	${RM} ${STAGEDIR}${WWWDIR}/node_modules/re2/build/Release/re2.node
+	${INSTALL_LIB} ${_RE2DIR}/build/Release/re2.node \
+		${STAGEDIR}${WWWDIR}/node_modules/re2/build/Release/re2.node
+.for f in ${BINS}
+	${INSTALL} -l rs ${STAGEDIR}${WWWDIR}/bin/${f} ${STAGEDIR}${PREFIX}/bin/${f}
+	${ECHO} "bin/${f}" >> ${TMPPLIST}
+.endfor
+
+post-install:
+	${ECHO} "@sample ${ETCDIR}/kibana.yml.sample" >> ${TMPPLIST}
+	${FIND} -s ${STAGEDIR}${WWWDIR} -not -type d | ${SORT} | \
+		${SED} -e 's#^${STAGEDIR}${PREFIX}/##' >> ${TMPPLIST}
+	${ECHO} "@dir(www,www) ${WWWDIR}/data" >> ${TMPPLIST}
+	${ECHO} "@dir ${WWWDIR}/plugins" >> ${TMPPLIST}
+	${ECHO} "@dir ${WWWDIR}/logs" >> ${TMPPLIST}
+
+.include <bsd.port.mk>
diff --git a/textproc/kibana8/distinfo b/textproc/kibana8/distinfo
new file mode 100644
index 000000000000..f16b50637a35
--- /dev/null
+++ b/textproc/kibana8/distinfo
@@ -0,0 +1,7 @@
+TIMESTAMP = 1669456190
+SHA256 (kibana-8.5.2-darwin-x86_64.tar.gz) = d568576f7daac371aab10409381450cae27a919fc7aa613bac62b11f0a338030
+SIZE (kibana-8.5.2-darwin-x86_64.tar.gz) = 150384461
+SHA256 (nodejs-nan-v2.17.0_GH0.tar.gz) = bcf5dfe59c26377b2096d903ecf6c2dbdae92528b1373a0565c40fe07537610d
+SIZE (nodejs-nan-v2.17.0_GH0.tar.gz) = 179443
+SHA256 (uhop-node-re2-1.17.8_GH0.tar.gz) = 4cf8c52cd92ae26eff9b26a9a213ea25eb97fbe381da2a5755c6ea8015ee347f
+SIZE (uhop-node-re2-1.17.8_GH0.tar.gz) = 41523
diff --git a/textproc/kibana8/files/extra-node-re2-binding-gyp.patch b/textproc/kibana8/files/extra-node-re2-binding-gyp.patch
new file mode 100644
index 000000000000..ebab5accfed0
--- /dev/null
+++ b/textproc/kibana8/files/extra-node-re2-binding-gyp.patch
@@ -0,0 +1,51 @@
+--- binding.gyp.orig	2021-05-10 04:34:55.000000000 +0200
++++ binding.gyp	2021-07-05 19:22:23.670716000 +0200
+@@ -14,29 +14,6 @@
+         "lib/to_string.cc",
+         "lib/accessors.cc",
+         "lib/util.cc",
+-        "vendor/re2/bitstate.cc",
+-        "vendor/re2/compile.cc",
+-        "vendor/re2/dfa.cc",
+-        "vendor/re2/filtered_re2.cc",
+-        "vendor/re2/mimics_pcre.cc",
+-        "vendor/re2/nfa.cc",
+-        "vendor/re2/onepass.cc",
+-        "vendor/re2/parse.cc",
+-        "vendor/re2/perl_groups.cc",
+-        "vendor/re2/prefilter.cc",
+-        "vendor/re2/prefilter_tree.cc",
+-        "vendor/re2/prog.cc",
+-        "vendor/re2/re2.cc",
+-        "vendor/re2/regexp.cc",
+-        "vendor/re2/set.cc",
+-        "vendor/re2/simplify.cc",
+-        "vendor/re2/stringpiece.cc",
+-        "vendor/re2/tostring.cc",
+-        "vendor/re2/unicode_casefold.cc",
+-        "vendor/re2/unicode_groups.cc",
+-        "vendor/util/pcre.cc",
+-        "vendor/util/rune.cc",
+-        "vendor/util/strutil.cc"
+       ],
+       "cflags": [
+         "-std=c++14",
+@@ -45,7 +22,7 @@
+         "-Wno-sign-compare",
+         "-Wno-unused-parameter",
+         "-Wno-missing-field-initializers",
+-        "-Wno-cast-function-type",
++        "-Wno-bad-function-cast",
+         "-O3",
+         "-g"
+       ],
+@@ -54,7 +31,8 @@
+         "NOMINMAX"
+       ],
+       "include_dirs": [
+-        "<!(node -e \"require('nan')\")",
++	"%%PREFIX%%/include",
++	"%%DEVDIR%%/nan",
+         "vendor"
+       ],
+       "xcode_settings": {
diff --git a/textproc/kibana8/files/kibana.in b/textproc/kibana8/files/kibana.in
new file mode 100644
index 000000000000..4b64a40c487a
--- /dev/null
+++ b/textproc/kibana8/files/kibana.in
@@ -0,0 +1,84 @@
+#!/bin/sh
+
+# PROVIDE: kibana
+# REQUIRE: DAEMON
+# BEFORE: LOGIN
+# KEYWORD: shutdown
+
+. /etc/rc.subr
+
+name=kibana
+rcvar=kibana_enable
+
+load_rc_config $name
+
+: ${kibana_enable:="NO"}
+: ${kibana_config:="%%ETCDIR%%/kibana.yml"}
+: ${kibana_user:="www"}
+: ${kibana_group:="www"}
+: ${kibana_log:="/var/log/kibana.log"}
+: ${kibana_syslog_output_enable:="NO"}
+
+start_precmd="kibana_start_precmd"
+reload_cmd="kibana_reload_cmd"
+extra_commands="reload"
+
+if checkyesno kibana_syslog_output_enable; then
+	if [ -n "${kibana_syslog_output_tag}" ]; then
+		kibana_syslog_output_flags="-T ${kibana_syslog_output_tag}"
+	else
+		kibana_syslog_output_flags="-T ${name}"
+	fi
+	if [ -n "${kibana_syslog_output_priority}" ]; then
+		kibana_syslog_output_flags="${kibana_syslog_output_flags} -s ${kibana_syslog_output_priority}"
+	fi
+	if [ -n "${kibana_syslog_output_facility}" ]; then
+		kibana_syslog_output_flags="${kibana_syslog_output_flags} -l ${kibana_syslog_output_facility}"
+	fi
+fi
+
+NODE="%%LOCALBASE%%/bin/node"
+
+required_files="${kibana_config}"
+pidfile="/var/run/${name}-daemon.pid"
+_kpidfile="/var/run/${name}.pid"
+
+command="/usr/sbin/daemon"
+command_args="-f ${kibana_syslog_output_flags} -P ${pidfile} -t ${name} \
+	/usr/bin/env BABEL_DISABLE_CACHE=1 NODE_ENV=production ${kibana_env} \
+	${NODE} --no-warnings --max-http-header-size=65536 \
+	%%WWWDIR%%/src/cli/dist serve \
+	--config ${kibana_config} --log-file ${kibana_log} \
+	--xpack.reporting.enabled=false ${kibana_args}"
+
+kibana_start_precmd()
+{
+	if [ ! -e "${pidfile}" ]; then
+		install -m 0600 -o ${kibana_user} -g ${kibana_group} /dev/null ${pidfile}
+	fi
+	if [ ! -e "${_kpidfile}" ]; then
+		install -m 0600 -o ${kibana_user} -g ${kibana_group} /dev/null ${_kpidfile}
+	fi
+	if [ ! -f ${kibana_log} ]; then
+		install -o ${kibana_user} -g ${kibana_group} -m 640 /dev/null ${kibana_log}
+	fi
+	if [ ! -d %%WWWDIR%%/optimize ]; then
+		install -d -o ${kibana_user} -g ${kibana_group} %%WWWDIR%%/optimize
+	else
+		# We may have installed a plugin as root which will cause files in here
+		# to be owned by root:wheel. Fix with a chown.
+		chown -R ${kibana_user}:${kibana_group} %%WWWDIR%%/optimize
+	fi
+}
+
+kibana_reload_cmd()
+{
+	if [ -z "$rc_pid" ]; then
+		_run_rc_notrunning
+		return 1
+	else
+		pkill -HUP -P ${rc_pid}
+	fi
+}
+
+run_rc_command "$1"
diff --git a/textproc/kibana8/files/patch-config_kibana.yml b/textproc/kibana8/files/patch-config_kibana.yml
new file mode 100644
index 000000000000..9fd5b414496c
--- /dev/null
+++ b/textproc/kibana8/files/patch-config_kibana.yml
@@ -0,0 +1,11 @@
+--- config/kibana.yml.orig	2021-10-26 12:51:47 UTC
++++ config/kibana.yml
+@@ -91,7 +91,7 @@
+ #elasticsearch.logQueries: false
+ 
+ # Specifies the path where Kibana creates the process ID file.
+-#pid.file: /run/kibana/kibana.pid
++pid.file: /var/run/kibana.pid
+ 
+ # Enables you to specify a file where Kibana stores log output.
+ #logging.dest: stdout
diff --git a/textproc/kibana8/files/patch-src_setup__node__env_node__version__validator.js b/textproc/kibana8/files/patch-src_setup__node__env_node__version__validator.js
new file mode 100644
index 000000000000..1bf9870031e9
--- /dev/null
+++ b/textproc/kibana8/files/patch-src_setup__node__env_node__version__validator.js
@@ -0,0 +1,18 @@
+--- src/setup_node_env/node_version_validator.js.orig	2021-10-07 21:19:53 UTC
++++ src/setup_node_env/node_version_validator.js
+@@ -14,11 +14,11 @@ var pkg = require('../../package.json'); // Note: This
+ var currentVersion = process && process.version || null;
+ var rawRequiredVersion = pkg && pkg.engines && pkg.engines.node || null;
+ var requiredVersion = rawRequiredVersion ? 'v' + rawRequiredVersion : rawRequiredVersion;
+-var isVersionValid = !!currentVersion && !!requiredVersion && currentVersion === requiredVersion; // Validates current the NodeJS version compatibility when Kibana starts.
++var isVersionValid = !!currentVersion && !!requiredVersion && currentVersion >= requiredVersion; // Validates current the NodeJS version compatibility when Kibana starts.
+ 
+ if (!isVersionValid) {
+-  var errorMessage = 'Kibana does not support the current Node.js version ' + currentVersion + '. Please use Node.js ' + requiredVersion + '.'; // Actions to apply when validation fails: error report + exit.
++  var errorMessage = 'Kibana does not support the current Node.js version ' + currentVersion + '. Please use Node.js >= ' + requiredVersion + '.'; // Actions to apply when validation fails: error report + exit.
+ 
+   console.error(errorMessage);
+   process.exit(1);
+-}
+\ No newline at end of file
++}
diff --git a/textproc/kibana8/files/pkg-deinstall.in b/textproc/kibana8/files/pkg-deinstall.in
new file mode 100644
index 000000000000..0699ab559805
--- /dev/null
+++ b/textproc/kibana8/files/pkg-deinstall.in
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+case "$2" in
+POST-DEINSTALL)
+	if [ -d %%WWWDIR%%/optimize ]; then
+		/usr/bin/find %%WWWDIR%%/optimize/ -delete
+	fi
+
+	cat <<EOMSG
+
+If %%PORTNAME%%%%PKGNAMESUFFIX%% is being deleted permanently, and you do not wish to keep any
+data that was in the cluster, then you may wish to delete the
+%%WWWDIR%% directory.  This can be done by with the command:
+
+	# rm -rf %%WWWDIR%%
+
+Please ignore this if %%PORTNAME%%%%PKGNAMESUFFIX%% is being upgraded
+EOMSG
+    ;;
+esac
diff --git a/textproc/kibana8/files/pkg-message.in b/textproc/kibana8/files/pkg-message.in
new file mode 100644
index 000000000000..a498c324d45c
--- /dev/null
+++ b/textproc/kibana8/files/pkg-message.in
@@ -0,0 +1,9 @@
+[
+{ type: install
+  message: <<EOM
+NOTICE: kibana port now installs kibana-specific utilities
+as symbolic links into %%BINDIR%%.
+EOM
+}
+]
+
diff --git a/textproc/kibana8/pkg-descr b/textproc/kibana8/pkg-descr
new file mode 100644
index 000000000000..de75d144d7ac
--- /dev/null
+++ b/textproc/kibana8/pkg-descr
@@ -0,0 +1,6 @@
+Kibana is an open source (Apache Licensed), browser based analytics and search
+dashboard for Elasticsearch. Kibana is a snap to setup and start using. Kibana
+strives to be easy to get started with, while also being flexible and powerful,
+just like Elasticsearch.
+
+Kibana 7.x is compatible with Elasticsearch 7.x