From 8aed006cda875d21eab1025d1c0783bccd5afc4f Mon Sep 17 00:00:00 2001 From: Dmitry Marakasov Date: Wed, 3 Jun 2015 00:23:35 +0300 Subject: [PATCH] Update FreeBSD port * Fix style * Fix github handling * Add LICENSE * Fix boost dependency * Add rc.d script * Install config file, handle with @sample * Install documentation * Fix hardcoded PREFIX/LOCALBASE references and other paths * Write files into /var/run/fastnetmon and /var/log/fastnetmon subdirectories, as /var/run and /var/log cannot be made writable by dedicated user This does not yet support dedicated user yet, as it would require modification of /usr/ports/{UIDs,GIDs}. This will be added when the port is committed to FreeBSD ports tree. --- src/FreeBSD_port/Makefile | 53 ++++++++++++------- src/FreeBSD_port/distinfo | 2 + src/FreeBSD_port/files/fastnetmon.in | 28 ++++++++++ .../files/patch-src_CMakeLists.txt | 46 ++++++++++++++++ src/FreeBSD_port/pkg-descr | 8 +-- src/FreeBSD_port/pkg-plist | 3 ++ 6 files changed, 116 insertions(+), 24 deletions(-) create mode 100644 src/FreeBSD_port/distinfo create mode 100644 src/FreeBSD_port/files/fastnetmon.in create mode 100644 src/FreeBSD_port/files/patch-src_CMakeLists.txt diff --git a/src/FreeBSD_port/Makefile b/src/FreeBSD_port/Makefile index 6e9fb68..7222795 100644 --- a/src/FreeBSD_port/Makefile +++ b/src/FreeBSD_port/Makefile @@ -1,33 +1,46 @@ # $FreeBSD$ -# Created by: Pavel Odintsov pavel.odintsov@gmail.com -# For fast install use pkg for boost: pkg install -y boost-all +PORTNAME= fastnetmon +PORTVERSION= 1.1.2 +DISTVERSIONPREFIX= v +CATEGORIES= net-mgmt -PORTNAME= fastnetmon +MAINTAINER= pavel.odintsov@gmail.com +COMMENT= Very fast DDoS analyzer with sFlow/NetFLow/IPFIX/SPAN/mirror support -# production -#PORTVERSION= 1.1.1 +LICENSE= GPLv2 +LICENSE_FILE= ${WRKSRC}/LICENSE -# Testing -PORTVERSION= master -CATEGORIES= net-mgmt +LIB_DEPENDS= liblog4cpp.so:${PORTSDIR}/devel/log4cpp \ + libboost_regex.so:${PORTSDIR}/devel/boost-libs -# Testing -MASTER_SITES= https://github.com/FastVPSEestiOu/fastnetmon/archive/ -DISTFILES= master.zip +USE_GITHUB= yes +GH_ACCOUNT= FastVPSEestiOu -# Production -#MASTER_SITES= https://github.com/FastVPSEestiOu/fastnetmon/archive/ -#DISTFILES= v1.1.1.tar.gz +# TODO: enable this after updating /usr/ports/{UIDs,GIDs} +#USERS= fastnetmon +#GROUPS= fastnetmon -MAINTAINER= Pavel Odintsov pavel.odintsov@gmail.com -COMMENT= Very fast DDoS analyzer with sFlow/NetFLow/IPFIX/SPAN/mirror support +USES= cmake +CMAKE_SOURCE_PATH=${WRKSRC}/src -USES= cmake -CMAKE_SOURCE_PATH= ${WRKSRC}/src +USE_RC_SUBR= fastnetmon -LIB_DEPENDS= liblog4cpp.so:${PORTSDIR}/devel/log4cpp libboost_regex.so:${PORTSDIR}/devel/boost-all +PORTDOCS= * -# distsum generated by call: make makesum +OPTIONS_DEFINE= DOCS + +post-patch: + @${REINPLACE_CMD} -e 's|/usr/local|${LOCALBASE}|' ${WRKSRC}/src/CMakeLists.txt + @${REINPLACE_CMD} -e 's|/usr/local|${PREFIX}|; \ + s|/var/run|&/fastnetmon|g; s|/var/log|&/fastnetmon|g; \ + s|"/etc/|"${PREFIX}/etc/|g; s|/root/fastnetmon|${DATADIR}|g' \ + ${WRKSRC}/src/fastnetmon.conf ${WRKSRC}/src/fastnetmon.cpp + +post-install: + ${MV} ${STAGEDIR}${PREFIX}/etc/${PORTNAME}.conf \ + ${STAGEDIR}${PREFIX}/etc/${PORTNAME}.conf.sample + cd ${WRKSRC} && ${COPYTREE_SHARE} "README.md docs" ${STAGEDIR}${DOCSDIR} + ${MKDIR} ${STAGEDIR}/var/run/fastnetmon ${STAGEDIR}/var/log/fastnetmon .include diff --git a/src/FreeBSD_port/distinfo b/src/FreeBSD_port/distinfo new file mode 100644 index 0000000..55eea1b --- /dev/null +++ b/src/FreeBSD_port/distinfo @@ -0,0 +1,2 @@ +SHA256 (FastVPSEestiOu-fastnetmon-v1.1.2_GH0.tar.gz) = f2c554aa402e608b9837132b17da79b49f1b998c17934344779ddc9a397261b4 +SIZE (FastVPSEestiOu-fastnetmon-v1.1.2_GH0.tar.gz) = 6072730 diff --git a/src/FreeBSD_port/files/fastnetmon.in b/src/FreeBSD_port/files/fastnetmon.in new file mode 100644 index 0000000..07dd7e4 --- /dev/null +++ b/src/FreeBSD_port/files/fastnetmon.in @@ -0,0 +1,28 @@ +#!/bin/sh + +# PROVIDE: fastnetmon +# REQUIRE: NETWORKING SERVERS LOGIN +# BEFORE: securelevel +# KEYWORD: shutdown + +# Add the following line to /etc/rc.conf to enable `fastnetmon': +# +# fastnetmon_enable="YES" +# + +. /etc/rc.subr + +name="fastnetmon" +rcvar="${name}_enable" + +command="%%PREFIX%%/bin/fastnetmon" +pidfile="/var/run/fastnetmon/$name.pid" + +load_rc_config "$name" + +: ${fastnetmon_enable:="NO"} +# TODO: enable this after updating /usr/ports/{UIDs,GIDs} +#: ${fastnetmon_user:="fastnetmon"} +: ${fastnetmon_flags:="--daemonize"} + +run_rc_command "$1" diff --git a/src/FreeBSD_port/files/patch-src_CMakeLists.txt b/src/FreeBSD_port/files/patch-src_CMakeLists.txt new file mode 100644 index 0000000..b7d8940 --- /dev/null +++ b/src/FreeBSD_port/files/patch-src_CMakeLists.txt @@ -0,0 +1,46 @@ +--- src/CMakeLists.txt.orig 2015-06-02 16:43:16 UTC ++++ src/CMakeLists.txt +@@ -14,8 +14,8 @@ set (Tutorial_VERSION_MAJOR 1) + set (Tutorial_VERSION_MINOR 1) + + # It's pretty safe and provide big speedup for our packet processor and patricia code +-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2 ") +-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2") ++set(CMAKE_C_FLAGS_RELEASE "-O2") ++set(CMAKE_CXX_FLAGS_RELEASE "-O2") + + set(FASTNETMON_PROFILER OFF) + +@@ -91,11 +91,13 @@ target_link_libraries(netflow_plugin ipf + add_library(pcap_plugin STATIC pcap_plugin/pcap_collector.cpp) + target_link_libraries(pcap_plugin pcap) + ++find_package(Threads) ++ + if (ENABLE_PFRING_SUPPORT) + add_library(pfring_plugin STATIC pfring_plugin/pfring_collector.cpp) + target_link_libraries(pfring_plugin ${PFRING_LIBRARIES}) + target_link_libraries(pfring_plugin numa) +- target_link_libraries(pfring_plugin pthread) ++ target_link_libraries(pfring_plugin ${CMAKE_THREAD_LIBS_INIT}) + endif() + + # example plugin +@@ -169,7 +171,7 @@ endif() + + target_link_libraries(fastnetmon ${LOG4CPP_LIBRARY_PATH}) + +-target_link_libraries(fastnetmon pthread) ++target_link_libraries(fastnetmon ${CMAKE_THREAD_LIBS_INIT}) + + # Our libs + target_link_libraries(fastnetmon patricia) +@@ -217,6 +219,8 @@ endif() + install(TARGETS fastnetmon DESTINATION bin) + install(TARGETS fastnetmon_client DESTINATION bin) + ++install(FILES fastnetmon.conf DESTINATION etc) ++ + # Configure cpack package builder + # Run it with: cd build; cpack -G DEB .. + set(CPACK_PACKAGE_NAME "fastnetmon") diff --git a/src/FreeBSD_port/pkg-descr b/src/FreeBSD_port/pkg-descr index 3eb3810..6ea81df 100644 --- a/src/FreeBSD_port/pkg-descr +++ b/src/FreeBSD_port/pkg-descr @@ -1,5 +1,5 @@ -FastNetMon - A high performance DoS/DDoS load analyzer built on top of multiple packet capture engines (NetFlow, IPFIX, sFLOW, netmap, PF_RING, PCAP). +FastNetMon - A high performance DoS/DDoS load analyzer built on top +of multiple packet capture engines (NetFlow, IPFIX, sFLOW, netmap, +PF_RING, PCAP). -Author: Pavel Odintsov pavel.odintsov@gmail.com -Company: FastVPS Eesti OU http://fastvps.host -Site: https://github.com/FastVPSEestiOu/fastnetmon +WWW: https://github.com/FastVPSEestiOu/fastnetmon diff --git a/src/FreeBSD_port/pkg-plist b/src/FreeBSD_port/pkg-plist index c0b2c27..5b3cce4 100644 --- a/src/FreeBSD_port/pkg-plist +++ b/src/FreeBSD_port/pkg-plist @@ -1,2 +1,5 @@ bin/fastnetmon bin/fastnetmon_client +@sample etc/fastnetmon.conf.sample +@dir /var/run/fastnetmon +@dir /var/log/fastnetmon