git: a25f1f676816 - main - net/csync2: re-add net/csync2 - cluster synchronization tool

Kirill Ponomarev krion at FreeBSD.org
Sun Jun 20 12:11:01 UTC 2021


The branch main has been updated by krion:

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

commit a25f1f676816fa1481d4d611305ec7762989cec9
Author:     Kirill Ponomarev <krion at FreeBSD.org>
AuthorDate: 2021-06-20 12:09:40 +0000
Commit:     Kirill Ponomarev <krion at FreeBSD.org>
CommitDate: 2021-06-20 12:09:40 +0000

    net/csync2: re-add net/csync2 - cluster synchronization tool
---
 net/csync2/Makefile             | 47 ++++++++++++++++++++++++++++
 net/csync2/distinfo             |  3 ++
 net/csync2/files/csync2.in      | 68 +++++++++++++++++++++++++++++++++++++++++
 net/csync2/files/patch-csync2.c | 21 +++++++++++++
 net/csync2/files/patch-csync2.h | 11 +++++++
 net/csync2/files/patch-rsync.c  | 30 ++++++++++++++++++
 net/csync2/files/pkg-install.in | 60 ++++++++++++++++++++++++++++++++++++
 net/csync2/pkg-descr            | 11 +++++++
 net/csync2/pkg-plist            |  9 ++++++
 9 files changed, 260 insertions(+)

