@@ -, +, @@ New port: devel/tlsh: Trend Micro Locality Sensitive Hash --- /dev/null +++ b/devel/tlsh/Makefile @@ -0,0 +1,63 @@ +# $FreeBSD$ + +PORTNAME= tlsh +DISTVERSION= 3.17.0 +CATEGORIES= devel +MASTER_SITES= GH + +MAINTAINER= cgull@glup.org +COMMENT= Trend Micro Locality Sensitive Hash library and utilities + +LICENSE= APACHE20 BSD3CLAUSE +LICENSE_COMB= dual +LICENSE_FILE= ${WRKSRC}/LICENSE + +USES= cmake +USE_LDCONFIG= yes +USE_GITHUB= yes +GH_ACCOUNT= trendmicro +GH_PROJECT= tlsh + +# XXX STATIC option not supported by tlsh CMakeFiles +# These options don't actually work as needed for FreeBSD; the +# tlsh build always builds static libraries, and shared libraries are +# optional. +# OPTIONS_DEFINE= STATIC +# OPTIONS_DEFAULT= +# STATIC_CMAKE_BOOL_OFF= TLSH_SHARED_LIBRARY + +OPTIONS_DEFINE= DOCS +OPTIONS_DEFAULT= DOCS + +CMAKE_ARGS= create_symlink tlsh_unittest tlsh +CMAKE_ON= TLSH_SHARED_LIBRARY + +TLSH_VERSION= ${PORTVERSION} +SHLIBVERMAJ= ${DISTVERSION:S/./ /g:[1]} +PLIST_SUB= TLSH_VERSION=${TLSH_VERSION} SHLIBVER=${DISTVERSION} SHLIBVERMAJ=${SHLIBVERMAJ} + +# XXX Testing/test.sh doesn't work with separated source and build directories +# TEST_TARGET= test + +post-build: + ${RLN} ${WRKSRC}/bin/tlsh_unittest ${WRKSRC}/bin/tlsh + +# XXX tlsh's install is incomplete, finish it ourselves +# Rely on cmake install for library itself, add docs and command +# after. tlsh's install only installs ${INCLUDEDIR}/tlsh.h, and skips +# version.h, so we must install both in ${INCLUDEDIR}/tlsh/ +post-install: + ${MKDIR} ${STAGEDIR}${PREFIX}/include/tlsh + ${RM} ${STAGEDIR}${PREFIX}/include/tlsh.h + ${INSTALL_PROGRAM} ${WRKSRC}/bin/tlsh ${STAGEDIR}${PREFIX}/bin + ${INSTALL_PROGRAM} ${WRKSRC}/bin/tlsh_unittest ${STAGEDIR}${PREFIX}/bin + ${INSTALL_DATA} ${WRKSRC}/include/tlsh.h ${STAGEDIR}${PREFIX}/include/tlsh/ + ${INSTALL_DATA} ${WRKSRC}/include/version.h ${STAGEDIR}${PREFIX}/include/tlsh/ + +post-install-DOCS-on: + ${MKDIR} ${STAGEDIR}${DOCSDIR} + ${INSTALL_MAN} ${WRKSRC}/README.md ${STAGEDIR}${DOCSDIR} + ${INSTALL_MAN} ${WRKSRC}/TLSH_Introduction.pdf ${STAGEDIR}${DOCSDIR} + ${INSTALL_MAN} ${WRKSRC}/TLSH_CTC_final.pdf ${STAGEDIR}${DOCSDIR} + +.include --- /dev/null +++ b/devel/tlsh/distinfo @@ -0,0 +1,3 @@ +TIMESTAMP = 1581709654 +SHA256 (trendmicro-tlsh-3.17.0_GH0.tar.gz) = 810cecdda1632ecb836278e5a58560d5b2b7911d02ed7419dc02b6a38e635985 +SIZE (trendmicro-tlsh-3.17.0_GH0.tar.gz) = 2829248 --- /dev/null +++ b/devel/tlsh/files/patch-Testing_test.sh @@ -0,0 +1,240 @@ +--- Testing/test.sh.orig 2020-02-16 01:55:44 UTC ++++ Testing/test.sh +@@ -1,4 +1,4 @@ +-#!/bin/bash ++#!/bin/sh + + ################################## + # set CREATE_EXP_FILE=1 if you want this script to create the Expected Results for the regression tests +@@ -10,26 +10,23 @@ echoerr() { echo "$@" 1>&2; } + ## Set LD_LIBRARY_PATH so that tlsh can pick up the tlsh shared library + export LD_LIBRARY_PATH=../lib:$LD_LIBRARY_PATH + BASEDIR=$(dirname $0) +-pushd $BASEDIR > /dev/null ++cd $BASEDIR + + if test ! -f ../bin/tlsh + then + echoerr "error: (127), you must compile tlsh" +- popd > /dev/null + exit 127 + fi + + if test ! -f ../bin/simple_unittest + then + echoerr "error: (127), you must compile ../bin/simple_unittest" +- popd > /dev/null + exit 127 + fi + + if test ! -f ../bin/tlsh_version + then + echoerr "error: (127), you must compile ../bin/tlsh_version" +- popd > /dev/null + exit 127 + fi + +@@ -91,7 +88,6 @@ runit() { + if test $CREATE_EXP_FILE = 0 + then + echoerr "error: (1), Expected Result file $EXPECTED_OUT does not exist" +- popd > /dev/null + exit 1 + else + echo "cp $TMP/example_data.out $EXPECTED_OUT" +@@ -103,7 +99,6 @@ runit() { + if test $CREATE_EXP_FILE = 0 + then + echoerr "error: (1), Expected Result file $EXPECTED_ERR does not exist" +- popd > /dev/null + exit 1 + else + echo "cp $TMP/example_data.err $EXPECTED_ERR" +@@ -115,7 +110,6 @@ runit() { + if test ! $diffc = 0 + then + echoerr "error: (1), diff $TMP/example_data.out $EXPECTED_OUT" +- popd > /dev/null + exit 1 + fi + +@@ -123,7 +117,6 @@ runit() { + if test ! $diffc = 0 + then + echoerr "error: (1), diff $TMP/example_data.err $EXPECTED_ERR" +- popd > /dev/null + exit 1 + fi + +@@ -154,7 +147,6 @@ runit() { + if test $CREATE_EXP_FILE = 0 + then + echoerr "error: (1), Expected Result file $EXPECTED_SCO does not exist" +- popd > /dev/null + exit 1 + else + echo "cp $TMP/example_data.scores $EXPECTED_SCO" +@@ -166,7 +158,6 @@ runit() { + if test $CREATE_EXP_FILE = 0 + then + echoerr "error: (1), Expected Result file $EXPECTED_ERR does not exist" +- popd > /dev/null + exit 1 + else + echo "cp $TMP/example_data.err2 $EXPECTED_ERR" +@@ -178,14 +169,12 @@ runit() { + if test ! $diffc = 0 + then + echoerr "error: (2), diff $TMP/example_data.scores $EXPECTED_SCO" +- popd > /dev/null + exit 2 + fi + diffc=`diff --ignore-all-space $TMP/example_data.err2 $EXPECTED_ERR | wc -l` + if test ! $diffc = 0 + then + echoerr "error: (2), diff $TMP/example_data.err2 $EXPECTED_ERR" +- popd > /dev/null + exit 2 + fi + +@@ -218,7 +207,6 @@ runit() { + if test $CREATE_EXP_FILE = 0 + then + echoerr "error: (3), Expected Result file $EXPECTED_SCO does not exist" +- popd > /dev/null + exit 1 + else + echo "cp $TMP/example_data.scores.2 $EXPECTED_SCO" +@@ -230,7 +218,6 @@ runit() { + if test ! $diffc = 0 + then + echoerr "error: (3) diff $TMP/example_data.scores.2 $EXPECTED_SCO" +- popd > /dev/null + exit 3 + fi + +@@ -259,7 +246,6 @@ runit() { + if test $CREATE_EXP_FILE = 0 + then + echoerr "error: ($testnum), Expected Result file $EXPECTED_SCO does not exist" +- popd > /dev/null + exit 1 + else + echo "cp $TMP/example_data.xref.scores $EXPECTED_SCO" +@@ -270,7 +256,6 @@ runit() { + diff --ignore-all-space $TMP/example_data.xref.scores $EXPECTED_SCO > /dev/null 2>/dev/null + if [ $? -ne 0 ]; then + echoerr "error: ($testnum), diff $TMP/example_data.xref.scores $EXPECTED_SCO" +- popd > /dev/null + exit $testnum + fi + +@@ -301,7 +286,6 @@ runit() { + if test $CREATE_EXP_FILE = 0 + then + echoerr "error: ($testnum), Expected Result file $EXPECTED_SCO does not exist" +- popd > /dev/null + exit 1 + else + echo "cp $TMP/example_data.scores.2.T-201 $EXPECTED_SCO" +@@ -312,7 +296,6 @@ runit() { + diff --ignore-all-space $TMP/example_data.scores.2.T-201 $EXPECTED_SCO > /dev/null 2>/dev/null + if [ $? -ne 0 ]; then + echoerr "error: ($testnum) diff $TMP/example_data.scores.2.T-201 $EXPECTED_SCO" +- popd > /dev/null + exit $testnum + fi + +@@ -351,7 +334,6 @@ then + if test $CREATE_EXP_FILE = 0 + then + echoerr "error: ($testnum), Expected Result file $EXPECTED_TESTLEN does not exist" +- popd > /dev/null + exit 1 + else + echo "cp $TMP/testlen.out $EXPECTED_TESTLEN" +@@ -362,7 +344,6 @@ fi + diff --ignore-all-space $TMP/testlen.out $EXPECTED_TESTLEN > /dev/null 2>/dev/null + if [ $? -ne 0 ]; then + echoerr "error: ($testnum) diff $TMP/testlen.out $EXPECTED_TESTLEN" +- popd > /dev/null + exit $testnum + fi + echo "passed" +@@ -390,7 +371,6 @@ for file in small small2 ; do + if test $CREATE_EXP_FILE = 0 + then + echoerr "error: ($testnum), Expected Result file $EXPECTED_TLSH does not exist" +- popd > /dev/null + exit 1 + else + echo "cp $TMP/$file.tlsh $EXPECTED_TLSH" +@@ -401,7 +381,6 @@ for file in small small2 ; do + diff --ignore-all-space $TMP/$file.tlsh $EXPECTED_TLSH + if [ $? -ne 0 ]; then + echoerr "error: ($testnum) $TMP/$file.tlsh $EXPECTED_TLSH" +- popd > /dev/null + exit $testnum + fi + done +@@ -432,14 +411,12 @@ EXPECTED_SCO=exp/example_data.$HASH.$CHKSUM.len.scores + if test ! -f $EXPECTED_SCO + then + echoerr "error: ($testnum), Expected Result file $EXPECTED_SCO does not exist" +- popd > /dev/null + exit 1 + fi + + diff --ignore-all-space $TMP/example_data.scores.l2.T-201 $EXPECTED_SCO > /dev/null 2>/dev/null + if [ $? -ne 0 ]; then + echoerr "error: ($testnum) diff $TMP/example_data.scores.l2.T-201 $EXPECTED_SCO" +- popd > /dev/null + exit $testnum + fi + +@@ -454,7 +431,6 @@ echo "../bin/${TLSH_PROG} -T 201 -l2 -lcsv -l example_ + diff --ignore-all-space $TMP/example_data.scores.l2csv.T-201 $EXPECTED_SCO > /dev/null 2>/dev/null + if [ $? -ne 0 ]; then + echoerr "error: ($testnum) diff $TMP/example_data.scores.l2csv.T-201 $EXPECTED_SCO" +- popd > /dev/null + exit $testnum + fi + +@@ -480,14 +456,12 @@ EXPECTED_RES=exp/example_data.Week3.split.tlsh + if test ! -f $EXPECTED_RES + then + echoerr "error: ($testnum), Expected Result file $EXPECTED_RES does not exist" +- popd > /dev/null + exit 1 + fi + + diff --ignore-all-space $TMP/example_data.Week3.split.tlsh $EXPECTED_RES > /dev/null 2>/dev/null + if [ $? -ne 0 ]; then + echoerr "error: ($testnum) diff $TMP/example_data.Week3.split.tlsh $EXPECTED_RES" +- popd > /dev/null + exit $testnum + fi + +@@ -512,7 +486,6 @@ then + if test $CREATE_EXP_FILE = 0 + then + echoerr "error: ($testnum), Expected Result file $EXPECTED_STEST does not exist" +- popd > /dev/null + exit 1 + else + echo "cp $TMP/simple_unittest.out $EXPECTED_STEST" +@@ -523,13 +496,10 @@ fi + diff --ignore-all-space $TMP/simple_unittest.out $EXPECTED_STEST > /dev/null 2>/dev/null + if [ $? -ne 0 ]; then + echoerr "error: ($testnum) diff $TMP/simple_unittest.out $EXPECTED_STEST" +- popd > /dev/null +- exit -1 ++ exit 255 + fi + + echo "passed all example data tests" +- +-popd > /dev/null + + echo + echo "If you have made changes to the Tlsh python module, build and install it, and run python_test.sh" --- /dev/null +++ b/devel/tlsh/files/patch-src_CMakeLists.txt @@ -0,0 +1,22 @@ +--- src/CMakeLists.txt.orig 2020-02-16 00:07:55 UTC ++++ src/CMakeLists.txt +@@ -65,16 +65,15 @@ set_target_properties(tlsh PROPERTIES OUTPUT_NAME tlsh + # it was causing problems when compiling / testing tools on Linux + ########################## + +-set(TLSH_SHARED_LIBRARY 0) +-if(TLSH_SHARED_LIBRARY EQUAL 1) ++if(TLSH_SHARED_LIBRARY) + add_library(tlsh_shared SHARED ${TLSH_SRCS}) + set_target_properties(tlsh_shared PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/lib) + set_target_properties(tlsh_shared PROPERTIES OUTPUT_NAME tlsh${BUILD_POSTFIX}) + set_target_properties(tlsh_shared PROPERTIES VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}" +- SOVERSION "0") ++ SOVERSION "${VERSION_MAJOR}") + endif() + +-if(TLSH_SHARED_LIBRARY EQUAL 1) ++if(TLSH_SHARED_LIBRARY) + install(TARGETS tlsh tlsh_shared DESTINATION lib) + else() + install(TARGETS tlsh DESTINATION lib) --- /dev/null +++ b/devel/tlsh/pkg-descr @@ -0,0 +1,6 @@ +TLSH is a library implementing the "Trend Micro Locality Sensitive +Hash" fuzzy matching hash algorithm. + +This port only installs the core C++ library. + +WWW: https://github.com/trendmicro/tlsh/ --- /dev/null +++ b/devel/tlsh/pkg-plist @@ -0,0 +1,11 @@ +bin/tlsh +bin/tlsh_unittest +include/tlsh/tlsh.h +include/tlsh/version.h +lib/libtlsh.a +lib/libtlsh.so +lib/libtlsh.so.%%SHLIBVERMAJ%% +lib/libtlsh.so.%%SHLIBVER%% +%%PORTDOCS%%%%DOCSDIR%%/README.md +%%PORTDOCS%%%%DOCSDIR%%/TLSH_Introduction.pdf +%%PORTDOCS%%%%DOCSDIR%%/TLSH_CTC_final.pdf