Bug 186102 - [new port] add devel/capstone port
Summary: [new port] add devel/capstone port
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: Kubilay Kocak
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-01-25 18:40 UTC by Oliver Pinter
Modified: 2014-01-29 02:40 UTC (History)
0 users

See Also:


Attachments
file.shar (5.14 KB, text/plain)
2014-01-25 18:40 UTC, Oliver Pinter
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Oliver Pinter 2014-01-25 18:40:01 UTC
Capstone is a lightweight multi-platform, multi-architecture disassembly framework.

Our target is to make Capstone the ultimate disassembly engine for binary analysis and reversing in the security community.

Fix: Patch attached with submission follows:
Comment 1 Kubilay Kocak freebsd_committer freebsd_triage 2014-01-27 06:25:07 UTC
Responsible Changed
From-To: freebsd-ports-bugs->koobs

I'll take it.
Comment 2 koobs 2014-01-27 06:53:40 UTC
Oliver,

First, thanks for your submission. I am about to commit it to the tree,
and wanted to follow-up with a review for your reference:

Portlint warnings:

WARN: capstone/pkg-plist: [8]: installing shared libraries, please
      define USE_LDCONFIG as appropriate
WARN: capstone/pkg-descr: includes lines that exceed 80 characters.
WARN: capstone/pkg-descr: contains a URL but no "WWW:"
WARN: Makefile: COMMENT should begin with a capital, and end without
      a period
WARN: Makefile: seems to have unnecessary blank lines at the last part.

- Dont override MAKE_ENV (unless theres a good reason to), use +=

MAKE_ENV+=       INSTALL_DATA="${INSTALL_DATA}"

- Use \ to break up an assignment into multiple lines:

MAKE_ENV+=       INSTALL_DATA="${INSTALL_DATA}" \
                INSTALL_LIBRARY="${INSTALL_DATA}"

- INSTALL_DATA is already passed to MAKE_ENV
- INSTALL_LIB is the correct variable for INSTALL_LIBRARY to install
  a stripped library

/!\ capstone-2.0: Makefile warnings, please consider fixing /!\

LICENSE must not contain BSD, instead use BSD[234]CLAUSE

For the above and other QA/Sanity checking, enable port developer
warnings in /etc/make.conf:

#
http://lists.freebsd.org/pipermail/freebsd-ports/2013-September/086022.html
DEVELOPER=yes
DEV_WARNING_WAIT=1

For the pre-install REINPLACE_CMD, the PORTSDIR may not be /usr/ports.
Update post-build: regular expression to suite (Thanks xmj via IRC)

${REINPLACE_CMD} -e
'/libdir/s|\(libdir=\)\(.*\)\(devel/capstone/work/stage\)|\1|g'
${WRKSRC}/capstone.pc

A few tips below to ensure your submissions are addressed as quickly as
possible in future:

- Enable ports developer warnings in /etc/make.conf
- Use portlint to check your port before submission
- Use redports poudriere to test your portbuilds on all versions/archs
- Include portlint output and redports/poudriere build logs in your PR

Eg:

portlint: OK
redports: OK (url)

If you'd like more info, detail or help, jump on IRC, #bsdports efnet or
#freebsd-ports freenode and say hi
Comment 3 dfilter service freebsd_committer freebsd_triage 2014-01-27 07:00:33 UTC
Author: koobs
Date: Mon Jan 27 07:00:24 2014
New Revision: 341330
URL: http://svnweb.freebsd.org/changeset/ports/341330
QAT: https://qat.redports.org/buildarchive/r341330/

Log:
  devel/capstone: Multi-platform, multi-architecture disassembly framework [NEW PORT]
  
  Capstone is a lightweight multi-platform, multi-architecture disassembly
  framework.
  
  Features:
   * Supported architectures: ARM, ARM64 (aka ARMv8), Mips, PowerPC & X86
   * Clean/simple/lightweight/intuitive architecture-neutral API
   * Provide details on disassembled instruction (called "decomposer")
   * Provide some semantics of the disassembled instruction, such as list of
     implicit registers read & written.
   * Implemented in pure C language, with bindings for Python, Ruby, C#, Java,
     GO, OCaml & Vala available.
   * Native support for Windows & *nix (including MacOSX, Linux, *BSD & Solaris)
   * Thread-safe by design
   * Distributed under the open source BSD license
  
  WWW: http://capstone-engine.org/
  
  PR:		ports/186102
  Submitted by:	Oliver Pinter <oliver.pntr@gmail.com>

