git: 5a22bf5e34cc - main - editors/bee-host: host part of the Browser's Exernal Editor extension

From: Thierry Thomas <thierry_at_FreeBSD.org>
Date: Fri, 12 Aug 2022 11:26:58 UTC
The branch main has been updated by thierry:

URL: https://cgit.FreeBSD.org/ports/commit/?id=5a22bf5e34cc0f56ab8821091a92dfc89d0de041

commit 5a22bf5e34cc0f56ab8821091a92dfc89d0de041
Author:     Thierry Thomas <thierry@FreeBSD.org>
AuthorDate: 2022-08-12 09:01:42 +0000
Commit:     Thierry Thomas <thierry@FreeBSD.org>
CommitDate: 2022-08-12 11:26:33 +0000

    editors/bee-host: host part of the Browser's Exernal Editor extension
    
    BeeCtl is the host part of Chrome-bee, a Chrome/Firefox extension that
    allows to edit text fields with an external editor.
---
 editors/Makefile                            |  1 +
 editors/bee-host/Makefile                   | 25 ++++++++++
 editors/bee-host/distinfo                   |  3 ++
 editors/bee-host/files/patch-CMakeLists.txt | 73 +++++++++++++++++++++++++++++
 editors/bee-host/files/patch-vars.sh        | 13 +++++
 editors/bee-host/pkg-descr                  |  8 ++++
 editors/bee-host/pkg-plist                  |  5 ++
 7 files changed, 128 insertions(+)

diff --git a/editors/Makefile b/editors/Makefile
index cd1343505a36..1b3da9a033ce 100644
--- a/editors/Makefile
+++ b/editors/Makefile
@@ -9,6 +9,7 @@
     SUBDIR += apel
     SUBDIR += asedit
     SUBDIR += beav
+    SUBDIR += bee-host
     SUBDIR += biew
     SUBDIR += bitedit
     SUBDIR += boiling-egg
