git: a27dcf53f655 - main - net/unison251: Add new port to preserve current old unison version.

From: Guido Falsi <madpilot_at_FreeBSD.org>
Date: Sun, 13 Mar 2022 21:28:31 UTC
The branch main has been updated by madpilot:

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

commit a27dcf53f655fa61691b2e89c7a0fedf437a8f47
Author:     Guido Falsi <madpilot@FreeBSD.org>
AuthorDate: 2022-03-13 21:25:43 +0000
Commit:     Guido Falsi <madpilot@FreeBSD.org>
CommitDate: 2022-03-13 21:28:26 +0000

    net/unison251: Add new port to preserve current old unison version.
    
    Preserve old unison 2.51 version as net/unison251 before updating
    to the latest version.
---
 net/Makefile                                       |   1 +
 net/unison251/Makefile                             | 109 +++++++++++++++++++++
 net/unison251/distinfo                             |   3 +
 net/unison251/files/patch-Makefile.OCaml           |  35 +++++++
 net/unison251/files/patch-fsmonitor_linux_Makefile |  20 ++++
 net/unison251/files/unison.desktop.in              |  12 +++
 net/unison251/pkg-descr                            |  11 +++
 net/unison251/pkg-message                          |   8 ++
 net/unison251/pkg-message.nox11                    |   7 ++
 net/unison251/pkg-plist                            |   7 ++
 10 files changed, 213 insertions(+)

diff --git a/net/Makefile b/net/Makefile
index 9dc4134e4e84..3d762fe2bb20 100644
--- a/net/Makefile
+++ b/net/Makefile
@@ -1532,6 +1532,7 @@
     SUBDIR += unison232
     SUBDIR += unison240
     SUBDIR += unison248
+    SUBDIR += unison251
     SUBDIR += unix2tcp
     SUBDIR += urelay
     SUBDIR += uriparser