Added:
  head/devel/capstone/
  head/devel/capstone/Makefile   (contents, props changed)
  head/devel/capstone/distinfo   (contents, props changed)
  head/devel/capstone/files/
  head/devel/capstone/files/patch-Makefile   (contents, props changed)
  head/devel/capstone/files/patch-tests_Makefile   (contents, props changed)
  head/devel/capstone/pkg-descr   (contents, props changed)
  head/devel/capstone/pkg-plist   (contents, props changed)
Modified:
  head/devel/Makefile

Modified: head/devel/Makefile
==============================================================================
--- head/devel/Makefile	Mon Jan 27 06:21:51 2014	(r341329)
+++ head/devel/Makefile	Mon Jan 27 07:00:24 2014	(r341330)
@@ -182,6 +182,7 @@
     SUBDIR += c-unit
     SUBDIR += c4
     SUBDIR += calibrator
+    SUBDIR += capstone
     SUBDIR += cbind
     SUBDIR += cbrowser
     SUBDIR += cc65

Added: head/devel/capstone/Makefile
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/devel/capstone/Makefile	Mon Jan 27 07:00:24 2014	(r341330)
@@ -0,0 +1,22 @@
+# $FreeBSD$
+
+PORTNAME=	capstone
+PORTVERSION=	2.0
+CATEGORIES=	devel
+MASTER_SITES=	http://capstone-engine.org/download/2.0/
+
+MAINTAINER=	oliver.pntr@gmail.com
+COMMENT=	Multi-platform, multi-architecture disassembly framework
+
+LICENSE=	BSD3CLAUSE
+
+USES=		gmake
+USE_LDCONFIG=	yes
+
+MAKE_ENV=	INSTALL_LIBRARY="${INSTALL_LIB}"
+
+post-build:
+	# The pkgconfig file is generated and points to stagedir
+	${REINPLACE_CMD} -e '/libdir/s|\(libdir=\)\(.*\)\(devel/capstone/work/stage\)|\1|g' ${WRKSRC}/capstone.pc
+
+.include <bsd.port.mk>

Added: head/devel/capstone/distinfo
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/devel/capstone/distinfo	Mon Jan 27 07:00:24 2014	(r341330)
@@ -0,0 +1,2 @@
+SHA256 (capstone-2.0.tar.gz) = 5d871b1e52047d1b2882bbcc6f049205ba6acc8d55d746937d22af5d0b33fa9e
+SIZE (capstone-2.0.tar.gz) = 1731759

