]> git.pld-linux.org Git - packages/uwsgi.git/blob - uwsgi.spec
Up to 2.0.21.
[packages/uwsgi.git] / uwsgi.spec
1
2 %bcond_without xml
3 %bcond_without yaml
4 %bcond_without zeromq
5 %bcond_without ssl
6 %bcond_without pcre
7 %bcond_without routing
8 %bcond_without matheval
9 %bcond_without python2
10 %bcond_without python3
11 %bcond_without greenlet
12 %bcond_with json
13
14 %if %{without python2} && %{without python3}
15 %undefine with_greenlet
16 %endif
17
18 # TODO:
19 # - pl desc
20 # - apache, module?
21 # - 'gevent' plugin depends on python and works only after python plugin is loaded
22 #   this can probably be fixed by better linking
23
24 Summary:        Fast WSGI server
25 Summary(pl.UTF-8):      Szybki serwer WSGI
26 Name:           uwsgi
27 Version:        2.0.21
28 Release:        1
29 License:        GPL v2
30 Group:          Networking/Daemons
31 # Source0:      http://projects.unbit.it/downloads/%{name}-%{version}.tar.gz
32 Source0:        https://pypi.debian.net/uwsgi/%{name}-%{version}.tar.gz
33 # Source0-md5:  ebf1760c403ee8cdf4f22225f4eb4628
34 Source1:        %{name}.init
35 Source2:        emperor.ini
36 Source3:        %{name}.tmpfiles
37 Source4:        %{name}.service
38 Patch0:         shared_python.patch
39 URL:            http://projects.unbit.it/uwsgi/
40 %{?with_xml:BuildRequires:      libxml2-devel}
41 %{?with_yaml:BuildRequires:     yaml-devel}
42 %{?with_json:BuildRequires:     jansson-devel}
43 %{?with_zeromq:BuildRequires:   zeromq-devel}
44 %{?with_ssl:BuildRequires:      openssl-devel}
45 %{?with_matheval:BuildRequires: libmatheval-devel}
46 %{!?with_matheval:BuildConflicts:       libmatheval-devel}
47 %if %{with pcre} || %{with routing}
48 BuildRequires:  pcre-devel
49 %endif
50 BuildRequires:  libcap-devel
51 BuildRequires:  libuuid-devel
52 BuildRequires:  zlib-devel
53 BuildRequires:  python-modules
54 %if %{with python2}
55 BuildRequires:  python-devel >= 1:2.7
56 %{?with_greenlet:BuildRequires: python-greenlet-devel}
57 %endif
58 %if %{with python3}
59 BuildRequires:  python3-devel >= 1:2.7
60 %{?with_greenlet:BuildRequires: python3-greenlet-devel}
61 BuildRequires:  python3-modules
62 %endif
63 Requires(post,preun):   /sbin/chkconfig
64 Requires(postun):       /usr/sbin/groupdel
65 Requires(postun):       /usr/sbin/userdel
66 Requires(pre):  /bin/id
67 Requires(pre):  /usr/bin/getgid
68 Requires(pre):  /usr/sbin/groupadd
69 Requires(pre):  /usr/sbin/useradd
70 Requires:       rc-scripts >= 0.4.3.0
71 Requires:       systemd-units >= 38
72 Provides:       webserver(cgi)
73 Suggests:       uwsgi-plugin-python
74 BuildRoot:      %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
75
76 %define pyver %(echo %{py_ver} | tr -d .)
77 %define py3ver %(echo %{py3_ver} | tr -d .)
78
79 %define _noautoprovfiles %{_libdir}/%{name}/.*
80
81 %description
82 uWSGI is a fast (pure C), self-healing, developer-friendly WSGI
83 server, aimed for professional python webapps deployment and
84 development. Over time it has evolved in a complete stack for
85 networked/clustered python applications, implementing message/object
86 passing and process management. It uses the uwsgi (all lowercase)
87 protocol for all the networking/interprocess communications. From the
88 0.9.5 release it includes a plugin loading technology that can be used
89 to add support for other languages or platform. A Lua wsapi adaptor, a
90 PSGI handler and an Erlang message exchanger are already available.
91
92 %package plugin-python
93 Summary:        Python 2.x plugin for uWSGI
94 Group:          Networking/Daemons
95 Requires:       %{name} = %{version}-%{release}
96
97 %description plugin-python
98 Python 2.x plugin for uWSGI.
99
100 %package plugin-python3
101 Summary:        Python 3.x plugin for uWSGI
102 Group:          Networking/Daemons
103 Requires:       %{name} = %{version}-%{release}
104
105 %description plugin-python3
106 Python 3.x plugin for uWSGI.
107
108 %prep
109 %setup -q
110
111 %patch0 -p1
112
113 %build
114 cat >buildconf/pld.ini <<EOF
115 [uwsgi]
116 main_plugin =
117 embedded_plugins =
118 inherit = base
119 plugin_dir = %{_libdir}/uwsgi
120 plugin_build_dir = ${PWD}
121
122 xml = %{?with_xml:true}%{!?with_xml:false}
123 yaml = %{?with_yaml:true}%{!?with_yaml:false}
124 zeromq = %{?with_zeromq:true}%{!?with_zeromq:false}
125 ssl = %{?with_ssl:true}%{!?with_ssl:false}
126 pcre = %{?with_pcre:true}%{!?with_pcre:false}
127 routing = %{?with_routing:true}%{!?with_routing:false}
128 matheval = %{?with_matheval:true}%{!?with_matheval:false}
129 json = %{?with_json:true}%{!?with_json:false}
130
131 %{?with_xml:xml_implementation = libxml2}
132 EOF
133
134 export CFLAGS="%{rpmcflags}"
135 %{__python} uwsgiconfig.py --build pld
136
137 # base plugin list from buildconf/base.ini
138 for plugin in \
139         ping cache nagios rrdtool carbon rpc corerouter \
140         fastrouter http ugreen signal syslog rsyslog logsocket \
141         router_uwsgi router_redirect router_basicauth zergpool \
142         redislog mongodblog router_rewrite router_http logfile \
143         router_cache rawrouter router_static sslrouter spooler \
144         cheaper_busyness symcall transformation_tofile \
145         transformation_gzip transformation_chunked \
146         transformation_offload router_memcached router_redis \
147         router_hash router_expires router_metrics \
148         transformation_template stats_pusher_socket ; do
149
150         %{__python} uwsgiconfig.py --plugin plugins/${plugin} pld ${plugin}
151 done
152
153 # extra non-base plugins
154 for plugin in cgi systemd_logger ; do
155         %{__python} uwsgiconfig.py --plugin plugins/${plugin} pld ${plugin}
156 done
157
158 %if %{with python2}
159 %{__python} uwsgiconfig.py --plugin plugins/python pld python%{pyver}
160 %{__python} uwsgiconfig.py --plugin plugins/gevent pld gevent_py%{pyver}
161 %{?with_greenlet:%{__python} uwsgiconfig.py --plugin plugins/greenlet pld greenlet_py%{pyver}}
162 %endif
163 %if %{with python3}
164 %{__python3} uwsgiconfig.py --plugin plugins/python pld python%{py3ver}
165 %{__python3} uwsgiconfig.py --plugin plugins/gevent pld gevent_py%{py3ver}
166 %{?with_greenlet:%{__python} uwsgiconfig.py --plugin plugins/greenlet pld greenlet_py%{py3ver}}
167 %endif
168
169 %install
170 rm -rf $RPM_BUILD_ROOT
171 install -d $RPM_BUILD_ROOT{%{_bindir},%{_libdir}/%{name}} \
172         $RPM_BUILD_ROOT{%{_sysconfdir}/rc.d/init.d,%{_sysconfdir}/sysconfig} \
173         $RPM_BUILD_ROOT{%{_sysconfdir}/uwsgi/vassals,/var/{run/uwsgi,log}} \
174         $RPM_BUILD_ROOT{%{systemdtmpfilesdir},%{systemdunitdir}}
175
176 touch $RPM_BUILD_ROOT/var/log/%{name}.log
177 install uwsgi $RPM_BUILD_ROOT%{_bindir}
178 install %{SOURCE1} $RPM_BUILD_ROOT%{_sysconfdir}/rc.d/init.d/%{name}
179 install %{SOURCE2} $RPM_BUILD_ROOT%{_sysconfdir}/uwsgi/emperor.ini
180 install %{SOURCE3} $RPM_BUILD_ROOT%{systemdtmpfilesdir}/%{name}.conf
181 install %{SOURCE4} $RPM_BUILD_ROOT%{systemdunitdir}/%{name}.service
182
183 install *_plugin.so $RPM_BUILD_ROOT%{_libdir}/%{name}
184
185 # the symlinks must be absolute – otherwise strange things happen in strace
186 %if %{with python2}
187 ln -s %{_libdir}/%{name}/python%{pyver}_plugin.so $RPM_BUILD_ROOT%{_libdir}/%{name}/python_plugin.so
188 ln -s %{_libdir}/%{name}/gevent_py%{pyver}_plugin.so $RPM_BUILD_ROOT%{_libdir}/%{name}/gevent_plugin.so
189 %{?with_greenlet:ln -s %{_libdir}/%{name}/greenlet_py%{pyver}_plugin.so $RPM_BUILD_ROOT%{_libdir}/%{name}/greenlet_plugin.so}
190 %endif
191 %if %{with python3}
192 ln -s %{_libdir}/%{name}/python%{py3ver}_plugin.so $RPM_BUILD_ROOT%{_libdir}/%{name}/python3_plugin.so
193 ln -s %{_libdir}/%{name}/gevent_py%{py3ver}_plugin.so $RPM_BUILD_ROOT%{_libdir}/%{name}/gevent_py3_plugin.so
194 %{?with_greenlet:ln -s %{_libdir}/%{name}/greenlet_py%{py3ver}_plugin.so $RPM_BUILD_ROOT%{_libdir}/%{name}/greenlet_py3_plugin.so}
195 %endif
196
197 %clean
198 rm -rf $RPM_BUILD_ROOT
199
200 %pre
201 %groupadd -r -g 270 %{name}
202 %useradd -r -u 270 -d /usr/share/empty -s /bin/false -c "uWSGI User" -g %{name} %{name}
203
204 %post
205 /sbin/chkconfig --add %{name}
206 touch /var/log/%{name}.log
207 chown uwsgi:uwsgi /var/log/%{name}.log
208 chmod 644 /var/log/%{name}.log
209 %service %{name} restart
210 %systemd_post %{name}.service
211
212 %preun
213 if [ "$1" = "0" ];then
214         %service %{name} stop
215         /sbin/chkconfig --del %{name}
216 fi
217 %systemd_preun %{name}.service
218
219 %postun
220 if [ "$1" = "0" ]; then
221         %userremove %{name}
222         %groupremove %{name}
223 fi
224 %systemd_reload
225
226 %triggerpostun -- %{name} < 1.9.12-1.1
227 UWSGI_CONFIG_FORMAT="xml"
228 [ -f /etc/sysconfig/uwsgi.rpmsave ] && . /etc/sysconfig/uwsgi.rpmsave || :
229 if [ "$UWSGI_CONFIG_FORMAT" = "xml" ] ; then
230   if [ -f /etc/uwsgi/uwsgi.xml.rpmsave ] ; then
231     sed -e 's/<daemonize>.*<\/daemonize>//' \
232         -e 's/<uwsgi>/<uwsgi>\n<plugins>python,gevent,ping,cache,nagios,rrdtool,carbon,rpc,corerouter,fastrouter,http,ugreen,signal,syslog,rsyslog,logsocket,router_uwsgi,router_redirect,router_basicauth,zergpool,redislog,mongodblog,router_rewrite,router_http,logfile,router_cache,rawrouter<\/plugins>/' \
233         < /etc/uwsgi/uwsgi.xml.rpmsave \
234         > /etc/uwsgi/vassals/uwsgi.xml || :
235   else
236     cat >/etc/uwsgi/vassals/uwsgi.xml << 'EOF'
237 <uwsgi>
238         <plugins>python,gevent,ping,cache,nagios,rrdtool,carbon,rpc,corerouter,fastrouter,http,ugreen,signal,syslog,rsyslog,logsocket,router_uwsgi,router_redirect,router_basicauth,zergpool,redislog,mongodblog,router_rewrite,router_http,logfile,router_cache,rawrouter</plugins>
239         <pidfile>/var/run/uwsgi/uwsgi.pid</pidfile>
240         <uid>uwsgi</uid>
241         <gid>uwsgi</gid>
242         <socket>/var/run/uwsgi/uwsgi.sock</socket>
243 </uwsgi>
244 EOF
245   fi
246 elif [ "$UWSGI_CONFIG_FORMAT" = "ini" ] ; then
247   if [ -f /etc/uwsgi/uwsgi.ini.rpmsave ] ; then
248     mv /etc/uwsgi/vassals/uwsgi.ini{,.rpmorig}
249     sed -e 's/[ \t]*daemonize.*//' \
250         -e 's/^\[uwsgi\]/[uwsgi]\nplugins=python,gevent,ping,cache,nagios,rrdtool,carbon,rpc,corerouter,fastrouter,http,ugreen,signal,syslog,rsyslog,logsocket,router_uwsgi,router_redirect,router_basicauth,zergpool,redislog,mongodblog,router_rewrite,router_http,logfile,router_cache,rawrouter/' \
251         < /etc/uwsgi/uwsgi.ini.rpmsave \
252         > /etc/uwsgi/vassals/uwsgi.ini || :
253   else
254     cat >/etc/uwsgi/vassals/uwsgi.ini << 'EOF'
255 [uwsgi]
256 plugins = python,gevent,ping,cache,nagios,rrdtool,carbon,rpc,corerouter,fastrouter,http,ugreen,signal,syslog,rsyslog,logsocket,router_uwsgi,router_redirect,router_basicauth,zergpool,redislog,mongodblog,router_rewrite,router_http,logfile,router_cache,rawrouter
257 socket = /var/run/uwsgi/uwsgi.sock
258 uid = uwsgi
259 gid = uwsgi
260 pidfile = /var/run/uwsgi/uwsgi.pid
261 EOF
262   fi
263 fi
264
265 if [ -f /var/run/uwsgi/uwsgi.pid ] ; then
266   # for the service restart to work
267   mv /var/run/uwsgi/uwsgi.pid /var/run/uwsgi-emperor.pid || :
268 fi
269
270 %banner -e %{name} << 'EOF'
271 uWSGI instance configuration has been moved to 
272 the %{_sysconfdir}/%{name}/vassals directory and
273 updated to be started via uWSGI emperor with loadable plugins.
274
275 The automatic configuration update might have failed, though.
276
277 You should probably install uwsgi-plugin-python too.
278 EOF
279 %service %{name} restart
280 %systemd_trigger %{name}.service
281
282 %files
283 %defattr(644,root,root,755)
284 %doc README
285 %attr(755,root,root) %{_bindir}/uwsgi
286 %{systemdtmpfilesdir}/%{name}.conf
287 %{systemdunitdir}/%{name}.service
288 %dir %{_sysconfdir}/%{name}
289 %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/uwsgi/emperor.ini
290 %dir %{_sysconfdir}/%{name}/vassals
291 %attr(754,root,root) /etc/rc.d/init.d/%{name}
292 %attr(755,uwsgi,uwsgi) %dir /var/run/uwsgi
293 %attr(644,uwsgi,uwsgi) %ghost /var/log/%{name}.log
294 %dir %{_libdir}/%{name}
295 %{_libdir}/%{name}/cache_plugin.so
296 %{_libdir}/%{name}/carbon_plugin.so
297 %{_libdir}/%{name}/cgi_plugin.so
298 %{_libdir}/%{name}/cheaper_busyness_plugin.so
299 %{_libdir}/%{name}/corerouter_plugin.so
300 %{_libdir}/%{name}/fastrouter_plugin.so
301 %{_libdir}/%{name}/http_plugin.so
302 %{_libdir}/%{name}/logfile_plugin.so
303 %{_libdir}/%{name}/logsocket_plugin.so
304 %{_libdir}/%{name}/mongodblog_plugin.so
305 %{_libdir}/%{name}/nagios_plugin.so
306 %{_libdir}/%{name}/ping_plugin.so
307 %{_libdir}/%{name}/rawrouter_plugin.so
308 %{_libdir}/%{name}/redislog_plugin.so
309 %{_libdir}/%{name}/router_basicauth_plugin.so
310 %{_libdir}/%{name}/router_cache_plugin.so
311 %{_libdir}/%{name}/router_expires_plugin.so
312 %{_libdir}/%{name}/router_hash_plugin.so
313 %{_libdir}/%{name}/router_http_plugin.so
314 %{_libdir}/%{name}/router_memcached_plugin.so
315 %{_libdir}/%{name}/router_metrics_plugin.so
316 %{_libdir}/%{name}/router_redirect_plugin.so
317 %{_libdir}/%{name}/router_redis_plugin.so
318 %{_libdir}/%{name}/router_rewrite_plugin.so
319 %{_libdir}/%{name}/router_static_plugin.so
320 %{_libdir}/%{name}/router_uwsgi_plugin.so
321 %{_libdir}/%{name}/rpc_plugin.so
322 %{_libdir}/%{name}/rrdtool_plugin.so
323 %{_libdir}/%{name}/rsyslog_plugin.so
324 %{_libdir}/%{name}/signal_plugin.so
325 %{_libdir}/%{name}/spooler_plugin.so
326 %{_libdir}/%{name}/sslrouter_plugin.so
327 %{_libdir}/%{name}/stats_pusher_socket_plugin.so
328 %{_libdir}/%{name}/symcall_plugin.so
329 %{_libdir}/%{name}/syslog_plugin.so
330 %{_libdir}/%{name}/systemd_logger_plugin.so
331 %{_libdir}/%{name}/transformation_chunked_plugin.so
332 %{_libdir}/%{name}/transformation_gzip_plugin.so
333 %{_libdir}/%{name}/transformation_offload_plugin.so
334 %{_libdir}/%{name}/transformation_template_plugin.so
335 %{_libdir}/%{name}/transformation_tofile_plugin.so
336 %{_libdir}/%{name}/ugreen_plugin.so
337 %{_libdir}/%{name}/zergpool_plugin.so
338
339 %files plugin-python
340 %defattr(644,root,root,755)
341 %{_libdir}/%{name}/python_plugin.so
342 %{_libdir}/%{name}/python%{pyver}_plugin.so
343 %{_libdir}/%{name}/gevent_py%{pyver}_plugin.so
344 %{_libdir}/%{name}/gevent_plugin.so
345 %if %{with greenlet}
346 %{_libdir}/%{name}/greenlet_py%{pyver}_plugin.so
347 %{_libdir}/%{name}/greenlet_plugin.so
348 %endif
349
350 %files plugin-python3
351 %defattr(644,root,root,755)
352 %{_libdir}/%{name}/python3_plugin.so
353 %{_libdir}/%{name}/python%{py3ver}_plugin.so
354 %{_libdir}/%{name}/gevent_py%{py3ver}_plugin.so
355 %{_libdir}/%{name}/gevent_py3_plugin.so
356 %if %{with greenlet}
357 %{_libdir}/%{name}/greenlet_py3_plugin.so
358 %{_libdir}/%{name}/greenlet_py%{py3ver}_plugin.so
359 %endif
This page took 0.047594 seconds and 3 git commands to generate.