forked from zeromq/zproject
-
Notifications
You must be signed in to change notification settings - Fork 0
/
zproject_redhat.gsl
500 lines (465 loc) · 16.9 KB
/
zproject_redhat.gsl
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
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
# Generate spec file for project
#
# This is a code generator built using the iMatix GSL code generation
# language. See https://github.com/zeromq/gsl for details.
#
# Copyright (c) the Contributors as noted in the AUTHORS file.
# This file is part of zproject.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
register_target ("redhat", "packaging for RedHat")
.macro target_redhat
.for project.main where ( defined(main.service) & main.service > 0 )
. systemd = 1
.endfor
.for project.target where ( target.name = "*" | target.name = "python_cffi" > 0 )
. python_cffi = 1
.endfor
.directory.create ('packaging/redhat')
.output "packaging/redhat/$(project.name).spec"
#
# $(project.name) - $(project.description?'':)
#
. for project.license
# $(string.trim (license.):block )
. endfor
#
# To build with draft APIs, use "--with drafts" in rpmbuild for local builds or add
# Macros:
# %_with_drafts 1
# at the BOTTOM of the OBS prjconf
%bcond_with drafts
%if %{with drafts}
%define DRAFTS yes
%else
%define DRAFTS no
%endif
. if !has_main & !project.exports_classes
%global debug_package %{nil}
. endif
.if systemd ?= 1
%define SYSTEMD_UNIT_DIR %(pkg-config --variable=systemdsystemunitdir systemd)
.endif
.if python_cffi ?= 1
# build with python_cffi support enabled
%bcond_with python_cffi
%if %{with python_cffi}
%define py2_ver %(python2 -c "import sys; print ('%d.%d' % (sys.version_info.major, sys.version_info.minor))")
%endif
# build with python3_cffi support enabled
%bcond_with python3_cffi
%if %{with python3_cffi}
%define py3_ver %(python3 -c "import sys; print ('%d.%d' % (sys.version_info.major, sys.version_info.minor))")
%endif
.endif
Name: $(project.name)
Version: $(project->version.major).$(project->version.minor).$(project->version.patch)
Release: 1
Summary: $(project.description)
License: $(project.license?"MIT")
URL: $(project.url?"http://example.com/")
Source0: %{name}-%{version}.tar.gz
Group: System/Libraries
# Note: ghostscript is required by graphviz which is required by
# asciidoc. On Fedora 24 the ghostscript dependencies cannot
# be resolved automatically. Thus add working dependency here!
BuildRequires: ghostscript
BuildRequires: asciidoc
BuildRequires: automake
BuildRequires: autoconf
BuildRequires: libtool
BuildRequires: pkgconfig
.if systemd ?= 1
BuildRequires: systemd-devel
BuildRequires: systemd
%{?systemd_requires}
.endif
BuildRequires: xmlto
.if project.use_cxx
. if defined(project.use_cxx_gcc_4_9) & !(project.use_cxx_gcc_4_9 ?= 0)
# Note that with current implementation of zproject use-cxx-gcc-4-9 option,
# this effectively hardcodes the use of specifically 4.9, not allowing for
# "4.9 or newer".
BuildRequires: devtoolset-3-gcc devtoolset-3-gcc-c++
BuildRequires: gcc-c++ >= 4.9.0
. else
BuildRequires: gcc-c++
. endif
.endif
.for project.use
.if defined(use.redhat_name)
. if !(use.redhat_name = '')
BuildRequires: $(use.redhat_name)\
. else
. echo "WARNING: redhat_name=='' for $(use.project) - not added to packaging/redhat/$(project.name).spec"
. endif
.else
BuildRequires: $(use.project)-devel\
.endif
. if (use.min_version <> '0.0.0')
>= $(use.min_version)\
. endif
.endfor
.if python_cffi ?= 1
%if %{with python_cffi}
BuildRequires: python-cffi
BuildRequires: python-devel
BuildRequires: python-setuptools
%endif
%if %{with python3_cffi}
BuildRequires: python3-devel
BuildRequires: python3-cffi
BuildRequires: python3-setuptools
%endif
.endif
BuildRoot: %{_tmppath}/%{name}-%{version}-build
.if project.has_main | project.has_bin
.for project.use where use.type ?= "runtime"
.if defined(use.redhat_name)
. if !(use.redhat_name = '')
Requires: $(use.redhat_name)\
. else
. echo "WARNING: redhat_name=='' for $(use.project) - not added to packaging/redhat/$(project.name).spec"
. endif
.elsif regexp.match("^lib", use.libname)
Requires: $(string.replace (use.libname, "_|-"))\
.else
Requires: $(string.replace (use.project, "_|-"))\
.endif
. if (use.min_version <> '0.0.0')
>= $(use.min_version)\
. endif
.endfor
.endif
%description
$(project.name) $(project.description).
.if defined (project->abi)
. my.abi_ver = project->abi.current - project->abi.age
.else
. my.abi_ver = 0
.endif
.if project.exports_classes | ( project.has_classes & project.has_main )
.# NOTE: Now for at least some compilers the symbol visibility seems to
.# be managed in the shared library files, not the "exportedness" - so
.# the delivered compiled binary files can use and do require those libs
.# packaged even if all classes are marked private - should have at least
.# one though. Also note that "bin" files are not necessarily compiled,
.# e.g. helper scripts, so are not covered in this clause.
%package -n $(project.libname)$(my.abi_ver)
Group: System/Libraries
Summary: $(project.description) shared library
%description -n $(project.libname)$(my.abi_ver)
This package contains shared library for $(project.name): $(project.description)
%post -n $(project.libname)$(my.abi_ver) -p /sbin/ldconfig
%postun -n $(project.libname)$(my.abi_ver) -p /sbin/ldconfig
%files -n $(project.libname)$(my.abi_ver)
%defattr(-,root,root)
.if file.exists ('COPYING')
%doc COPYING
.endif
%{_libdir}/$(project.libname).so.*
.endif
.if project.exports_classes
.# NOTE: The development libs/headers make sense if any class was not
.# marked private - different from just the lib package above.
%package devel
Summary: $(project.description)
Group: System/Libraries
Requires: $(project.libname)$(my.abi_ver) = %{version}
.for project.use
.if defined(use.redhat_name)
. if !(use.redhat_name = '')
Requires: $(use.redhat_name)\
. else
. echo "WARNING: redhat_name=='' for $(use.project) - not added to packaging/redhat/$(project.name).spec"
. endif
.else
Requires: $(use.project)-devel\
.endif
. if (use.min_version <> '0.0.0')
>= $(use.min_version)\
. endif
.endfor
%description devel
$(project.description) development tools
This package contains development files for $(project.name): $(project.description)
%files devel
%defattr(-,root,root)
%{_includedir}/*
%{_libdir}/$(project.libname).so
%{_libdir}/pkgconfig/$(project.libname).pc
. discover_manpages(project)
. if man3 ?<> ""
%{_mandir}/man3/*
. endif
. if man7 ?<> ""
%{_mandir}/man7/*
. endif
. for class where defined (class.api)
. if first ()
# Install api files into /usr/local/share/zproject
%dir %{_datadir}/zproject/
%dir %{_datadir}/zproject/$(project.name)
%{_datadir}/zproject/$(project.name)/*
. endif
. endfor
.endif
.if python_cffi ?= 1
%if %{with python_cffi}
%package -n python2-$(project.name)-cffi
Group: Python
Summary: Python CFFI bindings for $(project.name)
Requires: python >= %{py2_ver}.0, python < 3.0.0
%description -n python2-$(project.name)-cffi
This package contains Python CFFI bindings for $(project.name)
%files -n python2-$(project.name)-cffi
%{_libdir}/python%{py2_ver}/site-packages/$(project.name:c)_cffi/
%{_libdir}/python%{py2_ver}/site-packages/$(project.name:c)_cffi-*-py%{py2_ver}.egg-info/
%endif
%if %{with python3_cffi}
%package -n python3-$(project.name)-cffi
Group: Python
Summary: Python 3 CFFI bindings for $(project.name)
Requires: python = %{py3_ver}
%description -n python3-$(project.name)-cffi
This package contains Python 3 CFFI bindings for $(project.name)
%files -n python3-$(project.name)-cffi
%{_libdir}/python%{py3_ver}/site-packages/$(project.name:c)_cffi/
%{_libdir}/python%{py3_ver}/site-packages/$(project.name:c)_cffi-*-py%{py3_ver}.egg-info/
%endif
.endif
%prep
.if python_cffi ?= 1
#FIXME: error:... did not worked for me
%if %{with python_cffi}
%if %{without drafts}
echo "FATAL: python_cffi not yet supported w/o drafts"
exit 1
%endif
%endif
.endif
%setup -q
%build
sh autogen.sh
%{configure} --enable-drafts=%{DRAFTS}\
.if systemd ?= 1
--with-systemd-units\
.endif
.for project.use where use.optional
--with-$(use.libname)=yes\
.endfor
make %{_smp_mflags}
.if python_cffi ?= 1
%if %{with python_cffi} || %{with python3_cffi}
# Problem: we need pkg-config points to built and not yet installed copy of $(project.name)
# Solution: chicken-egg problem - let's make "fake" pkg-config file
sed -e "s@^libdir.*@libdir=.libs/@" \\
-e "s@^includedir.*@includedir=include/@" \\
src/$(project.libname).pc > bindings/python_cffi/$(project.libname).pc
cd bindings/python_cffi
# This avoids problem with "weird" character quoting between shell and python3
ln -sfr ../../include/ .
ln -sfr ../../src/.libs/ .
export PKG_CONFIG_PATH=`pwd`
%endif
%if %{with python_cffi}
python2 setup.py build
%endif
%if %{with python3_cffi}
python3 setup.py build
%endif
.endif
%install
make install DESTDIR=%{buildroot} %{?_smp_mflags}
# remove static libraries
find %{buildroot} -name '*.a' | xargs rm -f
find %{buildroot} -name '*.la' | xargs rm -f
.if python_cffi ?= 1
%if %{with python_cffi} || %{with python3_cffi}
cd bindings/python_cffi
export PKG_CONFIG_PATH=`pwd`
%endif
%if %{with python_cffi}
python2 setup.py install --root=%{buildroot} --skip-build --prefix %{_prefix}
%endif
%if %{with python3_cffi}
python3 setup.py install --root=%{buildroot} --skip-build --prefix %{_prefix}
%endif
.endif
.if has_main | project.has_bin
%files
%defattr(-,root,root)
.if file.exists ('README.md')
%doc README.md
.endif
.if file.exists ('README.txt')
%doc README.txt
.endif
.if file.exists ('README.asciidoc')
%doc README.asciidoc
.endif
.if file.exists ('COPYING')
%doc COPYING
.endif
.# generate binary names
.for project.main where scope = "public"
%{_bindir}/$(main.name)
. if man1 ?<> ""
%{_mandir}/man1/$(main.name)*
. endif
.endfor
.for project.bin
%{_bindir}/$(bin.name)
.endfor
.# generate service file names
.for project.main where ( defined(main.service) & main.service > 0 )
. if !defined(main.no_config) | main.no_config ?= 0
%config(noreplace) %{_sysconfdir}/$(project.name)/$(main.name).cfg
. endif
. if file.exists("src/$(main.name).service") | file.exists("src/$(main.name).service.in") | ( main.service ?= 1 | main.service ?= 3 )
%{SYSTEMD_UNIT_DIR}/$(main.name).service
. endif
. if file.exists("src/$(main.name)@.service") | file.exists("src/$(main.name)@.service.in") | ( main.service ?= 2 | main.service ?= 3 )
%{SYSTEMD_UNIT_DIR}/$(main.name)@.service
. endif
.etc_exists = 1
.endfor
.for project.main where ( defined(main.timer) & main.timer > 0 )
. if file.exists("src/$(main.name).timer") | file.exists("src/$(main.name).timer.in") | ( main.timer ?= 1 | main.timer ?= 3 )
%{SYSTEMD_UNIT_DIR}/$(main.name).timer
. endif
. if file.exists("src/$(main.name)@.timer") | file.exists("src/$(main.name)@.timer.in") | ( main.timer ?= 2 | main.timer ?= 3 )
%{SYSTEMD_UNIT_DIR}/$(main.name)@.timer
. endif
.endfor
.for project.bin where ( defined(bin.service) & bin.service > 0 )
. if file.exists("src/$(bin.name).service") | file.exists("src/$(bin.name).service.in") | ( bin.service ?= 1 | bin.service ?= 3 )
%{SYSTEMD_UNIT_DIR}/$(bin.name).service
. endif
. if file.exists("src/$(bin.name)@.service") | file.exists("src/$(bin.name)@.service.in") | ( bin.service ?= 2 | bin.service ?= 3 )
%{SYSTEMD_UNIT_DIR}/$(bin.name)@.service
. endif
.endfor
.for project.bin where ( defined(bin.timer) & bin.timer > 0 )
. if file.exists("src/$(bin.name).timer") | file.exists("src/$(bin.name).timer.in") | ( bin.timer ?= 1 | bin.timer ?= 3 )
%{SYSTEMD_UNIT_DIR}/$(bin.name).timer
. endif
. if file.exists("src/$(bin.name)@.timer") | file.exists("src/$(bin.name)@.timer.in") | ( bin.timer ?= 2 | bin.timer ?= 3 )
%{SYSTEMD_UNIT_DIR}/$(bin.name)@.timer
. endif
.endfor
.if etc_exists ?= 1
%dir %{_sysconfdir}/$(project.name)
.endif
.insert_snippet ("redhat.spec")
.if systemd ?= 1
%if 0%{?suse_version} > 1315
%post
%systemd_post\
. for project.main where ( defined(main.service) & main.service > 0 )
. if file.exists("src/$(main.name).service") | file.exists("src/$(main.name).service.in") | ( main.service ?= 1 | main.service ?= 3 )
$(main.name).service\
. endif
. if file.exists("src/$(main.name)@.service") | file.exists("src/$(main.name)@.service.in") | ( main.service ?= 2 | main.service ?= 3 )
$(main.name)@.service\
. endif
. endfor
. for project.main where ( defined(main.timer) & main.timer > 0 )
. if file.exists("src/$(main.name).timer") | file.exists("src/$(main.name).timer.in") | ( main.timer ?= 1 | main.timer ?= 3 )
$(main.name).timer\
. endif
. if file.exists("src/$(main.name)@.timer") | file.exists("src/$(main.name)@.timer.in") | ( main.timer ?= 2 | main.timer ?= 3 )
$(main.name)@.timer\
. endif
. endfor
. for project.bin where ( defined(bin.service) & bin.service > 0 )
. if file.exists("src/$(bin.name).service") | file.exists("src/$(bin.name).service.in") | ( bin.service ?= 1 | bin.service ?= 3 )
$(bin.name).service\
. endif
. if file.exists("src/$(bin.name)@.service") | file.exists("src/$(bin.name)@.service.in") | ( bin.service ?= 2 | bin.service ?= 3 )
$(bin.name)@.service\
. endif
. endfor
. for project.bin where ( defined(bin.timer) & bin.timer > 0 )
. if file.exists("src/$(bin.name).timer") | file.exists("src/$(bin.name).timer.in") | ( bin.timer ?= 1 | bin.timer ?= 3 )
$(bin.name).timer\
. endif
. if file.exists("src/$(bin.name)@.timer") | file.exists("src/$(bin.name)@.timer.in") | ( bin.timer ?= 2 | bin.timer ?= 3 )
$(bin.name)@.timer\
. endif
. endfor
%preun
%systemd_preun\
. for project.main where ( defined(main.service) & main.service > 0 )
. if file.exists("src/$(main.name).service") | file.exists("src/$(main.name).service.in") | ( main.service ?= 1 | main.service ?= 3 )
$(main.name).service\
. endif
. if file.exists("src/$(main.name)@.service") | file.exists("src/$(main.name)@.service.in") | ( main.service ?= 2 | main.service ?= 3 )
$(main.name)@.service\
. endif
. endfor
. for project.main where ( defined(main.timer) & main.timer > 0 )
. if file.exists("src/$(main.name).timer") | file.exists("src/$(main.name).timer.in") | ( main.timer ?= 1 | main.timer ?= 3 )
$(main.name).timer\
. endif
. if file.exists("src/$(main.name)@.timer") | file.exists("src/$(main.name)@.timer.in") | ( main.timer ?= 2 | main.timer ?= 3 )
$(main.name)@.timer\
. endif
. endfor
. for project.bin where ( defined(bin.service) & bin.service > 0 )
. if file.exists("src/$(bin.name).service") | file.exists("src/$(bin.name).service.in") | ( bin.service ?= 1 | bin.service ?= 3 )
$(bin.name).service\
. endif
. if file.exists("src/$(bin.name)@.service") | file.exists("src/$(bin.name)@.service.in") | ( bin.service ?= 2 | bin.service ?= 3 )
$(bin.name)@.service\
. endif
. endfor
. for project.bin where ( defined(bin.timer) & bin.timer > 0 )
. if file.exists("src/$(bin.name).timer") | file.exists("src/$(bin.name).timer.in") | ( bin.timer ?= 1 | bin.timer ?= 3 )
$(bin.name).timer\
. endif
. if file.exists("src/$(bin.name)@.timer") | file.exists("src/$(bin.name)@.timer.in") | ( bin.timer ?= 2 | bin.timer ?= 3 )
$(bin.name)@.timer\
. endif
. endfor
%postun
%systemd_postun_with_restart\
. for project.main where ( defined(main.service) & main.service > 0 )
. if file.exists("src/$(main.name).service") | file.exists("src/$(main.name).service.in") | ( main.service ?= 1 | main.service ?= 3 )
$(main.name).service\
. endif
. if file.exists("src/$(main.name)@.service") | file.exists("src/$(main.name)@.service.in") | ( main.service ?= 2 | main.service ?= 3 )
$(main.name)@.service\
. endif
. endfor
. for project.main where ( defined(main.timer) & main.timer > 0 )
. if file.exists("src/$(main.name).timer") | file.exists("src/$(main.name).timer.in") | ( main.timer ?= 1 | main.timer ?= 3 )
$(main.name).timer\
. endif
. if file.exists("src/$(main.name)@.timer") | file.exists("src/$(main.name)@.timer.in") | ( main.timer ?= 2 | main.timer ?= 3 )
$(main.name)@.timer\
. endif
. endfor
. for project.bin where ( defined(bin.service) & bin.service > 0 )
. if file.exists("src/$(bin.name).service") | file.exists("src/$(bin.name).service.in") | ( bin.service ?= 1 | bin.service ?= 3 )
$(bin.name).service\
. endif
. if file.exists("src/$(bin.name)@.service") | file.exists("src/$(bin.name)@.service.in") | ( bin.service ?= 2 | bin.service ?= 3 )
$(bin.name)@.service\
. endif
. endfor
. for project.bin where ( defined(bin.timer) & bin.timer > 0 )
. if file.exists("src/$(bin.name).timer") | file.exists("src/$(bin.name).timer.in") | ( bin.timer ?= 1 | bin.timer ?= 3 )
$(bin.name).timer\
. endif
. if file.exists("src/$(bin.name)@.timer") | file.exists("src/$(bin.name)@.timer.in") | ( bin.timer ?= 2 | bin.timer ?= 3 )
$(bin.name)@.timer\
. endif
. endfor
%endif
.endif
.endif
%changelog
.endmacro