[arch-commits] Commit in distorm/trunk (PKGBUILD build.patch python3.patch)

Levente Polyak anthraxx at archlinux.org
Sun Jun 12 18:46:08 UTC 2016


    Date: Sunday, June 12, 2016 @ 20:46:08
  Author: anthraxx
Revision: 179724

upgpkg: distorm 3.3.4-1

Added:
  distorm/trunk/build.patch
  distorm/trunk/python3.patch
Modified:
  distorm/trunk/PKGBUILD

---------------+
 PKGBUILD      |   63 ++++++++++++++++++++++++++++++++++++++++----------------
 build.patch   |   61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 python3.patch |   40 +++++++++++++++++++++++++++++++++++
 3 files changed, 146 insertions(+), 18 deletions(-)

Modified: PKGBUILD
===================================================================
--- PKGBUILD	2016-06-12 15:47:48 UTC (rev 179723)
+++ PKGBUILD	2016-06-12 18:46:08 UTC (rev 179724)
@@ -2,39 +2,66 @@
 # Contributor: Mike Sampson <mike at sambodata dot com>
 # Contributor: Dmitry A. Ilyashevich <dmitry.ilyashevich at gmail.com>
 
-pkgname=distorm
-pkgver=3.3.3
+pkgbase=distorm
+pkgname=('distorm' 'python-distorm' 'python2-distorm')
+pkgver=3.3.4
 pkgrel=1
-pkgdesc="Powerful disassembler library for x86/AMD64"
+pkgdesc='Powerful disassembler library for x86/AMD64'
 url='https://github.com/gdabah/distorm'
 arch=('i686' 'x86_64')
 license=('BSD')
