git: 54df541db5b4 - main - net/quagga: introduce compatible installation mode

From: Eugene Grosbein <eugen_at_FreeBSD.org>
Date: Tue, 03 Jan 2023 08:50:12 UTC
The branch main has been updated by eugen:

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

commit 54df541db5b43bad19051ca8c5a6d0d8667fd8b5
Author:     Eugene Grosbein <eugen@FreeBSD.org>
AuthorDate: 2023-01-03 08:38:14 +0000
Commit:     Eugene Grosbein <eugen@FreeBSD.org>
CommitDate: 2023-01-03 08:50:02 +0000

    net/quagga: introduce compatible installation mode
    
    This change makes it possible to build a package not conflicting
    with frr, pimd nor openbgpd introducing new port option LEGACY
    enabled by default. If disabled, the package is called quagga-compat
    and has following differences:
    
    * /usr/local/bin/vtysh renamed to /usr/local/bin/qvtysh;
    * libraries install to /usr/local/quagga/lib instead of /usr/local/lib;
    * binaries install to /usr/local/quagga/sbin instead of /usr/local/sbin.
    * manual pages install to /usr/local/quagga/man;
    
    This is intended to ease migration from quagga to frr
    making it possible to stop quagga and start frr at once
    and fall back quickly if things go wrong.
    
    Also, remove unneeded USES=ssl. Add other distfile mirrors.
---
 net/quagga/Makefile                              | 42 ++++++++++--
 net/quagga/{pkg-message => files/pkg-message.in} |  2 +
 net/quagga/files/quagga.in                       |  4 +-
 net/quagga/files/watchquagga.in                  |  2 +-
 net/quagga/pkg-plist                             | 84 ++++++++++++------------
 5 files changed, 82 insertions(+), 52 deletions(-)

diff --git a/net/quagga/Makefile b/net/quagga/Makefile
index edce72330110..84eeeebf2b27 100644
--- a/net/quagga/Makefile
+++ b/net/quagga/Makefile
@@ -1,8 +1,10 @@
 PORTNAME=	quagga
 PORTVERSION=	1.2.4
-PORTREVISION=	10
+PORTREVISION=	11
 CATEGORIES=	net
-MASTER_SITES=	https://github.com/Quagga/quagga/releases/download/${DISTNAME}/
+MASTER_SITES=	https://github.com/Quagga/quagga/releases/download/${DISTNAME}/ \
+		http://www.grosbein.net/freebsd/distfiles/ \
+		LOCAL/eugen
 
 MAINTAINER=	eugen@FreeBSD.org
 COMMENT=	Free RIPv1, RIPv2, OSPFv2, BGP4, IS-IS route software
@@ -12,27 +14,26 @@ LICENSE=	GPLv2+
 LICENSE_FILE=	${WRKSRC}/COPYING
 
 USES=		compiler:c11 cpe gmake libtool makeinfo \
-		perl5 readline ssl
+		perl5 readline
 
-CONFLICTS=	frr7 openbgpd pimd zebra
 
 GNU_CONFIGURE=	yes
 CONFIGURE_ENV+=	GAWK=${AWK}
 
 CFLAGS+=	-fcommon
 INSTALL_TARGET=	install-strip
-USE_LDCONFIG=	yes
 USE_PERL5=	build
 
 INFO=		quagga
 
-OPTIONS_DEFINE=	ISISD PIMD PAM RTADV SNMP TCPSOCKETS DLMALLOC \
+OPTIONS_DEFINE=	LEGACY ISISD PIMD PAM RTADV SNMP TCPSOCKETS DLMALLOC \
 		NO_BGP_ANNOUNCE OSPF_NEXTHOP ISIS_TOPOLOGY EXAMPLES
 # IRDP needs something freebsd does not seem to have:
 # configure: error: 'IRDP requires in_pktinfo at the moment!'
-OPTIONS_DEFAULT=	ISISD PIMD RTADV
+OPTIONS_DEFAULT=	LEGACY ISISD PIMD RTADV
 OPTIONS_SUB=	yes
 
+LEGACY_DESC=		Install to legacy paths (conflicts with FRR etc.)
 PIMD_DESC=		PIM-SSM multicast routing
 IRDP_DESC=		Enable IRDP server support
 ISISD_DESC=		Enable ISIS daemon (beta)
@@ -84,6 +85,11 @@ NO_BGP_ANNOUNCE_CONFIGURE_OFF=	--enable-bgp-announce
 
 USE_RC_SUBR=	quagga watchquagga
 
