[arch-commits] Commit in tlsh/repos (6 files)

Levente Polyak anthraxx at archlinux.org
Tue Dec 15 00:28:59 UTC 2015


    Date: Tuesday, December 15, 2015 @ 01:28:59
  Author: anthraxx
Revision: 153333

archrelease: copy trunk to community-i686, community-x86_64

Added:
  tlsh/repos/community-i686/
  tlsh/repos/community-i686/PKGBUILD
    (from rev 153332, tlsh/trunk/PKGBUILD)
  tlsh/repos/community-i686/fix-python3.patch
    (from rev 153332, tlsh/trunk/fix-python3.patch)
  tlsh/repos/community-x86_64/
  tlsh/repos/community-x86_64/PKGBUILD
    (from rev 153332, tlsh/trunk/PKGBUILD)
  tlsh/repos/community-x86_64/fix-python3.patch
    (from rev 153332, tlsh/trunk/fix-python3.patch)

------------------------------------+
 community-i686/PKGBUILD            |   71 +++++++++++++++++++++++++++++++++++
 community-i686/fix-python3.patch   |   35 +++++++++++++++++
 community-x86_64/PKGBUILD          |   71 +++++++++++++++++++++++++++++++++++
 community-x86_64/fix-python3.patch |   35 +++++++++++++++++
 4 files changed, 212 insertions(+)

Copied: tlsh/repos/community-i686/PKGBUILD (from rev 153332, tlsh/trunk/PKGBUILD)
===================================================================
--- community-i686/PKGBUILD	                        (rev 0)
+++ community-i686/PKGBUILD	2015-12-15 00:28:59 UTC (rev 153333)
@@ -0,0 +1,71 @@
+# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
+
+pkgbase=tlsh
+pkgname=('tlsh' 'python-tlsh' 'python2-tlsh')
+pkgver=3.4.4
+pkgrel=1
+pkgdesc='Fuzzy matching library that generates a hash value which can be used for similarity comparisons'
+url='https://github.com/trendmicro/tlsh'
+arch=('i686' 'x86_64')
+license=('Apache')
+makedepends=('cmake' 'python' 'python2' 'gcc-libs')
+source=(${pkgname}-${pkgver}.tar.gz::https://github.com/trendmicro/${pkgname}/archive/v${pkgver}.tar.gz
+        fix-python3.patch)
+sha512sums=('c4897cf70cfef555638b14e2a77e550fd52dc3c23ca7dd98077d37478d944282b93c0019593c6e13a40df298a439fbdf20d0aa893aa1a78de0ea7b39ef76b572'
+            'aeafea636656fc974d0486acd37d210ffab14cd868c0e621170b5abc45ba68702826cea39cec41e2c8fe286b6ac0b85b3499c92e065abda21ce215a4c0a69bc4')
+
+prepare() {
+  cd ${pkgbase}-${pkgver}
+  patch -p1 < "${srcdir}/fix-python3.patch"
+  cp -ra py_ext{,-py2}
+  cp Testing/python_test.sh Testing/python2_test.sh
+  sed 's|py_ext|py_ext-py2|g' -i Testing/python2_test.sh
+}
+
+build() {
+  cd ${pkgbase}-${pkgver}
+  mkdir -p build
+  (cd build
+    cmake ..
+    make
+  )
+  (cd py_ext
+    python setup.py build
+  )
+  (cd py_ext-py2
+    python2 setup.py build
+  )
+}
+
+check() {
+  cd ${pkgbase}-${pkgver}
+  (cd build
+    make test
+  )
+  Testing/python_test.sh
+  Testing/python2_test.sh python2
+}
+
+package_tlsh() {
+  depends=('gcc-libs')
+
+  cd ${pkgbase}-${pkgver}
+  install -Dm 755 bin/tlsh_unittest "${pkgdir}/usr/bin/tlsh_unittest"
+  install -Dm 644 README.md "${pkgdir}/usr/share/doc/${pkgname}/README.md"
+}
+
+package_python-tlsh() {
+  depends=('python')
+
+  cd ${pkgbase}-${pkgver}/py_ext
+  python setup.py install -O1 --root="${pkgdir}" --skip-build
+}
+
+package_python2-tlsh() {
+  depends=('python2')
+
+  cd ${pkgbase}-${pkgver}/py_ext-py2
+  python2 setup.py install -O1 --root="${pkgdir}" --skip-build
+}
+
+# vim: ts=2 sw=2 et:

