summaryrefslogtreecommitdiffstats
path: root/capstone.spec
blob: 7ba4de20183b663d3ee82e98e6774806fad475b1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
Name:           capstone
Version:        4.0.2
Release:        10%{?dist}
Summary:        A lightweight multi-platform, multi-architecture disassembly framework

%global         gituser         aquynh
%global         gitname         capstone
# 4.0.2 release
%global         commit          1d230532840a37ac032c6ab80128238fc930c6c1
%global         shortcommit     %(c=%{commit}; echo ${c:0:7})

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

# Test suite binary samples to be used for disassembly
# Source1:

# 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

# Upstream patch which fixes libcapstone.pc.
# See: https://github.com/aquynh/capstone/issues/1339
# Patch1:         0001-Fix-include-path-in-pkg-config-for-Makefile-too-1339.patch

%global         common_desc %{expand:
Capstone is a disassembly framework with the target of becoming the ultimate
disasm engine for binary analysis and reversing in the security community.}

# Build with python3 package by default
%bcond_without  python3

# Build without python2 package for newer releases f32+ and rhel8+
%if (0%{?fedora} && 0%{?fedora} >= 32 ) || ( 0%{?rhel} && 0%{?rhel} >= 8 )
%bcond_with     python2
%else
%bcond_without  python2
%endif


%global srcname distribute

BuildRequires:  gcc
BuildRequires:  make
BuildRequires:  git
BuildRequires:  jna
BuildRequires:  java-devel

%if %{with python2}
BuildRequires:  python2
BuildRequires:  python2-devel
BuildRequires:  python2-setuptools
%endif

%if %{with python3}
BuildRequires:  python%{python3_pkgversion}
BuildRequires:  python%{python3_pkgversion}-devel
BuildRequires:  python%{python3_pkgversion}-setuptools
%endif

%global _hardened_build 1


%description
%{common_desc}

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

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



%if %{with python2}
%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
%{common_desc}
The python2-capstone package contains python bindings for %{name}.
# with_python2
%endif



%if %{with python3}
%package	-n python%{python3_pkgversion}-capstone
%{?python_provide:%python_provide python%{python3_pkgversion}-capstone}
Provides:       %{name}-python%{python3_pkgversion} = %{version}-%{release}
Provides:       %{name}-python%{python3_pkgversion}%{?_isa} = %{version}-%{release}
Obsoletes:      %{name}-python%{python3_pkgversion} < %{version}-%{release}
Requires:       %{name}%{?_isa} = %{version}-%{release}
Summary:        Python3 bindings for %{name}


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



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

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



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



%build
V=1 CFLAGS="%{optflags}" \
PREFIX="%{_prefix}" LIBDIRARCH="%{_lib}" INCDIR="%{_includedir}" \
%make_build PYTHON2=%{__python2} PYTHON3=%{__python3}

# 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

%if %{with python2}
%py2_build
%endif

%if %{with python3}
%py3_build
%endif
popd

# build java bindings needs some python
pushd bindings/java
%if %{with python3}
%make_build PYTHON2=%{__python3} PYTHON3=%{__python3} CFLAGS="%{optflags}" # %{?_smp_mflags} parallel seems broken
%else
%make_build PYTHON2=%{__python2} PYTHON3=%{__python2} CFLAGS="%{optflags}" # %{?_smp_mflags} parallel seems broken
%endif
popd



%install
DESTDIR=%{buildroot} PREFIX="%{_prefix}" 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
%if %{with python2}
%py2_install
%endif

%if %{with python3}
%py3_install
%endif
popd

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



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


%ldconfig_scriptlets



%files
%license LICENSE.TXT LICENSE_LLVM.TXT
%doc CREDITS.TXT ChangeLog README.md SPONSORS.TXT
%{_libdir}/*.so.*
%{_bindir}/cstool



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



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



%if %{with python3}
%files -n python%{python3_pkgversion}-capstone
%{python3_sitelib}/*egg-info
%{python3_sitelib}/%{name}
%endif



%files java
%{_javadir}/

%changelog
* Fri Sep 02 2022 Miroslav Rezanina <mrezanin@redhat.com> - 4.0.2-10
- Import to CentOS 9 Stream / RHEL 9

* Sat Feb 05 2022 Jiri Vanek <jvanek@redhat.com> - 4.0.2-9
- Rebuilt for java-17-openjdk as system jdk

* Wed Jan 19 2022 Fedora Release Engineering <releng@fedoraproject.org> - 4.0.2-8
- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild

* Wed Jul 21 2021 Fedora Release Engineering <releng@fedoraproject.org> - 4.0.2-7
- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild

* Fri Jun 04 2021 Python Maint <python-maint@redhat.com> - 4.0.2-6
- Rebuilt for Python 3.10

* Fri May 14 2021 Michal Ambroz <rebus AT_ seznam.cz> - 4.0.2-5
- modernize specfile, using with bcond and py*_build macros

* Tue Jan 26 2021 Fedora Release Engineering <releng@fedoraproject.org> - 4.0.2-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild

* Mon Jul 27 2020 Fedora Release Engineering <releng@fedoraproject.org> - 4.0.2-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild

* Wed Jul 22 2020 Riccardo Schirone <rschirone91@gmail.com> - 4.0.2-2
- Use make_build macro instead of make (thanks to tstellar)

* Mon Jul 20 2020 Riccardo Schirone <rschirone91@gmail.com> - 4.0.2-1
- Rebase to upstream version 4.0.2

* Fri Jul 10 2020 Jiri Vanek <jvanek@redhat.com> - 4.0.1-13
- Rebuilt for JDK-11, see https://fedoraproject.org/wiki/Changes/Java11

* Tue May 26 2020 Miro Hrončok <mhroncok@redhat.com> - 4.0.1-12
- Rebuilt for Python 3.9

* Tue Jan 28 2020 Fedora Release Engineering <releng@fedoraproject.org> - 4.0.1-11
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild

* Tue Jan 21 2020 Kalev Lember <klember@redhat.com> - 4.0.1-10
- Avoid hardcoding /usr prefix

* Tue Oct 15 2019 Michal Ambroz <rebus AT_ seznam.cz> - 4.0.1-9
- do not build python2 package for rhel8

* Thu Oct 10 2019 Michal Ambroz <rebus AT_ seznam.cz> - 4.0.1-8
- fix descriptions of sub-packages
- remove buildroot from the build phase

* Thu Oct 10 2019 Michal Ambroz <rebus AT_ seznam.cz> - 4.0.1-7
- remove python2 from rawhide/fc32 package

* Thu Oct 03 2019 Miro Hrončok <mhroncok@redhat.com> - 4.0.1-6
- Rebuilt for Python 3.8.0rc1 (#1748018)

* Mon Aug 19 2019 Miro Hrončok <mhroncok@redhat.com> - 4.0.1-5
- Rebuilt for Python 3.8

* Wed Jul 24 2019 Fedora Release Engineering <releng@fedoraproject.org> - 4.0.1-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild

* Thu Jan 31 2019 Fedora Release Engineering <releng@fedoraproject.org> - 4.0.1-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild

* Sat Jan 12 2019 Richard W.M. Jones <rjones@redhat.com> - 4.0.1-2
- Add upstream patch which fixes libcapstone.pc
  https://github.com/aquynh/capstone/issues/1339

* Fri Jan 11 2019 Michal Ambroz <rebus _AT seznam.cz> - 4.0.1-1
- bump to 4.0.1 release

* 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