+LEGACY_SUB_LIST=	VTYSH=vtysh  N=
+LEGACY_SUB_LIST_OFF=	VTYSH=qvtysh N=${PORTNAME}/
+LEGACY_PLIST_SUB=	VTYSH=vtysh  N=
+LEGACY_PLIST_SUB_OFF=	VTYSH=qvtysh N=${PORTNAME}/
+
 SUB_LIST+=	LOCALSTATE_DIR=${LOCALSTATE_DIR} \
 		SYSCONF_DIR=${SYSCONF_DIR}
 
@@ -106,4 +112,26 @@ pre-everything::
 post-install:
 	${MKDIR} ${STAGEDIR}${LOCALSTATE_DIR} ${STAGEDIR}${SYSCONF_DIR}
 
+.include <bsd.port.options.mk>
+
+.if ${PORT_OPTIONS:MLEGACY}
+CONFLICTS=		frr7 openbgpd pimd
+USE_LDCONFIG=		yes
+.else
+PKGNAMESUFFIX=		-compat
+QPREFIX=		${PREFIX}/${PORTNAME}
+GNU_CONFIGURE_PREFIX=	${QPREFIX}
+MANPREFIX=		${QPREFIX}
+MANDIRS=		${QPREFIX}/man
+USE_LDCONFIG=		${QPREFIX}/lib
+CONFIGURE_ARGS+=	--datarootdir=${QPREFIX} \
+			--bindir=${PREFIX}/bin \
+			--includedir=${PREFIX}/include
+
+post-install-LEGACY-off:
+	${MV} ${STAGEDIR}${PREFIX}/bin/vtysh ${STAGEDIR}${PREFIX}/bin/qvtysh
+	${MV} ${STAGEDIR}${QPREFIX}/${INFO_PATH}/${PORTNAME}* ${STAGEDIR}${PREFIX}/${INFO_PATH}/
+
+.endif
+
 .include <bsd.port.mk>