-depends=('python2')
-source=(${pkgname}-${pkgver}.tar.gz::https://github.com/gdabah/distorm/archive/v${pkgver}.tar.gz)
-sha512sums=('abc37d050efcb7fd7c6e0f1ef055537f06059528fb48a07d159621adca8d905ee3a44b394d75e10aa69f2429fb1023e9282b349281acb3a9474148f195306fbf')
+makedepends=('python' 'python2' 'glibc')
+options=('staticlibs')
+source=(${pkgname}-${pkgver}.tar.gz::https://github.com/gdabah/distorm/archive/v${pkgver}.tar.gz
+        python3.patch
+        build.patch)
+sha512sums=('172bb1a9a3f92089daf140fd019c94cf3b63f646b78e7aa527640819f418b1e3df2e2d727a76863a7800e6e3735c404054aeb48fceeec7a94f95480b89883b90'
+            '91bfa096e8de1c494a84e781aa27c48a1063239c4d1e1c746d32fde9273e79769af37240559341edf6547055fbf80698339474ad77c3581c01d4057ba5cef0ea'
+            'f7ec10c577715b3c8907dc999652de377f21b33acb78954544f920bc65be7e19d13368cf9915be10a5162c149cb9b48816f52f0258d219a3ea1cf26bb63ed8c2')
 
 prepare() {
-  cd ${pkgname}-${pkgver}
-  sed -r 's|(install)|\1 -D|g' -i make/linux/Makefile
-  sed -r 's|/usr/local/lib|${DESTDIR}/usr/lib/${TARGET}|g' -i make/linux/Makefile
-  sed -r 's|(CFLAGS	)=|\1+=|g' -i make/linux/Makefile
-  sed -e '1i#!/usr/bin/env python2' -i python/distorm3/sample.py
+  (cd ${pkgbase}-${pkgver}
+    patch -p1 < "${srcdir}/build.patch"
+    patch -p1 < "${srcdir}/python3.patch"
+  )
+  cp -ra ${pkgbase}-${pkgver}{,-py2}
+  sed -e '1i#!/usr/bin/env python' -i ${pkgbase}-${pkgver}/python/distorm3/sample.py
+  sed -e '1i#!/usr/bin/env python2' -i ${pkgbase}-${pkgver}-py2/python/distorm3/sample.py
 }
 
 build() {
-  cd ${pkgname}-${pkgver}
-  make -C make/linux
+  (cd ${pkgbase}-${pkgver}
+    make -C make/linux
+    python setup.py build
+  )
+  (cd ${pkgbase}-${pkgver}-py2
+    python2 setup.py build
+  )
 }
 
-package() {
-  cd ${pkgname}-${pkgver}
+package_distorm() {
+  depends=('glibc')
+  cd ${pkgbase}-${pkgver}
+  make -C make/linux PREFIX=/usr DESTDIR="${pkgdir}" install
+  install -Dm 644 include/*.h -t "${pkgdir}/usr/include"
+  install -Dm 644 COPYING "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
+}
 
-  make -C make/linux DESTDIR="${pkgdir}" install
-  python2 setup.py install --root="${pkgdir}" -O1
+package_python-distorm() {
+  depends=('python')
+  cd ${pkgbase}-${pkgver}
+  python setup.py install --root="${pkgdir}" -O1 --skip-build
+  install -Dm 755 python/distorm3/sample.py "${pkgdir}/usr/bin/disasm"
+  install -Dm 644 COPYING "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
+}
 
+package_python2-distorm() {
+  depends=('python2')
+  cd ${pkgbase}-${pkgver}-py2
+  python2 setup.py install --root="${pkgdir}" -O1 --skip-build
   install -Dm 755 python/distorm3/sample.py "${pkgdir}/usr/bin/disasm"
-  install -Dm 644 include/*.h -t "${pkgdir}/usr/include"
   install -Dm 644 COPYING "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
+  mv "${pkgdir}/usr/bin/disasm"{,-py2}
 }
 
 # vim: ts=2 sw=2 et:

Added: build.patch
===================================================================
--- build.patch	                        (rev 0)
+++ build.patch	2016-06-12 18:46:08 UTC (rev 179724)
@@ -0,0 +1,61 @@
+From 26d3959ac90cfbecd36458fee2fbb67807457d54 Mon Sep 17 00:00:00 2001
+From: anthraxx <levente at leventepolyak.net>
+Date: Mon, 6 Jun 2016 00:03:20 +0200
+Subject: [PATCH] more distribution friendly Makefile improvements
+
+- append CFLAGS instead of force-set it, this was distributions
+  can also add their own CFLAGS in addition (this is very common).
+- introduce LDFLAGS so distributions can set their own additional
+  flags for the linker and append instead of set (this is very common)
+- replace static /usr/local/lib with a PREFIX variable with default
+  value of /usr/local so a distribution can easily use PREFIX=/usr
+  (this is also common)
+- introduce DESTDIR for distribution wide packaging as they build in
+  chroots and deploy into a special directory structure that will later
+  put into a tarball and lands in a distribution package.
+  f.e. DESTDIR="/build/package" (this is also common for packaging)
+- adding -D to install call to create all leading components of the
+  destination. This is very important if the DESTDIR is set for
+  packaging the therefor the structure does not yet exists. This will
+  then basically freate the directory structure. in case DESTDIR is not
+  used and /usr/local/lib f.e. already exists this will do nothing
+  this is highly common to do it this way.
+  We add the ${TARGET} to the end because we use the -D parameter and
+  therefor we need to also pass the resulting filename
+---
+ make/linux/Makefile | 9 ++++++---
+ 1 file changed, 6 insertions(+), 3 deletions(-)
+
+diff --git a/make/linux/Makefile b/make/linux/Makefile
+index c2ad39e..d142bb4 100644
+--- a/make/linux/Makefile
++++ b/make/linux/Makefile
+@@ -5,7 +5,10 @@
+ TARGET	= libdistorm3.so
+ COBJS	= ../../src/mnemonics.o ../../src/wstring.o ../../src/textdefs.o ../../src/prefix.o ../../src/operands.o ../../src/insts.o ../../src/instructions.o ../../src/distorm.o ../../src/decoder.o
+ CC	= gcc
+-CFLAGS	= -fPIC -O2 -Wall -DSUPPORT_64BIT_OFFSET -DDISTORM_STATIC
++CFLAGS	+= -fPIC -O2 -Wall -DSUPPORT_64BIT_OFFSET -DDISTORM_STATIC
++LDFLAGS	+= -shared
++PREFIX	= /usr/local
++DESTDIR	=
+ 
+ all: clib
+ 
+@@ -13,11 +16,11 @@ clean:
+ 	/bin/rm -rf ../../src/*.o ${TARGET} ../../distorm3.a ./../*.o
+ 
+ clib: ${COBJS}
+-	${CC} ${CFLAGS} ${VERSION} ${COBJS} -shared -o ${TARGET}
++	${CC} ${CFLAGS} ${VERSION} ${COBJS} ${LDFLAGS} -o ${TARGET}
+ 	ar rs ../../distorm3.a ${COBJS}
+ 
+ install: libdistorm3.so
+-	install -s ${TARGET} /usr/local/lib
++	install -D -s ${TARGET} ${DESTDIR}/${PREFIX}/lib/${TARGET}
+ 	@echo "... running ldconfig might be smart ..."
+ 
+ .c.o:
+-- 
+2.8.3
+

Added: python3.patch
===================================================================
--- python3.patch	                        (rev 0)
+++ python3.patch	2016-06-12 18:46:08 UTC (rev 179724)
@@ -0,0 +1,40 @@
+From 28b3af2136bcc465830631afa9357fbf73048e52 Mon Sep 17 00:00:00 2001
+From: gil_dabah <dabah at north-bit.com>
+Date: Sat, 4 Jun 2016 17:37:40 +0300
+Subject: [PATCH] Fix for cross Python support.
+
+---
+ python/distorm3/__init__.py | 13 +++++++++++--
+ 1 file changed, 11 insertions(+), 2 deletions(-)
+
+diff --git a/python/distorm3/__init__.py b/python/distorm3/__init__.py
+index c8f881c..176677b 100644
+--- a/python/distorm3/__init__.py
++++ b/python/distorm3/__init__.py
+@@ -537,6 +537,15 @@ def DecodeGenerator(codeOffset, code, dt):
+     p_result        = byref(result)
+     instruction_off = 0
+ 
++    # Support cross Python compatibility
++    toUnicode = lambda s: s
++    spaceCh = b" "
++    if sys.version_info[0] >= 3:
++        if sys.version_info[1] > 0:
++            toUnicode = lambda s: s.decode()
++        else:
++            spaceCh = " "
++
+     while codeLen > 0:
+ 
+         usedInstructionsCount = c_uint(0)
+@@ -553,8 +562,8 @@ def DecodeGenerator(codeOffset, code, dt):
+             di   = result[index]
+             asm  = di.mnemonic.p
+             if len(di.operands.p):
+-                asm += b" " + di.operands.p
+-            pydi = (di.offset, di.size, asm, di.instructionHex.p)
++                asm += spaceCh + di.operands.p
++            pydi = (di.offset, di.size, toUnicode(asm), toUnicode(di.instructionHex.p))
+             instruction_off += di.size
+             yield pydi
+ 



More information about the arch-commits mailing list