diff --git a/net/csync2/Makefile b/net/csync2/Makefile
new file mode 100644
index 000000000000..c963741fac70
--- /dev/null
+++ b/net/csync2/Makefile
@@ -0,0 +1,47 @@
+PORTNAME=	csync2
+PORTVERSION=	2.0
+PORTREVISION=	3
+CATEGORIES=	net
+
+MAINTAINER=	olevole at olevole.ru
+COMMENT=	Cluster synchronization tool
+
+LICENSE=	GPLv2
+LICENSE_FILE=	${WRKSRC}/COPYING
+
+LIB_DEPENDS=	librsync.so:net/librsync \
+		libgnutls.so:security/gnutls \
+		libsqlite3.so:databases/sqlite3
+
+USES=		autoreconf pkgconfig shebangfix
+SHEBANG_FILES=	csync2-compare
+
+OPTIONS_DEFINE=	CSYNC2_COMPARE DOCS
+OPTIONS_SUB=	yes
+CSYNC2_COMPARE_DESC=		Install csync2-compare script
+CSYNC2_COMPARE_RUN_DEPENDS=	bash:shells/bash
+
+USE_GITHUB=	yes
+GH_ACCOUNT=	LINBIT
+GH_PROJECT=	csync2
+GH_TAGNAME=	a8d38eb
+
+GNU_CONFIGURE=	yes
+CONFIGURE_ARGS=	ac_cv_prog_PDFLATEX=
+CPPFLAGS+=	-I${LOCALBASE}/include
+LIBS+=		-L${LOCALBASE}/lib
+
+USE_RC_SUBR=	csync2
+
+SUB_FILES=	pkg-install
+
+post-patch:
+	@${REINPLACE_CMD} -e 's|(localstatedir)/lib|(localstatedir)/db|' \
+		-e 's/-ldl//' ${WRKSRC}/Makefile.am
+
+post-install:
+	${MV} ${STAGEDIR}${PREFIX}/etc/csync2.cfg \
+		${STAGEDIR}${PREFIX}/etc/csync2.cfg.sample
+	${MKDIR} ${STAGEDIR}/var/backups/csync2
+
+.include <bsd.port.mk>
diff --git a/net/csync2/distinfo b/net/csync2/distinfo
new file mode 100644
index 000000000000..80f35dd5851f
--- /dev/null
+++ b/net/csync2/distinfo
@@ -0,0 +1,3 @@
+TIMESTAMP = 1624175490
+SHA256 (LINBIT-csync2-2.0-a8d38eb_GH0.tar.gz) = d2dd33259aa86e1cc8e1866e5cfb9d5af07c59170a179d06e25b92a0a0d1a178
+SIZE (LINBIT-csync2-2.0-a8d38eb_GH0.tar.gz) = 108311
diff --git a/net/csync2/files/csync2.in b/net/csync2/files/csync2.in
new file mode 100644
index 000000000000..85a100d1e94a
--- /dev/null
+++ b/net/csync2/files/csync2.in
@@ -0,0 +1,68 @@
+#!/bin/sh
+#
+# PROVIDE: csync2
+# REQUIRE: LOGIN
+# KEYWORD: shutdown
+
+# Add the following line to /etc/rc.conf to enable csync2:
+# csync2_enable="YES"
+#
+# Optional configuration of csync2:
+# csync2_cfg (str):		Path to csync2 main configuration.
+#				Default is %%PREFIX%%/etc/csync2.cfg.
+# csync2_flags (str):		Extra flags passed to csync2 program.
+#				Default to "-ii -v".
+# csync2_logfile (str):		Path to logfile where daemon' output logged to.
+#				Default to "/var/log/csync2.log".
+
+. /etc/rc.subr
+
+name="csync2"
+rcvar=csync2_enable
+
+pidfile=/var/run/${name}.pid
+command=%%PREFIX%%/sbin/csync2
+
+start_cmd="csync2_start"
+
+load_rc_config $name
+: ${csync2_enable="NO"}
+: ${csync2_flags="-ii -v"}
+: ${csync2_cfg="%%PREFIX%%/etc/csync2.cfg"}
+: ${csync2_logfile="/var/log/csync2.log"}
+
+required_files="${csync2_cfg}"
+
+csync2_check_keys()
+{
+	[ -f "${csync2_cfg}" ] || return 1
+
+	_key=`grep '^[[:blank:]]*key[[:space:]]\+.\+;\?$' ${csync2_cfg} |\
+		awk '{print($2)}'`
+	[ -n "${_key}" ] || return 1
+	
+	for _file in ${_key}; do
+		_file=${_file%;}
+		[ ! -f "${_file}" ] && \
+		warn "PSK specified but not found, use csync2 -k ${_file} to create it."
+	done
+
+	return 0
+}
+
+csync2_start() {
+
+	if [ -z "$rc_fast" -a -n "$rc_pid" ]; then
+		echo 1>&2 "${name} already running? (pid=$rc_pid)."
+		return 1
+	fi
+
+	csync2_check_keys
+
+	check_startmsgs && echo "Starting ${name}."
+
+	/usr/sbin/daemon -p ${pidfile} \
+		${command} ${csync2_flags} >> ${csync2_logfile} 2>&1
+}
+
+run_rc_command "$1"
diff --git a/net/csync2/files/patch-csync2.c b/net/csync2/files/patch-csync2.c
new file mode 100644
index 000000000000..82a700578f63
--- /dev/null
+++ b/net/csync2/files/patch-csync2.c
@@ -0,0 +1,21 @@
+--- csync2.c.orig	2013-05-02 12:58:04 UTC
++++ csync2.c
+@@ -256,7 +256,7 @@ static int csync_server_bind(void)
+ 	struct addrinfo hints;
+ 	struct addrinfo *result, *rp;
+ 	int save_errno;
+-	int sfd = -1, s, on = 1;
++	int sfd = -1, s, off = 0, on = 1;
+ 	memset(&hints, 0, sizeof(struct addrinfo));
+ 	hints.ai_family = AF_UNSPEC;	/* Allow IPv4 or IPv6 */
+ 	hints.ai_socktype = SOCK_STREAM;
+@@ -284,6 +284,9 @@ static int csync_server_bind(void)
+ 			goto error;
+ 		if (setsockopt(sfd, IPPROTO_TCP, TCP_NODELAY, &on, (socklen_t) sizeof(on)) < 0)
+ 			goto error;
++		if (rp->ai_family == AF_INET6)
++			if (setsockopt(sfd, IPPROTO_IPV6, IPV6_V6ONLY, &off, (socklen_t) sizeof(off)) < 0)
++				goto error;
+ 
+ 		if (bind(sfd, rp->ai_addr, rp->ai_addrlen) == 0)
+ 			break;	/* Success */
diff --git a/net/csync2/files/patch-csync2.h b/net/csync2/files/patch-csync2.h
new file mode 100644
index 000000000000..c6d392192ac5
--- /dev/null
+++ b/net/csync2/files/patch-csync2.h
@@ -0,0 +1,11 @@
+--- csync2.h.orig	2013-05-02 12:58:14 UTC
++++ csync2.h
+@@ -80,7 +80,7 @@ extern int csync_perm(const char *filena
+ 
+ extern void csync_printtime();
+ extern void csync_printtotaltime();
+-extern void csync_fatal(const char *fmt, ...);
++extern void csync_fatal(const char *fmt, ...) __dead2;
+ extern void csync_debug(int lv, const char *fmt, ...);
+ 
+ #define csync_debug_ping(N) \
diff --git a/net/csync2/files/patch-rsync.c b/net/csync2/files/patch-rsync.c
new file mode 100644
index 000000000000..c8f47627d5cb
--- /dev/null
+++ b/net/csync2/files/patch-rsync.c
@@ -0,0 +1,30 @@
+--- rsync.c.orig	2015-03-09 14:08:51 UTC
++++ rsync.c
+@@ -41,6 +41,7 @@
+ 
+ /* This has been taken from rsync:lib/compat.c */
+ 
++#if 0
+ /**
+  * Like strncpy but does not 0 fill the buffer and always null
+  * terminates.
+@@ -61,6 +62,7 @@ static size_t strlcpy(char *d, const cha
+         }
+         return ret;
+ }
++#endif
+ 
+ /* splits filepath at the last '/', if any, like so:
+  *	dirname		basename	filepath
+@@ -117,7 +119,10 @@ int mkpath(const char *path, mode_t mode
+ 		return -1;
+ 	}
+ 
+-	strlcpy(temp,path,strlen(path));
++	if(strlcpy(temp,path,sizeof(temp))>=sizeof(temp)) {
++		csync_debug(1,"path too long: %s",path);
++		return -1;
++	}
+ 	csync_debug(1,"mkpath full path: %s",temp);
+ 	for( remaining=strchr(temp+1, '/'); remaining!=NULL; remaining=strchr(remaining+1, '/') ){
+ 		*remaining='\0';
diff --git a/net/csync2/files/pkg-install.in b/net/csync2/files/pkg-install.in
new file mode 100644
index 000000000000..9401f90b79e0
--- /dev/null
+++ b/net/csync2/files/pkg-install.in
@@ -0,0 +1,60 @@
+#!/bin/sh
+
+create_cert() {
+
+	_errlog=`mktemp /tmp/.${0##*/}.XXXXX`
+	code=0
+
+	exec 3>&2 2>${_errlog}
+
+	openssl genrsa -out ${PKG_PREFIX}/etc/csync2_ssl_key.pem 1024 || code=1
+	yes '' | openssl req -new -key ${PKG_PREFIX}/etc/csync2_ssl_key.pem \
+		-out /tmp/csync2_ssl_cert.csr || code=1
+	openssl x509 -req -days 600 -in /tmp/csync2_ssl_cert.csr \
+		-signkey ${PKG_PREFIX}/etc/csync2_ssl_key.pem \
+		-out ${PKG_PREFIX}/etc/csync2_ssl_cert.pem || code=1
+
+	rm -f /tmp/csync2_ssl_cert.csr
+
+	if [ ${code} -ne 0 ]; then
+		echo "csync2: OpenSSL error occurred:"
+		echo
+		cat ${_errlog}
+		echo
+		rm -f ${_errlog}
+		return 1
+	fi
+
+	exec 2>&3
+
+	rm -f ${_errlog}
+
+	chmod 600 ${PKG_PREFIX}/etc/csync2_ssl_key.pem \
+		${PKG_PREFIX}/etc/csync2_ssl_cert.pem
+
+	echo "csync2: RSA certificate-key pair installed."
+
+	return 0
+}
+
+pre_install() {
+	return 0
+}
+
+post_install() {
+
+	[ -n "${PACKAGE_BUILDING}" ] && return 0
+
+	if [ ! -f ${PKG_PREFIX}/etc/csync2_ssl_cert.pem ]; then
+		create_cert || return $?
+	fi
+
+	return 0
+}
+
+[ $# -eq 2 ] || exit 0
+
+case $2 in
+	"PRE-INSTALL") pre_install ;;
+	"POST-INSTALL") post_install ;;
+esac
diff --git a/net/csync2/pkg-descr b/net/csync2/pkg-descr
new file mode 100644
index 000000000000..72a0058fbc07
--- /dev/null
+++ b/net/csync2/pkg-descr
@@ -0,0 +1,11 @@
+Csync2 is a cluster synchronization tool. It can be used to keep files on
+multiple hosts in a cluster in sync. Csync2 can handle complex setups with
+much more than just 2 hosts, handle file deletions and can detect
+conflicts.
+
+It is expedient for HA-clusters, HPC-clusters, COWs and server farms. If
+you are looking for a tool to sync your laptop with your workstation, you
+better have a look at Unison (http://www.cis.upenn.edu/~bcpierce/unison/)
+too.
+
+WWW: https://github.com/LINBIT/csync2/
diff --git a/net/csync2/pkg-plist b/net/csync2/pkg-plist
new file mode 100644
index 000000000000..17e61f7124ff
--- /dev/null
+++ b/net/csync2/pkg-plist
@@ -0,0 +1,9 @@
+ at sample etc/csync2.cfg.sample
+man/man1/csync2.1.gz
+sbin/csync2
+%%CSYNC2_COMPARE%%sbin/csync2-compare
+%%PORTDOCS%%%%DOCSDIR%%/AUTHORS
+%%PORTDOCS%%%%DOCSDIR%%/ChangeLog
+%%PORTDOCS%%%%DOCSDIR%%/README
+ at dir(,,700) /var/db/csync2
+ at dir(,,700) /var/backups/csync2


More information about the dev-commits-ports-main mailing list