Copied: tlsh/repos/community-i686/fix-python3.patch (from rev 153332, tlsh/trunk/fix-python3.patch)
===================================================================
--- community-i686/fix-python3.patch	                        (rev 0)
+++ community-i686/fix-python3.patch	2015-12-15 00:28:59 UTC (rev 153333)
@@ -0,0 +1,35 @@
+From 243124159ad0fcbbb1329100c233bbfae40ca0de Mon Sep 17 00:00:00 2001
+From: anthraxx <levente at leventepolyak.net>
+Date: Sat, 5 Dec 2015 21:56:21 +0100
+Subject: [PATCH] convert arg to bytes object before passing to
+ PyBytes_AsStringAndSize
+
+this fixes python3 and ensures for both, python2 and python3 that
+the passed argument is a string.
+---
+ py_ext/tlshmodule.cpp | 12 ++++++++++++
+ 1 file changed, 12 insertions(+)
+
+diff --git a/py_ext/tlshmodule.cpp b/py_ext/tlshmodule.cpp
+index 409501b..8ed2335 100644
+--- a/py_ext/tlshmodule.cpp
++++ b/py_ext/tlshmodule.cpp
+@@ -178,6 +178,18 @@ Tlsh_fromTlshStr(tlsh_TlshObject *self, PyObject *args)
+         return PyErr_Format(PyExc_TypeError, "function takes exactly 1 argument (%lu given)", PyTuple_Size(args));
+ 
+     arg = PyTuple_GetItem(args, 0);
++#if PY_MAJOR_VERSION >= 3
++    if (!PyUnicode_Check(arg) || (arg = PyUnicode_AsASCIIString(arg)) == NULL) {
++      PyErr_SetString(PyExc_ValueError, "argument is not a TLSH hex string");
++      return NULL;
++    }
++#else
++    if (!PyString_Check(arg)) {
++      PyErr_SetString(PyExc_ValueError, "argument is not a TLSH hex string");
++      return NULL;
++    }
++#endif
++
+     if (PyBytes_AsStringAndSize(arg, &str, &len) == -1) {
+         PyErr_SetString(PyExc_ValueError, "argument is not a TLSH hex string");
+         return NULL;

Copied: tlsh/repos/community-x86_64/PKGBUILD (from rev 153332, tlsh/trunk/PKGBUILD)
===================================================================
--- community-x86_64/PKGBUILD	                        (rev 0)
+++ community-x86_64/PKGBUILD	2015-12-15 00:28:59 UTC (rev 153333)
@@ -0,0 +1,71 @@
+# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
+
+pkgbase=tlsh
+pkgname=('tlsh' 'python-tlsh' 'python2-tlsh')
+pkgver=3.4.4
+pkgrel=1
+pkgdesc='Fuzzy matching library that generates a hash value which can be used for similarity comparisons'
+url='https://github.com/trendmicro/tlsh'
+arch=('i686' 'x86_64')
+license=('Apache')
+makedepends=('cmake' 'python' 'python2' 'gcc-libs')
+source=(${pkgname}-${pkgver}.tar.gz::https://github.com/trendmicro/${pkgname}/archive/v${pkgver}.tar.gz
+        fix-python3.patch)
+sha512sums=('c4897cf70cfef555638b14e2a77e550fd52dc3c23ca7dd98077d37478d944282b93c0019593c6e13a40df298a439fbdf20d0aa893aa1a78de0ea7b39ef76b572'
+            'aeafea636656fc974d0486acd37d210ffab14cd868c0e621170b5abc45ba68702826cea39cec41e2c8fe286b6ac0b85b3499c92e065abda21ce215a4c0a69bc4')
+
+prepare() {
+  cd ${pkgbase}-${pkgver}
+  patch -p1 < "${srcdir}/fix-python3.patch"
+  cp -ra py_ext{,-py2}
+  cp Testing/python_test.sh Testing/python2_test.sh
+  sed 's|py_ext|py_ext-py2|g' -i Testing/python2_test.sh
+}
+
+build() {
+  cd ${pkgbase}-${pkgver}
+  mkdir -p build
+  (cd build
+    cmake ..
+    make
+  )
+  (cd py_ext
+    python setup.py build
+  )
+  (cd py_ext-py2
+    python2 setup.py build
+  )
+}
+
+check() {
+  cd ${pkgbase}-${pkgver}
+  (cd build
+    make test
+  )
+  Testing/python_test.sh
+  Testing/python2_test.sh python2
+}
+
+package_tlsh() {
+  depends=('gcc-libs')
+
+  cd ${pkgbase}-${pkgver}
+  install -Dm 755 bin/tlsh_unittest "${pkgdir}/usr/bin/tlsh_unittest"
+  install -Dm 644 README.md "${pkgdir}/usr/share/doc/${pkgname}/README.md"
+}
+
+package_python-tlsh() {
+  depends=('python')
+
+  cd ${pkgbase}-${pkgver}/py_ext
+  python setup.py install -O1 --root="${pkgdir}" --skip-build
+}
+
+package_python2-tlsh() {
+  depends=('python2')
+
+  cd ${pkgbase}-${pkgver}/py_ext-py2
+  python2 setup.py install -O1 --root="${pkgdir}" --skip-build
+}
+
+# vim: ts=2 sw=2 et:

Copied: tlsh/repos/community-x86_64/fix-python3.patch (from rev 153332, tlsh/trunk/fix-python3.patch)
===================================================================
--- community-x86_64/fix-python3.patch	                        (rev 0)
+++ community-x86_64/fix-python3.patch	2015-12-15 00:28:59 UTC (rev 153333)
@@ -0,0 +1,35 @@
+From 243124159ad0fcbbb1329100c233bbfae40ca0de Mon Sep 17 00:00:00 2001
+From: anthraxx <levente at leventepolyak.net>
+Date: Sat, 5 Dec 2015 21:56:21 +0100
+Subject: [PATCH] convert arg to bytes object before passing to
+ PyBytes_AsStringAndSize
+
+this fixes python3 and ensures for both, python2 and python3 that
+the passed argument is a string.
+---
+ py_ext/tlshmodule.cpp | 12 ++++++++++++
+ 1 file changed, 12 insertions(+)
+
+diff --git a/py_ext/tlshmodule.cpp b/py_ext/tlshmodule.cpp
+index 409501b..8ed2335 100644
+--- a/py_ext/tlshmodule.cpp
++++ b/py_ext/tlshmodule.cpp
+@@ -178,6 +178,18 @@ Tlsh_fromTlshStr(tlsh_TlshObject *self, PyObject *args)
+         return PyErr_Format(PyExc_TypeError, "function takes exactly 1 argument (%lu given)", PyTuple_Size(args));
+ 
+     arg = PyTuple_GetItem(args, 0);
++#if PY_MAJOR_VERSION >= 3
++    if (!PyUnicode_Check(arg) || (arg = PyUnicode_AsASCIIString(arg)) == NULL) {
++      PyErr_SetString(PyExc_ValueError, "argument is not a TLSH hex string");
++      return NULL;
++    }
++#else
++    if (!PyString_Check(arg)) {
++      PyErr_SetString(PyExc_ValueError, "argument is not a TLSH hex string");
++      return NULL;
++    }
++#endif
++
+     if (PyBytes_AsStringAndSize(arg, &str, &len) == -1) {
+         PyErr_SetString(PyExc_ValueError, "argument is not a TLSH hex string");
+         return NULL;



More information about the arch-commits mailing list