diff --git a/net/quagga/pkg-message b/net/quagga/files/pkg-message.in
similarity index 86%
rename from net/quagga/pkg-message
rename to net/quagga/files/pkg-message.in
index 39a462ff3210..3c1b5716e9b6 100644
--- a/net/quagga/pkg-message
+++ b/net/quagga/files/pkg-message.in
@@ -1,6 +1,8 @@
 [
 { type: install
   message: <<EOM
+vtysh is installed as %%PREFIX%%/bin/%%VTYSH%%
+
 To enable quagga, add the following lines to rc.conf:
 
 defaultrouter="NO"
diff --git a/net/quagga/files/quagga.in b/net/quagga/files/quagga.in
index 29ad459f17d2..82a814a82a4a 100644
--- a/net/quagga/files/quagga.in
+++ b/net/quagga/files/quagga.in
@@ -82,7 +82,7 @@ do_cmd()
 	local ret
 	ret=0
 	for daemon in ${quagga_daemons}; do
-	    command=%%PREFIX%%/sbin/${daemon}
+	    command=%%PREFIX%%/%%N%%sbin/${daemon}
 	    required_files=%%SYSCONF_DIR%%/${daemon}.conf
 	    pidfile=%%LOCALSTATE_DIR%%/${daemon}.pid
 	    if [ ${quagga_cmd} = "restart" -o ${quagga_cmd} = "start" ]; then
@@ -101,7 +101,7 @@ do_cmd()
 	done
 	if checkyesno quagga_vtysh_boot; then
 	    echo "Booting for integrated-vtysh-config..."
-	    %%PREFIX%%/bin/vtysh -b
+	    %%PREFIX%%/bin/%%VTYSH%% -b
 	fi
 	return ${ret}
 }
diff --git a/net/quagga/files/watchquagga.in b/net/quagga/files/watchquagga.in
index 6e1176f483dc..737a9f3cc6ba 100644
--- a/net/quagga/files/watchquagga.in
+++ b/net/quagga/files/watchquagga.in
@@ -21,7 +21,7 @@ stop_postcmd="rm -f $pidfile"
 
 watchquagga_enable=${watchquagga_enable:-"NO"}
 
-command=%%PREFIX%%/sbin/watchquagga
+command=%%PREFIX%%/%%N%%sbin/watchquagga
 pidfile=%%LOCALSTATE_DIR%%/watchquagga.pid
 
 run_rc_command "$1"
diff --git a/net/quagga/pkg-plist b/net/quagga/pkg-plist
index c25931a835d9..a5f68a9cbc8e 100644
--- a/net/quagga/pkg-plist
+++ b/net/quagga/pkg-plist
@@ -1,6 +1,6 @@
 bin/bgp_btoa
 %%PIMD%%bin/test_igmpv3_join
-bin/vtysh
+bin/%%VTYSH%%
 include/quagga/buffer.h
 include/quagga/checksum.h
 include/quagga/command.h
@@ -54,47 +54,47 @@ include/quagga/workqueue.h
 include/quagga/zassert.h
 include/quagga/zclient.h
 include/quagga/zebra.h
-lib/libfpm_pb.a
-lib/libfpm_pb.so
-lib/libfpm_pb.so.0
-lib/libfpm_pb.so.0.0.0
-lib/libospf.a
-lib/libospf.so
-lib/libospf.so.0
-lib/libospf.so.0.0.0
-lib/libospfapiclient.a
-lib/libospfapiclient.so
-lib/libospfapiclient.so.0
-lib/libospfapiclient.so.0.0.0
-lib/libquagga_pb.a
-lib/libquagga_pb.so
-lib/libquagga_pb.so.0
-lib/libquagga_pb.so.0.0.0
-lib/libzebra.a
-lib/libzebra.so
-lib/libzebra.so.1
-lib/libzebra.so.1.0.0
-man/man1/vtysh.1.gz
-man/man8/bgpd.8.gz
-%%ISISD%%man/man8/isisd.8.gz
-man/man8/ospf6d.8.gz
-man/man8/ospfclient.8.gz
-man/man8/ospfd.8.gz
-%%PIMD%%man/man8/pimd.8.gz
-man/man8/ripd.8.gz
-man/man8/ripngd.8.gz
-man/man8/watchquagga.8.gz
-man/man8/zebra.8.gz
-sbin/bgpd
-%%ISISD%%sbin/isisd
-sbin/ospf6d
-sbin/ospfclient
-sbin/ospfd
-%%PIMD%%sbin/pimd
-sbin/ripd
-sbin/ripngd
-sbin/watchquagga
-sbin/zebra
+%%N%%lib/libfpm_pb.a
+%%N%%lib/libfpm_pb.so
+%%N%%lib/libfpm_pb.so.0
+%%N%%lib/libfpm_pb.so.0.0.0
+%%N%%lib/libospf.a
+%%N%%lib/libospf.so
+%%N%%lib/libospf.so.0
+%%N%%lib/libospf.so.0.0.0
+%%N%%lib/libospfapiclient.a
+%%N%%lib/libospfapiclient.so
+%%N%%lib/libospfapiclient.so.0
+%%N%%lib/libospfapiclient.so.0.0.0
+%%N%%lib/libquagga_pb.a
+%%N%%lib/libquagga_pb.so
+%%N%%lib/libquagga_pb.so.0
+%%N%%lib/libquagga_pb.so.0.0.0
+%%N%%lib/libzebra.a
+%%N%%lib/libzebra.so
+%%N%%lib/libzebra.so.1
+%%N%%lib/libzebra.so.1.0.0
+%%N%%man/man1/vtysh.1.gz
+%%N%%man/man8/bgpd.8.gz
+%%ISISD%%%%N%%man/man8/isisd.8.gz
+%%N%%man/man8/ospf6d.8.gz
+%%N%%man/man8/ospfclient.8.gz
+%%N%%man/man8/ospfd.8.gz
+%%PIMD%%%%N%%man/man8/pimd.8.gz
+%%N%%man/man8/ripd.8.gz
+%%N%%man/man8/ripngd.8.gz
+%%N%%man/man8/watchquagga.8.gz
+%%N%%man/man8/zebra.8.gz
+%%N%%sbin/bgpd
+%%ISISD%%%%N%%sbin/isisd
+%%N%%sbin/ospf6d
+%%N%%sbin/ospfclient
+%%N%%sbin/ospfd
+%%PIMD%%%%N%%sbin/pimd
+%%N%%sbin/ripd
+%%N%%sbin/ripngd
+%%N%%sbin/watchquagga
+%%N%%sbin/zebra
 %%EXAMPLES%%%%EXAMPLESDIR%%/bgpd.conf.sample
 %%EXAMPLES%%%%EXAMPLESDIR%%/bgpd.conf.sample2
 %%EXAMPLES%%%%ISISD%%%%EXAMPLESDIR%%/isisd.conf.sample