git: a6c9a9718c02 - main - devel/tlsh: New port: Trend Micro Locality Sensitive Hash
Jung-uk Kim
jkim at FreeBSD.org
Fri Sep 3 22:12:48 UTC 2021
The branch main has been updated by jkim:
URL: https://cgit.FreeBSD.org/ports/commit/?id=a6c9a9718c02555996e0a63aae981f356e09d067
commit a6c9a9718c02555996e0a63aae981f356e09d067
Author: Jung-uk Kim <jkim at FreeBSD.org>
AuthorDate: 2021-09-03 22:09:39 +0000
Commit: Jung-uk Kim <jkim at FreeBSD.org>
CommitDate: 2021-09-03 22:12:26 +0000
devel/tlsh: New port: Trend Micro Locality Sensitive Hash
TLSH is a fuzzy matching program and library. Given a file (min 50 bytes),
TLSH generates a hash value which can be used for similarity comparisons.
Similar files will have similar hash values which allows for the detection of
similar objects by comparing their hash values.
This port only includes the core C++ library.
WWW: https://tlsh.org
PR: 244381
---
devel/Makefile | 1 +
devel/tlsh/Makefile | 69 ++++++++
devel/tlsh/distinfo | 3 +
devel/tlsh/files/patch-Testing_test.sh | 268 ++++++++++++++++++++++++++++++
devel/tlsh/files/patch-src_CMakeLists.txt | 22 +++
devel/tlsh/pkg-descr | 8 +
devel/tlsh/pkg-plist | 8 +
7 files changed, 379 insertions(+)
diff --git a/devel/Makefile b/devel/Makefile
index a4f4cb3dc05e..dd4a073f2c39 100644
--- a/devel/Makefile
+++ b/devel/Makefile
@@ -7011,6 +7011,7 @@
SUBDIR += tl-expected
SUBDIR += tla
SUBDIR += tllist
+ SUBDIR += tlsh
SUBDIR += tlx
SUBDIR += tmake
SUBDIR += tnt
diff --git a/devel/tlsh/Makefile b/devel/tlsh/Makefile
new file mode 100644
index 000000000000..c13313da3a0b
--- /dev/null
+++ b/devel/tlsh/Makefile
@@ -0,0 +1,69 @@
+# Created by: John Hood <cgull at glup.org>
+
+PORTNAME= tlsh
+DISTVERSION= 4.7.2
+CATEGORIES= devel
+
+MAINTAINER= cgull at glup.org
+COMMENT= Trend Micro Locality Sensitive Hash library and utilities
+
+LICENSE= APACHE20 BSD3CLAUSE
+LICENSE_COMB= dual
+LICENSE_FILE= ${WRKSRC}/LICENSE
+
+USES= cmake cpe
+USE_GITHUB= yes
+GH_ACCOUNT= trendmicro
+GH_TAGNAME= d842e75
+CPE_VENDOR= ${GH_ACCOUNT}
+USE_LDCONFIG= yes
+
+CMAKE_ARGS= create_symlink \
+ tlsh \
+ tlsh_unittest
+CMAKE_ON= TLSH_SHARED_LIBRARY
+
+PORTDOCS= README.md TLSH_Introduction.pdf TLSH_CTC_final.pdf
+
+# XXX Testing/test.sh is too dumb to work with separated source and
+# build directories.
+TEST_TARGET= test
+
+_TLSH_VERSION= ${PORTVERSION}
+_SHLIBVERMAJ= ${DISTVERSION:S/./ /g:[1]}
+PLIST_SUB= SHLIBVER=${DISTVERSION} \
+ SHLIBVERMAJ=${_SHLIBVERMAJ} \
+ TLSH_VERSION=${_TLSH_VERSION}
+
+OPTIONS_DEFINE= DOCS
+# The tlsh build always builds static libraries, and shared libraries
+# are optional. The STATIC option is the reverse, and can't be used
+# with tlsh.
+# OPTIONS_DEFINE= STATIC
+# OPTIONS_DEFAULT=
+# STATIC_CMAKE_BOOL_OFF= TLSH_SHARED_LIBRARY
+
+post-build:
+ ${RLN} ${WRKSRC}/bin/tlsh_unittest ${WRKSRC}/bin/tlsh
+
+# rely on cmake install for library itself, add docs and command after.
+# XXX 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}
+.for i in ${PORTDOCS}
+ ${INSTALL_DATA} ${WRKSRC}/${i} ${STAGEDIR}${DOCSDIR}
+.endfor
+
+.include <bsd.port.mk>
diff --git a/devel/tlsh/distinfo b/devel/tlsh/distinfo
new file mode 100644
index 000000000000..af2a718ecaf4
--- /dev/null
+++ b/devel/tlsh/distinfo
@@ -0,0 +1,3 @@
+TIMESTAMP = 1630608937
+SHA256 (trendmicro-tlsh-4.7.2-d842e75_GH0.tar.gz) = 2cdcc05cd20026839f8b0d6b42a40b5c83d99b4620ff3c1770218167ebc4937d
+SIZE (trendmicro-tlsh-4.7.2-d842e75_GH0.tar.gz) = 3345166
diff --git a/devel/tlsh/files/patch-Testing_test.sh b/devel/tlsh/files/patch-Testing_test.sh
new file mode 100644
index 000000000000..28b9e776c59b
--- /dev/null
+++ b/devel/tlsh/files/patch-Testing_test.sh
@@ -0,0 +1,268 @@
+--- Testing/test.sh.orig 2020-12-10 01:30:11 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
+@@ -8,7 +8,7 @@ CREATE_EXP_FILE=0
+ echoerr() { echo "$@" 1>&2; }
+
+ BASEDIR=$(dirname $0)
+-pushd $BASEDIR > /dev/null
++cd $BASEDIR
+
+ LISTOPTION=1
+ JSONOPTION=1
+@@ -34,14 +34,12 @@ echo "TLSH_PROG=$TLSH_PROG"
+ if test ! -f $TLSH_PROG
+ then
+ echoerr "error: (127), you must compile $TLSH_PROG"
+- popd > /dev/null
+ exit 127
+ fi
+
+ if test ! -f $SIMP_PROG
+ then
+ echoerr "error: (127), you must compile $SIMP_PROG"
+- popd > /dev/null
+ exit 127
+ fi
+
+@@ -104,7 +102,6 @@ runit() {
+ if test ! -f $TMP/example_data.out
+ then
+ echoerr "error: (1), $TMP/example_data.out does not exist"
+- popd > /dev/null
+ exit 1
+ fi
+ EXPECTED_OUT=exp/example_data.$HASH.$CHKSUM.$XLEN.out_EXP
+@@ -114,7 +111,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"
+@@ -126,7 +122,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"
+@@ -137,7 +132,6 @@ runit() {
+ if test ! $diffc = 0
+ then
+ echoerr "error: (1), diff $TMP/example_data.out $EXPECTED_OUT"
+- popd > /dev/null
+ exit 1
+ fi
+
+@@ -145,7 +139,6 @@ runit() {
+ if test ! $diffc = 0
+ then
+ echoerr "error: (1), diff $TMP/example_data.err $EXPECTED_ERR"
+- popd > /dev/null
+ exit 1
+ fi
+
+@@ -160,7 +153,6 @@ runit() {
+ if test ! $diffc = 0
+ then
+ echoerr "error: (1), diff $TMP/example_data.json_out $EXPECTED_OUT"
+- popd > /dev/null
+ exit 1
+ fi
+ echo "passed"
+@@ -194,7 +186,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"
+@@ -206,7 +197,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"
+@@ -218,14 +208,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
+
+@@ -260,7 +248,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"
+@@ -272,7 +259,6 @@ runit() {
+ if test ! $diffc = 0
+ then
+ echoerr "error: (3) diff $TMP/example_data.scores.2 $EXPECTED_SCO"
+- popd > /dev/null
+ exit 3
+ fi
+
+@@ -304,7 +290,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"
+@@ -315,7 +300,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
+
+@@ -334,7 +318,6 @@ runit() {
+ diff --ignore-all-space $TMP/example_data.xref.json_scores $EXPECTED_SCO > /dev/null 2>/dev/null
+ if [ $? -ne 0 ]; then
+ echoerr "error: ($testnum), diff $TMP/example_data.xref.json_scores $EXPECTED_SCO"
+- popd > /dev/null
+ exit $testnum
+ fi
+ echo "passed"
+@@ -370,7 +353,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"
+@@ -381,7 +363,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
+ echo "passed"
+@@ -398,7 +379,6 @@ runit
+ if test "$1" = "_go"
+ then
+ echo "passed all example data tests (for go implementation)"
+- popd > /dev/null
+ exit 0
+ fi
+ runit "-xlen"
+@@ -428,7 +408,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"
+@@ -439,7 +418,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"
+@@ -467,7 +445,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"
+@@ -478,7 +455,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
+@@ -511,14 +487,12 @@ then
+ 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
+
+@@ -533,7 +507,6 @@ then
+ 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
+
+@@ -563,14 +536,12 @@ then
+ 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
+
+@@ -598,7 +569,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"
+@@ -609,13 +579,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"
diff --git a/devel/tlsh/files/patch-src_CMakeLists.txt b/devel/tlsh/files/patch-src_CMakeLists.txt
new file mode 100644
index 000000000000..34566853bf5c
--- /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)
diff --git a/devel/tlsh/pkg-descr b/devel/tlsh/pkg-descr
new file mode 100644
index 000000000000..11eb4782390c
--- /dev/null
+++ b/devel/tlsh/pkg-descr
@@ -0,0 +1,8 @@
+TLSH is a fuzzy matching program and library. Given a file (min 50 bytes),
+TLSH generates a hash value which can be used for similarity comparisons.
+Similar files will have similar hash values which allows for the detection of
+similar objects by comparing their hash values.
+
+This port only includes the core C++ library.
+
+WWW: https://tlsh.org
diff --git a/devel/tlsh/pkg-plist b/devel/tlsh/pkg-plist
new file mode 100644
index 000000000000..05584abc4624
--- /dev/null
+++ b/devel/tlsh/pkg-plist
@@ -0,0 +1,8 @@
+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%%
More information about the dev-commits-ports-all
mailing list