Blob Blame History Raw
Name:           capstone
Version:        3.0.5
Release:        1%{?dist}
Summary:        A lightweight multi-platform, multi-architecture disassembly framework

%global         gituser         aquynh
%global         gitname         capstone
%global         commit          db19431d4bb787019ca94d8f2a558f0ed46341a7
%global         shortcommit     %(c=%{commit}; echo ${c:0:7})

License:        BSD
URL:            http://www.capstone-engine.org/
Source0:        https://github.com/%{gituser}/%{gitname}/archive/%{commit}/%{name}-%{version}-%{shortcommit}.tar.gz

# Fedora 29 makes python executable separate from python2 and python3. This patch makes
# it possible to specify PYTHON2 and PYTHON3 binary to be explicit that by "python" we mean "python2"
Patch0:         capstone-python.patch

%if 0%{?fedora} > 12
%global with_python3 1
%else
%{!?__python2: %global __python2 /usr/bin/python2}
%{!?python2_sitelib: %global python2_sitelib %(%{__python2} -c "from distutils.sysconfig import get_python_lib; print (get_python_lib())")}
%endif

%global srcname distribute

BuildRequires:  gcc
BuildRequires:  git
BuildRequires:  python2
BuildRequires:  python2-devel
BuildRequires:  python2-setuptools
BuildRequires:  jna
BuildRequires:  java-devel

%if 0%{?with_python3}
BuildRequires:  python%{python3_pkgversion}
BuildRequires:  python%{python3_pkgversion}-devel
BuildRequires:  python%{python3_pkgversion}-setuptools
%endif # if with_python3
%global _hardened_build 1


%description
Capstone is a disassembly framework with the target of becoming the ultimate
disasm engine for binary analysis and reversing in the security community.

%package        devel
Summary:        Development files for %{name}
Requires:       %{name}%{?_isa} = %{version}-%{release}

%description    devel
The %{name}-devel package contains libraries and header files for
developing applications that use %{name}.

%package        -n python2-capstone
%{?python_provide:%python_provide python2-capstone}
# Remove before F30
Provides:       %{name}-python = %{version}-%{release}
Provides:       %{name}-python%{?_isa} = %{version}-%{release}
Obsoletes:      %{name}-python < %{version}-%{release}
Summary:        Python bindings for %{name}
Requires:       %{name}%{?_isa} = %{version}-%{release}

%description    -n python2-capstone
The %{name}-python package contains python bindings for %{name}.

%if 0%{?with_python3}
%package	-n python%{python3_pkgversion}-capstone
%{?python_provide:%python_provide python%{python3_pkgversion}-capstone}
# Remove before F30
Provides:       %{name}-python%{python3_pkgversion} = %{version}-%{release}
Provides:       %{name}-python%{python3_pkgversion}%{?_isa} = %{version}-%{release}
Obsoletes:      %{name}-python%{python3_pkgversion} < %{version}-%{release}
Summary:        Python bindings for %{name}
Requires:       %{name}%{?_isa} = %{version}-%{release}


Summary:	Python3 bindings for %{name}
Requires:	%{name}%{?_isa} = %{version}-%{release}

%description	-n python%{python3_pkgversion}-capstone
The %{name}-python3 package contains python3 bindings for %{name}.
%endif # with_python3

%package        java
Summary:        Java bindings for %{name}
Requires:       %{name} = %{version}-%{release}
BuildArch:      noarch

%description    java
The %{name}-java package contains java bindings for %{name}.

%prep
%autosetup -n %{gitname}-%{commit} -S git

%build
DESTDIR="%{buildroot}" 	V=1 CFLAGS="%{optflags}" \
LIBDIRARCH="%{_lib}" INCDIR="%{_includedir}" \
make PYTHON2=%{__python2} PYTHON3=%{__python3} %{?_smp_mflags}

# Fix pkgconfig file
sed -i 's;%{buildroot};;' capstone.pc
grep -v archive capstone.pc > capstone.pc.tmp
mv capstone.pc.tmp capstone.pc

# build python bindings
pushd bindings/python
CFLAGS="%{optflags}" %{__python2} setup.py build
%if 0%{?with_python3}
CFLAGS="%{optflags}" %{__python3} setup.py build
%endif # with_python3
popd

# build java bindings
pushd bindings/java
make PYTHON2=%{__python2} PYTHON3=%{__python3} CFLAGS="%{optflags}" # %{?_smp_mflags} parallel seems broken
popd

%install
DESTDIR=%{buildroot} LIBDIRARCH=%{_lib} \
INCDIR="%{_includedir}" make install
find %{buildroot} -name '*.la' -exec rm -f {} ';'
find %{buildroot} -name '*.a' -exec rm -f {} ';'

# install python bindings
pushd bindings/python
%{__python2} setup.py install --skip-build --root %{buildroot}
%if 0%{?with_python3}
%{__python3} setup.py install --skip-build --root %{buildroot}
%endif # with_python3
popd

