forked from zeromq/zproject
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzproject_redhat.gsl
215 lines (195 loc) · 5.24 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
# Generate spec file for project
#
# This is a code generator built using the iMatix GSL code generation
# language. See https://github.com/imatix/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 main.service ?= 1
. systemd = 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
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
BuildRequires: gcc-c++
.endif
.for project.use
.if defined(use.redhat_name)
BuildRequires: $(use.redhat_name)
.else
BuildRequires: $(use.project)-devel
.endif
.endfor
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%description
$(project.name) $(project.description).
.if project.exports_classes
%package -n $(project.libname)$(project->version.major)
Group: System/Libraries
Summary: $(project.description)
%description -n $(project.libname)$(project->version.major)
$(project.name) $(project.description).
This package contains shared library.
%post -n $(project.libname)$(project->version.major) -p /sbin/ldconfig
%postun -n $(project.libname)$(project->version.major) -p /sbin/ldconfig
%files -n $(project.libname)$(project->version.major)
%defattr(-,root,root)
.if file.exists ('COPYING')
%doc COPYING
.endif
%{_libdir}/$(project.libname).so.*
%package devel
Summary: $(project.description)
Group: System/Libraries
Requires: $(project.libname)$(project->version.major) = %{version}
.for project.use
.if defined(use.redhat_name)
Requires: $(use.redhat_name)
.else
Requires: $(use.project)-devel
.endif
.endfor
%description devel
$(project.name) $(project.description).
This package contains development files.
%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
. if count (class, defined (class.api))
%{_datadir}/zproject/
%{_datadir}/zproject/$(project.name)/
. endif
.endif
%prep
%setup -q
%build
sh autogen.sh
.if systemd ?= 1
%{configure} --enable-drafts=%{DRAFTS} --with-systemd-units
.else
%{configure} --enable-drafts=%{DRAFTS}
.endif
make %{_smp_mflags}
%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 has_main | count(project.bin) > 0
%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
.if file.exists ("src/$(main.name).cfg.example")
%{_sysconfdir}/$(project.name)/$(main.name).cfg.example
.etc_exists = 1
.endif
.endfor
.for project.bin
%{_bindir}/$(bin.name)
.endfor
.# generate service file names
.for project.main where main.service ?= 1
%config(noreplace) %{_sysconfdir}/$(project.name)/$(main.name).cfg
/usr/lib/systemd/system/$(main.name).service
.etc_exists = 1
.endfor
.if etc_exists ?= 1
%dir %{_sysconfdir}/$(project.name)
.endif
.if systemd ?= 1
%if 0%{?suse_version} > 1315
%post
%systemd_post\
. for project.main where main.service ?= 1
$(main.name).service\
. endfor
%preun
%systemd_preun\
. for project.main where main.service ?= 1
$(main.name).service\
. endfor
%postun
%systemd_postun_with_restart\
. for project.main where main.service ?= 1
$(main.name).service\
. endfor
%endif
.endif
.endif
%changelog
.endmacro