Added: head/devel/capstone/files/patch-Makefile
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/devel/capstone/files/patch-Makefile	Mon Jan 27 07:00:24 2014	(r341330)
@@ -0,0 +1,52 @@
+--- Makefile.orig	2014-01-22 11:33:35.000000000 +0100
++++ Makefile	2014-01-25 19:13:32.000000000 +0100
+@@ -15,7 +15,7 @@
+ STRIP = $(CROSS)strip
+ endif
+ 
+-CFLAGS += -fPIC -O3 -Wall -Iinclude
++CFLAGS += -fPIC -Wall -Iinclude
+ 
+ ifeq ($(USE_SYS_DYN_MEM),yes)
+ CFLAGS += -DUSE_SYS_DYN_MEM
+@@ -38,6 +38,14 @@
+ endif
+ endif
+ 
++LIBDATADIR = $(LIBDIR)
++UNAME_S := $(shell uname -s)
++ifeq ($(UNAME_S), FreeBSD)
++LIBDATADIR = $(DESTDIR)$(PREFIX)/libdata
++else
++LIBDATADIR = $(LIBDIR)
++endif
++
+ INSTALL_BIN ?= install
+ INSTALL_DATA ?= $(INSTALL_BIN) -m0644
+ INSTALL_LIBRARY ?= $(INSTALL_BIN) -m0755
+@@ -88,7 +96,6 @@
+ 
+ LIBOBJ += MCInst.o
+ 
+-UNAME_S := $(shell uname -s)
+ # OSX?
+ ifeq ($(UNAME_S),Darwin)
+ EXT = dylib
+@@ -156,14 +163,14 @@
+ 	$(INSTALL_DATA) lib$(LIBNAME).$(AR_EXT) $(LIBDIR)
+ 	mkdir -p $(INCDIR)/$(LIBNAME)
+ 	$(INSTALL_DATA) include/*.h $(INCDIR)/$(LIBNAME)
+-	mkdir -p $(LIBDIR)/pkgconfig
+-	$(INSTALL_DATA) $(PKGCFGF) $(LIBDIR)/pkgconfig/
++	mkdir -p $(LIBDATADIR)/pkgconfig
++	$(INSTALL_DATA) $(PKGCFGF) $(LIBDATADIR)/pkgconfig/
+ 
+ uninstall:
+ 	rm -rf $(INCDIR)/$(LIBNAME)
+ 	rm -f $(LIBDIR)/lib$(LIBNAME).$(EXT)
+ 	rm -f $(LIBDIR)/lib$(LIBNAME).$(AR_EXT)
+-	rm -f $(LIBDIR)/pkgconfig/$(LIBNAME).pc
++	rm -f $(LIBDATADIR)/pkgconfig/$(LIBNAME).pc
+ 
+ clean:
+ 	rm -f $(LIBOBJ) lib$(LIBNAME).*

Added: head/devel/capstone/files/patch-tests_Makefile
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/devel/capstone/files/patch-tests_Makefile	Mon Jan 27 07:00:24 2014	(r341330)
@@ -0,0 +1,22 @@
+--- tests/Makefile.orig	2014-01-25 19:14:03.000000000 +0100
++++ tests/Makefile	2014-01-25 19:14:24.000000000 +0100
+@@ -11,7 +11,7 @@
+ endif
+ 
+ 
+-CFLAGS += -fPIC -O3 -Wall -I$(INCDIR) -L$(LIBDIR)
++CFLAGS += -fPIC -Wall -I$(INCDIR) -L$(LIBDIR)
+ 
+ LIBNAME = capstone
+ 
+@@ -48,8 +48,8 @@
+ $(BINARY): $(OBJS)
+ 
+ %$(BIN_EXT): %.o
+-	${CC} $(CFLAGS) $(LDFLAGS) $< -O3 -Wall -l$(LIBNAME) -o $@
+-	${CC} $(CFLAGS) $(LDFLAGS) $< -O3 -Wall ../lib$(LIBNAME).$(AR_EXT) -o $(subst $(BIN_EXT),,$@).static$(BIN_EXT)
++	${CC} $(CFLAGS) $(LDFLAGS) $< -Wall -l$(LIBNAME) -o $@
++	${CC} $(CFLAGS) $(LDFLAGS) $< -Wall ../lib$(LIBNAME).$(AR_EXT) -o $(subst $(BIN_EXT),,$@).static$(BIN_EXT)
+ 
+ %.o: %.c
+ 	${CC} ${CFLAGS} -c $< -o $@

Added: head/devel/capstone/pkg-descr
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/devel/capstone/pkg-descr	Mon Jan 27 07:00:24 2014	(r341330)
@@ -0,0 +1,16 @@
+Capstone is a lightweight multi-platform, multi-architecture disassembly
+framework.
+
+Features:
+ * Supported architectures: ARM, ARM64 (aka ARMv8), Mips, PowerPC & X86
+ * Clean/simple/lightweight/intuitive architecture-neutral API
+ * Provide details on disassembled instruction (called "decomposer")
+ * Provide some semantics of the disassembled instruction, such as list of
+   implicit registers read & written.
+ * Implemented in pure C language, with bindings for Python, Ruby, C#, Java,
+   GO, OCaml & Vala available.
+ * Native support for Windows & *nix (including MacOSX, Linux, *BSD & Solaris)
+ * Thread-safe by design
+ * Distributed under the open source BSD license
+
+WWW: http://capstone-engine.org/

Added: head/devel/capstone/pkg-plist
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/devel/capstone/pkg-plist	Mon Jan 27 07:00:24 2014	(r341330)
@@ -0,0 +1,10 @@
+include/capstone/arm.h
+include/capstone/arm64.h
+include/capstone/capstone.h
+include/capstone/mips.h
+include/capstone/ppc.h
+include/capstone/x86.h
+lib/libcapstone.a
+lib/libcapstone.so
+libdata/pkgconfig/capstone.pc
+@dirrmtry include/capstone
_______________________________________________
svn-ports-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-ports-all
To unsubscribe, send any mail to "svn-ports-all-unsubscribe@freebsd.org"
Comment 4 Kubilay Kocak freebsd_committer freebsd_triage 2014-01-27 08:10:00 UTC
State Changed
From-To: open->closed

New port added, with changes. Thanks Oliver!
Comment 5 Oliver Pinter 2014-01-29 02:31:32 UTC
On 1/27/14, Kubilay Kocak <koobs.freebsd@gmail.com> wrote:
> Oliver,
>
> First, thanks for your submission. I am about to commit it to the tree,
> and wanted to follow-up with a review for your reference:
>
> Portlint warnings:
>
> WARN: capstone/pkg-plist: [8]: installing shared libraries, please
>       define USE_LDCONFIG as appropriate
> WARN: capstone/pkg-descr: includes lines that exceed 80 characters.
> WARN: capstone/pkg-descr: contains a URL but no "WWW:"
> WARN: Makefile: COMMENT should begin with a capital, and end without
>       a period
> WARN: Makefile: seems to have unnecessary blank lines at the last part.
>
> - Dont override MAKE_ENV (unless theres a good reason to), use +=
>
> MAKE_ENV+=       INSTALL_DATA="${INSTALL_DATA}"
>
> - Use \ to break up an assignment into multiple lines:
>
> MAKE_ENV+=       INSTALL_DATA="${INSTALL_DATA}" \
>                 INSTALL_LIBRARY="${INSTALL_DATA}"
>
> - INSTALL_DATA is already passed to MAKE_ENV
> - INSTALL_LIB is the correct variable for INSTALL_LIBRARY to install
>   a stripped library
>
> /!\ capstone-2.0: Makefile warnings, please consider fixing /!\
>
> LICENSE must not contain BSD, instead use BSD[234]CLAUSE
>
> For the above and other QA/Sanity checking, enable port developer
> warnings in /etc/make.conf:
>
> #
> http://lists.freebsd.org/pipermail/freebsd-ports/2013-September/086022.html
> DEVELOPER=yes
> DEV_WARNING_WAIT=1
>
> For the pre-install REINPLACE_CMD, the PORTSDIR may not be /usr/ports.
> Update post-build: regular expression to suite (Thanks xmj via IRC)
>
> ${REINPLACE_CMD} -e
> '/libdir/s|\(libdir=\)\(.*\)\(devel/capstone/work/stage\)|\1|g'
> ${WRKSRC}/capstone.pc
>
> A few tips below to ensure your submissions are addressed as quickly as
> possible in future:
>
> - Enable ports developer warnings in /etc/make.conf
> - Use portlint to check your port before submission
> - Use redports poudriere to test your portbuilds on all versions/archs
> - Include portlint output and redports/poudriere build logs in your PR
>
> Eg:
>
> portlint: OK
> redports: OK (url)
>
> If you'd like more info, detail or help, jump on IRC, #bsdports efnet or
> #freebsd-ports freenode and say hi
>

Thanks for the feedback. I keep in mind those.

I started to use redports, and it's seems like neither INSTALL_LIB nor
INSTALL_DATA passed down to make.

After explicitly passed it's, then the file permission are fine:

===>   Generating temporary packing list
gmake[2]: Entering directory `/work/a/ports/devel/capstone/work/capstone-2.0'
mkdir -p /work/a/ports/devel/capstone/work/stage/usr/local/lib
install  -s -o root -g wheel -m 444 libcapstone.so
/work/a/ports/devel/capstone/work/stage/usr/local/lib
install  -o root -g wheel -m 444 libcapstone.a
/work/a/ports/devel/capstone/work/stage/usr/local/lib
mkdir -p /work/a/ports/devel/capstone/work/stage/usr/local/include/capstone
install  -o root -g wheel -m 444 include/*.h
/work/a/ports/devel/capstone/work/stage/usr/local/include/capstone
mkdir -p /work/a/ports/devel/capstone/work/stage/usr/local/libdata/pkgconfig
install  -o root -g wheel -m 444 capstone.pc
/work/a/ports/devel/capstone/work/stage/usr/local/libdata/pkgconfig/
gmake[2]: Leaving directory `/work/a/ports/devel/capstone/work/capstone-2.0'

but when not passed, then not, see svn log:
https://redports.org/log/op?action=stop_on_copy&mode=stop_on_copy&rev=22461&stop_rev=&limit=100&verbose=on