diff --git a/net/unison251/Makefile b/net/unison251/Makefile
new file mode 100644
index 000000000000..4d3a66d5b3a4
--- /dev/null
+++ b/net/unison251/Makefile
@@ -0,0 +1,109 @@
+# Created by: Dan Pelleg <dpelleg+unison@cs.cmu.edu>
+
+PORTNAME=	unison
+PORTVERSION=	2.51.5
+DISTVERSIONPREFIX=	v
+CATEGORIES=	net
+
+MAINTAINER=	madpilot@FreeBSD.org
+COMMENT=	User-level file synchronization tool
+
+LICENSE=	GPLv3+
+LICENSE_FILE=	${WRKSRC}/COPYING
+
+FLAVORS=	x11 nox11
+FLAVOR?=	${FLAVORS:[1]}
+
+VERSIONSUFFIX=	251
+
+nox11_PKGNAMESUFFIX=		${VERSIONSUFFIX}-nox11
+nox11_CONFLICTS_INSTALL=	unison${VERSIONSUFFIX}
+
+x11_PKGNAMESUFFIX=		${VERSIONSUFFIX}
+x11_CONFLICTS_INSTALL=		unison${VERSIONSUFFIX}-nox11
+x11_BUILD_DEPENDS=	lablgtk2:x11-toolkits/ocaml-lablgtk2 \
+			icotool:graphics/icoutils
+x11_LIB_DEPENDS=	libfontconfig.so:x11-fonts/fontconfig \
+			libfreetype.so:print/freetype2 \
+			libharfbuzz.so:print/harfbuzz
+x11_RUN_DEPENDS=	lablgtk2:x11-toolkits/ocaml-lablgtk2
+
+PLIST_SUB=	PORTVERSION=${PORTVERSION} VERSIONSUFFIX=${VERSIONSUFFIX}
+USES=		gmake localbase
+USE_OCAML=	yes
+WRKSRC_SUBDIR=	src
+NO_OCAML_RUNDEPENDS=yes
+CONFLICTS=	unison-devel
+MAKE_ENV=	CLIBS="${LIBS:S/^-/-ccopt -/}" COFLAGS="${CFLAGS:C/ *(-[^ ]*) */ -ccopt \"\1 \"/gW}"
+ALL_TARGET=	unison all
+
+USE_GITHUB=	yes
+GH_ACCOUNT=	bcpierce00
+
+DOCS=		NEWS README
+
+OPTIONS_DEFINE=		DOCS FSMONITOR
+OPTIONS_DEFAULT?=	FSMONITOR
+
+FSMONITOR_DESC=		Compile and install fsmonitor plugin
+
+OPTIONS_SUB=		YES
+
+FSMONITOR_LIB_DEPENDS=	libinotify.so:devel/libinotify
+
+.if ${FLAVOR} == nox11
+MAKE_ARGS=		UISTYLE=text
+PKGMESSAGE=		${PKGDIR}/pkg-message.nox11
+PLIST_SUB+=		X11="@comment "
+.else
+MAKE_ARGS=		UISTYLE=gtk2
+SUB_FILES=		${PORTNAME}.desktop
+USE_GNOME+=		atk cairo gdkpixbuf2 glib20 gtk20 pango
+USES+=			gettext-runtime gnome
+PLIST_SUB+=		X11=""
+.endif
+
+post-patch-FSMONITOR-off:
+	@${REINPLACE_CMD} -e 's/-include fsmonitor/#&/' \
+		${WRKSRC}/Makefile.OCaml
+
+post-patch-FSMONITOR-on:
+	@${REINPLACE_CMD} \
+		-e '/let suffix = if Util.osType/s/else "" in/else "${VERSIONSUFFIX}" in/' \
+		${WRKSRC}/fswatch.ml
+
+post-patch:
+.if ${FLAVOR} == nox11
+	@${REINPLACE_CMD} -e 's/CFLAGS/COFLAGS/g' \
+		${WRKSRC}/Makefile.OCaml ${WRKSRC}/fsmonitor/linux/Makefile
+.else
+	@${REINPLACE_CMD} -Ee 's@(\+|/)(lablgtk2)@\1site-lib/\2@' \
+		-e 's/CFLAGS/COFLAGS/g' \
+		${WRKSRC}/Makefile.OCaml ${WRKSRC}/fsmonitor/linux/Makefile
+.endif
+
+post-build:
+	(cd ${WRKSRC} && HOME=${WRKSRC} ./unison -selftest -ui text -batch)
+.if ${FLAVOR} == x11
+	@${ECHO} Building text-only version
+	@${ECHO} ${WRKSRC}
+	${SETENV} ${MAKE_ENV} ${MAKE_CMD} -C ${WRKSRC} UISTYLE=text NAME=unison-text
+	@cd ${WRKSRC}/win32rc && ${LOCALBASE}/bin/icotool -x U.ico
+.endif
+
+do-install:
+	${INSTALL_PROGRAM} ${WRKSRC}/${PORTNAME} ${STAGEDIR}${PREFIX}/bin/${PORTNAME}${VERSIONSUFFIX}
+.if ${FLAVOR} == x11
+	${INSTALL_PROGRAM} ${WRKSRC}/${PORTNAME}-text ${STAGEDIR}${PREFIX}/bin/${PORTNAME}${VERSIONSUFFIX}-text
+	${INSTALL_DATA} ${WRKDIR}/${PORTNAME}.desktop ${STAGEDIR}${DESKTOPDIR}/${PORTNAME}${VERSIONSUFFIX}.desktop
+	${INSTALL_DATA} ${WRKSRC}/win32rc/U_4_48x48x32.png ${STAGEDIR}${PREFIX}/share/pixmaps/${PORTNAME}${VERSIONSUFFIX}.png
+.endif
+
+do-install-DOCS-on:
+	@${MKDIR} ${STAGEDIR}${DOCSDIR}
+	cd ${WRKSRC} && ${INSTALL_DATA} ${DOCS} ${STAGEDIR}${DOCSDIR}
+
+do-install-FSMONITOR-on:
+	${INSTALL_PROGRAM} ${WRKSRC}/${PORTNAME}-fsmonitor ${STAGEDIR}${PREFIX}/bin/${PORTNAME}-fsmonitor${VERSIONSUFFIX}
+
+.include <bsd.port.mk>
diff --git a/net/unison251/distinfo b/net/unison251/distinfo
new file mode 100644
index 000000000000..2216a412a298
--- /dev/null
+++ b/net/unison251/distinfo
@@ -0,0 +1,3 @@
+TIMESTAMP = 1639862759
+SHA256 (bcpierce00-unison-v2.51.5_GH0.tar.gz) = 7e876371992ebf890b60f32df880a98a75fe8c47c06b7b2ae2ad36be48013e83
+SIZE (bcpierce00-unison-v2.51.5_GH0.tar.gz) = 1385407
diff --git a/net/unison251/files/patch-Makefile.OCaml b/net/unison251/files/patch-Makefile.OCaml
new file mode 100644
index 000000000000..45859e189c5a
--- /dev/null
+++ b/net/unison251/files/patch-Makefile.OCaml
@@ -0,0 +1,35 @@
+--- Makefile.OCaml.orig	2021-06-23 14:30:30 UTC
++++ Makefile.OCaml
+@@ -34,7 +34,11 @@ ifeq ($(shell uname),OpenBSD)
+ else
+ ifeq ($(shell uname),NetBSD)
+   OSARCH=NetBSD
++else
++ifeq ($(shell uname),FreeBSD)
++  OSARCH=FreeBSD
+ endif
++endif
+ ifeq ($(shell uname),Linux)
+   OSARCH=Linux
+ endif
+@@ -290,6 +294,11 @@ ifeq ($(OSARCH),Linux)
+ INCLFLAGS+=-I fsmonitor -I fsmonitor/linux
+ endif
+ 
++ifeq ($(OSARCH),FreeBSD)
++-include fsmonitor/linux/Makefile src/fsmonitor/linux/Makefile
++INCLFLAGS+=-I fsmonitor -I fsmonitor/linux
++endif
++
+ ifeq ($(OSARCH),solaris)
+ -include fsmonitor/solaris/Makefile src/fsmonitor/solaris/Makefile
+ INCLFLAGS+=-I fsmonitor -I fsmonitor/solaris
+@@ -432,7 +441,7 @@ fswatch.cmi : ubase/prefs.cmi
+ 
+ %.o %.obj: %.c
+ 	@echo "$(CAMLC): $< ---> $@"
+-	$(CAMLC) $(CAMLFLAGS) -ccopt $(OUTPUT_SEL)$(CWD)/$@ -c $(CWD)/$<
++	$(CAMLC) $(CAMLFLAGS) -ccopt $(OUTPUT_SEL)$(CWD)/$@ -c $(CFLAGS) $(CWD)/$<
+ 
+ $(NAME)$(EXEC_EXT): $(CAMLOBJS) $(COBJS)
+ 	@echo Linking $@
diff --git a/net/unison251/files/patch-fsmonitor_linux_Makefile b/net/unison251/files/patch-fsmonitor_linux_Makefile
new file mode 100644
index 000000000000..820041472d23
--- /dev/null
+++ b/net/unison251/files/patch-fsmonitor_linux_Makefile
@@ -0,0 +1,20 @@
+--- fsmonitor/linux/Makefile.orig	2017-03-23 16:47:46 UTC
++++ fsmonitor/linux/Makefile
+@@ -18,6 +18,10 @@ else
+   FSMCAMLLIBS=$(FSMOCAMLLIBS)
+ endif
+ 
++ifeq ($(OSARCH),FreeBSD)
++  CLIBS+=-cclib -linotify
++endif
++
+ buildexecutable:: $(FSMONITOR)$(EXEC_EXT)
+ 
+ $(FSMONITOR)$(EXEC_EXT): $(FSMCAMLOBJS) $(FSMCOBJS)
+@@ -26,4 +30,4 @@ $(FSMONITOR)$(EXEC_EXT): $(FSMCAMLOBJS) $(FSMCOBJS)
+ 
+ clean::
+ 	rm -f $(DIR)/*.cm[iox] $(DIR)/*.o $(DIR)/*~
+-	rm -f $(FSMONITOR)$(EXEC_EXT)
+\ No newline at end of file
++	rm -f $(FSMONITOR)$(EXEC_EXT)
diff --git a/net/unison251/files/unison.desktop.in b/net/unison251/files/unison.desktop.in
new file mode 100644
index 000000000000..789ccaa366b6
--- /dev/null
+++ b/net/unison251/files/unison.desktop.in
@@ -0,0 +1,12 @@
+[Desktop Entry]
+Encoding=UTF-8
+Name=Unison
+GenericName=File-synchronization tool
+Type=Application
+Terminal=false
+StartupNotify=true
+Categories=GTK;Utility;
+Exec=unison
+Icon=unison.png
+Comment=Synchronize files (directories) over different disks (hosts)
+Comment[ru]=Синхронизация файлов (каталогов) на нескольких дисках (компьютерах)
diff --git a/net/unison251/pkg-descr b/net/unison251/pkg-descr
new file mode 100644
index 000000000000..0fdae72e6019
--- /dev/null
+++ b/net/unison251/pkg-descr
@@ -0,0 +1,11 @@
+Unison is a file-synchronization tool for Unix and Windows. It allows two
+replicas of a collection of files and directories to be stored on different
+hosts (or different disks on the same host), modified separately, and then
+brought up to date by propagating the changes in each replica to the other.
+
+Unison shares a number of features with tools such as configuration
+management packages (CVS, PRCS, etc.) distributed filesystems (Coda, etc.)
+uni-directional mirroring utilities (rsync, etc.) and other synchronizers
+(Intellisync, Reconcile, etc).
+
+WWW: https://www.cis.upenn.edu/~bcpierce/unison/
diff --git a/net/unison251/pkg-message b/net/unison251/pkg-message
new file mode 100644
index 000000000000..1795b612e0a8
--- /dev/null
+++ b/net/unison251/pkg-message
@@ -0,0 +1,8 @@
+[
+{ type: install
+  message: <<EOM
+Together with a gtk-enabled version, a text-only unison-text binary
+is installed as it depends on a smaller number of libraries.
+EOM
+}
+]
diff --git a/net/unison251/pkg-message.nox11 b/net/unison251/pkg-message.nox11
new file mode 100644
index 000000000000..31b179babd46
--- /dev/null
+++ b/net/unison251/pkg-message.nox11
@@ -0,0 +1,7 @@
+[
+{ type: install
+  message: <<EOM
+A text-only unison binary is installed.
+EOM
+}
+]
diff --git a/net/unison251/pkg-plist b/net/unison251/pkg-plist
new file mode 100644
index 000000000000..18aa92847fa3
--- /dev/null
+++ b/net/unison251/pkg-plist
@@ -0,0 +1,7 @@
+bin/unison%%VERSIONSUFFIX%%
+%%FSMONITOR%%bin/unison-fsmonitor%%VERSIONSUFFIX%%
+%%X11%%share/applications/unison%%VERSIONSUFFIX%%.desktop
+%%X11%%bin/unison%%VERSIONSUFFIX%%-text
+%%X11%%share/pixmaps/unison%%VERSIONSUFFIX%%.png
+%%PORTDOCS%%%%DOCSDIR%%/NEWS
+%%PORTDOCS%%%%DOCSDIR%%/README