diff --git a/editors/bee-host/Makefile b/editors/bee-host/Makefile
new file mode 100644
index 000000000000..1b803b8e5917
--- /dev/null
+++ b/editors/bee-host/Makefile
@@ -0,0 +1,25 @@
+PORTNAME=	bee-host
+PORTVERSION=	1.3.4
+CATEGORIES=	editors www
+
+MAINTAINER=	thierry@FreeBSD.org
+COMMENT=	Host application for Browser's Exernal Editor extension
+
+LICENSE=	MIT
+
+LIB_DEPENDS=	libcjson.so:devel/libcjson
+
+USE_GITHUB=	yes
+GH_ACCOUNT=	rosmanov
+
+USES=		cmake:noninja localbase:ldflags python shebangfix
+SHEBANG_GLOB=	*.sh
+LDFLAGS+=	-lcjson -lcjson_utils
+CMAKE_ARGS=	-DCMAKE_DOC_DIR:PATH=${DOCSDIR_REL}
+
+OPTIONS_DEFINE=	DOCS
+
+pre-configure:
+	${REINPLACE_CMD} -e 's|%%LOCALBASE%%|${LOCALBASE:C|/||}|' ${WRKSRC}/vars.sh
+
+.include <bsd.port.mk>
diff --git a/editors/bee-host/distinfo b/editors/bee-host/distinfo
new file mode 100644
index 000000000000..f9693402fffa
--- /dev/null
+++ b/editors/bee-host/distinfo
@@ -0,0 +1,3 @@
+TIMESTAMP = 1660238948
+SHA256 (rosmanov-bee-host-1.3.4_GH0.tar.gz) = 715ab4edff8900dddef27303a5b19060b680cb0c341e4e3d6def4d04eeeb591d
+SIZE (rosmanov-bee-host-1.3.4_GH0.tar.gz) = 30742
diff --git a/editors/bee-host/files/patch-CMakeLists.txt b/editors/bee-host/files/patch-CMakeLists.txt
new file mode 100644
index 000000000000..b14ecb0976a2
--- /dev/null
+++ b/editors/bee-host/files/patch-CMakeLists.txt
@@ -0,0 +1,73 @@
+--- CMakeLists.txt.orig	2022-04-07 09:03:56 UTC
++++ CMakeLists.txt
+@@ -33,27 +33,7 @@ endif()
+ 
+ set(EXTERNAL_DIR ${CMAKE_CURRENT_BINARY_DIR}/external)
+ 
+-# cJSON and cJSONUtils
+-ExternalProject_Add(cjson
+-  GIT_REPOSITORY "https://github.com/DaveGamble/cJSON"
+-  GIT_TAG "v1.7.14"
+-  PREFIX "${EXTERNAL_DIR}/cJSON"
+-  BUILD_IN_SOURCE 1
+-  TEST_COMMAND ""
+-  INSTALL_COMMAND ""
+-  CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
+-    -DBUILD_SHARED_AND_STATIC_LIBS=On
+-    -DBUILD_SHARED_LIBS=Off
+-    -DENABLE_CJSON_TEST=Off
+-    -DENABLE_CJSON_UTILS=On
+-    -DENABLE_TARGET_EXPORT=On
+-  )
+-ExternalProject_Get_Property(cjson source_dir)
+-ExternalProject_Get_Property(cjson binary_dir)
+-ExternalProject_Get_Property(cjson download_dir)
+-set(CJSON_SOURCE_DIR "${source_dir}")
+-set(CJSON_BINARY_DIR "${binary_dir}")
+-set(CJSON_DOWNLOAD_DIR "${download_dir}")
++# cJSON and cJSONUtils installed from devel/libcjson
+ 
+ # beectl
+ set(BEECTL_SRCS
+@@ -64,21 +44,13 @@ set(BEECTL_SRCS
+   src/mkstemps.c
+   # This is nasty, but I couldn't find a way to use CMAKE_TOOLCHAIN_FILE
+   # for the external project (see comments below.)
+-  "${CJSON_SOURCE_DIR}/cJSON.c"
+   )
+ 
+ add_executable(beectl ${BEECTL_SRCS})
+ 
+-# Workaround for CMake versions which require the cJSON.c file to exist before
+-# downloading the external project.
+-add_custom_command(TARGET beectl PRE_BUILD
+-    BYPRODUCTS "${CJSON_SOURCE_DIR}/cJSON.c"
+-    COMMAND touch "${CJSON_SOURCE_DIR}/cJSON.c")
+-
+ target_compile_features(beectl PRIVATE c_variadic_macros)
+ target_include_directories(beectl PRIVATE "${CJSON_DOWNLOAD_DIR}")
+ set_property(TARGET beectl PROPERTY C_STANDARD 11) # C11
+-add_dependencies(beectl cjson)
+ 
+ # The following would be better approach than including cJSON files in our
+ # source list. But the build fails when cross-compiling, since
+@@ -103,8 +75,8 @@ set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURC
+ 
+ message(STATUS "CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX}")
+ set(BEECTL_MANIFEST_TARGET_PATH "${CMAKE_INSTALL_PREFIX}/bin/beectl")
+-set(BEECTL_CHROME_MANIFEST_DIR "etc/opt/chrome/native-messaging-hosts")
+-set(BEECTL_FIREFOX_MANIFEST_DIR "usr/lib/mozilla/native-messaging-hosts")
++set(BEECTL_CHROME_MANIFEST_DIR "etc/chrome/native-messaging-hosts")
++set(BEECTL_FIREFOX_MANIFEST_DIR "lib/mozilla/native-messaging-hosts")
+ 
+ # RPM package properties
+ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/beectl.spec.in"
+@@ -226,7 +198,7 @@ elseif(uppercase_CMAKE_SYSTEM_NAME MATCHES DARWIN)
+         COMPONENT config)
+ else(uppercase_CMAKE_SYSTEM_NAME MATCHES WINDOWS)
+     # Install host app
+-    install(TARGETS beectl RUNTIME DESTINATION usr/local/bin COMPONENT applications)
++    install(TARGETS beectl RUNTIME DESTINATION bin COMPONENT applications)
+ 
+     configure_file(
+         chrome-com.ruslan_osmanov.bee.json.in
diff --git a/editors/bee-host/files/patch-vars.sh b/editors/bee-host/files/patch-vars.sh
new file mode 100644
index 000000000000..12201417b955
--- /dev/null
+++ b/editors/bee-host/files/patch-vars.sh
@@ -0,0 +1,13 @@
+--- vars.sh.orig	2022-04-07 09:03:56 UTC
++++ vars.sh
+@@ -45,8 +45,8 @@ case "$kernel" in
+   *)
+     if [ $EUID == 0 ]; then
+       # If superuser
+-      chrome_target_manifest_dir='/etc/opt/chrome/native-messaging-hosts'
+-      firefox_target_manifest_dir='/usr/lib/mozilla/native-messaging-hosts'
++      chrome_target_manifest_dir='%%LOCALBASE%%/chrome/native-messaging-hosts'
++      firefox_target_manifest_dir='%%LOCALBASE%%/lib/mozilla/native-messaging-hosts'
+     else
+       # If normal user
+       chrome_target_manifest_dir="$HOME/.config/google-chrome/NativeMessagingHosts"
diff --git a/editors/bee-host/pkg-descr b/editors/bee-host/pkg-descr
new file mode 100644
index 000000000000..d91a8c6d1bf5
--- /dev/null
+++ b/editors/bee-host/pkg-descr
@@ -0,0 +1,8 @@
+BeeCtl, a native messaging host application for Browser's Exernal Editor
+extension (https://github.com/rosmanov/chrome-bee).
+
+When installing the add-on External Editor for Firefox (or Chrome),
+https://addons.mozilla.org/en-US/firefox/addon/external-editor/
+this is the required host part.
+
+WWW: https://github.com/rosmanov/bee-host
diff --git a/editors/bee-host/pkg-plist b/editors/bee-host/pkg-plist
new file mode 100644
index 000000000000..cd3eb79eefcb
--- /dev/null
+++ b/editors/bee-host/pkg-plist
@@ -0,0 +1,5 @@
+bin/beectl
+etc/chrome/native-messaging-hosts/com.ruslan_osmanov.bee.json
+lib/mozilla/native-messaging-hosts/com.ruslan_osmanov.bee.json
+%%PORTDOCS%%%%DOCSDIR%%/LICENSE
+%%PORTDOCS%%%%DOCSDIR%%/README.md