# install java bindings
install -D -p -m 0644 bindings/java/%{name}.jar  %{buildroot}/%{_javadir}/%{name}.jar

%check
ln -s libcapstone.so libcapstone.so.3
make check LD_LIBRARY_PATH="`pwd`"

%post -p /sbin/ldconfig

%postun -p /sbin/ldconfig


%files
# %license does not work for RHEL<7
%if 0%{?rhel} || 0%{?fedora} < 21
%doc LICENSE.TXT LICENSE_LLVM.TXT
%else
%license LICENSE.TXT LICENSE_LLVM.TXT
%endif # %license workarond for RHEL<7
%doc README ChangeLog
%{_libdir}/*.so.*
%{_bindir}/cstool

%files devel
%{_includedir}/*
%{_libdir}/*.so
%{_libdir}/pkgconfig/*

%files -n python2-capstone
%{python2_sitelib}/*egg-info
%{python2_sitelib}/%{name}

%if 0%{?with_python3}
%files -n python%{python3_pkgversion}-capstone
%{python3_sitelib}/*egg-info
%{python3_sitelib}/%{name}
%endif # _with_python3

%files java
%{_javadir}/

%changelog
* Mon Aug 27 2018 Michal Ambroz <rebus _AT seznam.cz> - 3.0.5-1
- bump to 3.0.5

* Thu Jul 12 2018 Fedora Release Engineering <releng@fedoraproject.org> - 3.0.4-18
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild

* Mon Jul 02 2018 Miro Hrončok <mhroncok@redhat.com> - 3.0.4-17
- Rebuilt for Python 3.7

* Tue Jun 26 2018 Michal Ambroz <rebus _AT seznam.cz> - 3.0.4-16
- unify the naming convention for the python packages
- fix the python3 package naming for EPEL7

* Tue Jun 19 2018 Miro Hrončok <mhroncok@redhat.com> - 3.0.4-15
- Rebuilt for Python 3.7

* Fri Feb 09 2018 Igor Gnatenko <ignatenkobrain@fedoraproject.org> - 3.0.4-14
- Escape macros in %%changelog

* Wed Feb 07 2018 Fedora Release Engineering <releng@fedoraproject.org> - 3.0.4-13
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild

* Sun Aug 20 2017 Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> - 3.0.4-12
- Add Provides for the old name without %%_isa

* Sat Aug 19 2017 Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> - 3.0.4-11
- Python 2 binary package renamed to python2-capstone
  See https://fedoraproject.org/wiki/FinalizingFedoraSwitchtoPython3

* Wed Aug 02 2017 Fedora Release Engineering <releng@fedoraproject.org> - 3.0.4-10
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild

* Wed Jul 26 2017 Fedora Release Engineering <releng@fedoraproject.org> - 3.0.4-9
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild

* Fri Feb 10 2017 Fedora Release Engineering <releng@fedoraproject.org> - 3.0.4-8
- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild

* Mon Dec 19 2016 Miro Hrončok <mhroncok@redhat.com> - 3.0.4-7
- Rebuild for Python 3.6

* Tue Jul 19 2016 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 3.0.4-6
- https://fedoraproject.org/wiki/Changes/Automatic_Provides_for_Python_RPM_Packages

* Wed Feb 03 2016 Fedora Release Engineering <releng@fedoraproject.org> - 3.0.4-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild

* Tue Oct 27 2015 Stefan Cornelius <scorneli@redhat.com> - 3.0.4-4
- Really add dist tag this time

* Sun Oct 25 2015 Stefan Cornelius <scorneli@redhat.com> - 3.0.4-3
- Fix issues found during package review: dist tag, git sources

* Thu Jul 16 2015 Stefan Cornelius <scorneli@redhat.com> - 3.0.4-2
- Fix EPEL6 build problems

* Wed Jul 15 2015 Stefan Cornelius <scorneli@redhat.com> - 3.0.4-1
- new version 3.0.4. Includes security fixes.

* Tue May 12 2015 Stefan Cornelius <scorneli@redhat.com> - 3.0.3-2
- Addressed issues found during package review.

* Fri May 08 2015 Stefan Cornelius <scorneli@redhat.com> - 3.0.3-1
-  Update to version 3.0.3

* Fri May 08 2015 Stefan Cornelius <scorneli@redhat.com> - 3.0.2-3
- Added python3 and hardened build support. Update java building.
- Various cleanups.

* Wed May 06 2015 Stefan Cornelius <scorneli@redhat.com> - 3.0.2-2
- Update to 3.0.2. Fix 64bit issues. add %%check.

* Sat Sep 27 2014 Adel Gadllah <adel.gadllah@gmail.com> - 2.1.2-2
- Addressed issues found during package review.

* Mon May 19 2014 Adel Gadllah <adel.gadllah@gmail.com> - 2.1.2-1
- Initial package