xref: /unit/pkg/rpm/unit.spec.in (revision 2136:5bcedb046826)
1# distribution specific definitions
2%define bdir %{_builddir}/%{name}-%{version}
3%define dotests 0
4
5%if 0%{?rhel}%{?fedora}
6BuildRequires: gcc
7%if 0%{?amzn2}
8BuildRequires: openssl11-devel
9%else
10BuildRequires: openssl-devel
11%endif
12%endif
13
14%if 0%{?rhel}
15%if 0%{?amzn} == 0
16%define dist .el%{?rhel}
17%endif
18%endif
19
20%if 0%{?suse_version} >= 1315
21BuildRequires: libopenssl-devel
22%endif
23
24%define CC_OPT %{optflags} -fPIC
25%define LD_OPT -Wl,-z,relro -Wl,-z,now -pie
26
27%define CONFIGURE_ARGS $(echo "%%CONFIGURE_ARGS%%")
28
29Provides: nginx-unit
30
31Name: unit
32Summary: NGINX Unit
33Version: %%VERSION%%
34Release: %%RELEASE%%%{?dist}.ngx
35License: ASL 2.0
36Vendor: %%PACKAGE_VENDOR%%
37URL: https://unit.nginx.org/
38Group: System Environment/Daemons
39
40Source0: unit-%{version}.tar.gz
41Source1: unit.service
42Source2: unit-debug.service
43Source3: unit.example.config
44Source4: unit.logrotate
45
46BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
47BuildRequires: systemd
48Requires(post):    systemd
49Requires(preun):   systemd
50Requires(postun):  systemd
51
52BuildRequires: pcre2-devel
53
54%description
55NGINX Unit is a runtime and delivery environment for modern distributed
56applications. It runs the application code in multiple languages
57(PHP, Python, Go, etc.), and tightly couples it with traffic delivery
58in and out of the application. Take this application server and proxy
59directly in the cloud / container environments and fully control your app
60dynamically via an API.
61
62%if 0%{?suse_version}
63%debug_package
64%endif
65
66%if (0%{?fedora}) || (0%{?rhel} >= 8)
67%define _debugsource_template %{nil}
68%endif
69
70%package devel
71Summary: NGINX Unit (development files)
72Version: %%VERSION%%
73Release: %%RELEASE%%%{?dist}.ngx
74Group: Development/Libraries
75Requires: unit == %%VERSION%%-%%RELEASE%%%{?dist}.ngx
76%description devel
77Library and include files required for NGINX Unit modules development.
78
79%prep
80%setup -q
81
82%build
83./configure \
84	%{CONFIGURE_ARGS} \
85	--modules=%{_libdir}/unit/debug-modules \
86	--libdir=%{_libdir} \
87	--cc-opt="%{CC_OPT}" \
88	--ld-opt="%{LD_OPT}" \
89	--debug
90%{__make} %{?_smp_mflags}
91%{__make} %{?_smp_mflags} build/libunit.a
92%{__mv} build build-debug
93./configure \
94	%{CONFIGURE_ARGS} \
95	--modules=%{_libdir}/unit/modules \
96	--libdir=%{_libdir} \
97	--cc-opt="%{CC_OPT}" \
98	--ld-opt="%{LD_OPT}"
99%{__make} %{?_smp_mflags}
100%{__mv} build build-nodebug
101
102%install
103%{__rm} -rf %{buildroot}
104%{__ln_s} build-nodebug build
105DESTDIR=%{buildroot} make unitd-install libunit-install manpage-install
106%{__install} -m755 %{bdir}/build-debug/unitd \
107    %{buildroot}%{_sbindir}/unitd-debug
108%{__install} -m644 %{bdir}/build-debug/libunit.a \
109    %{buildroot}%{_libdir}/libunit-debug.a
110%{__mkdir} -p %{buildroot}%{_libdir}/unit/modules
111%{__mkdir} -p %{buildroot}%{_libdir}/unit/debug-modules
112%{__mkdir} -p %{buildroot}%{_sharedstatedir}/unit
113%{__mkdir} -p %{buildroot}%{_localstatedir}/log/unit
114%{__mkdir} -p %{buildroot}%{_localstatedir}/run/unit
115%{__mkdir} -p %{buildroot}%{_sysconfdir}/logrotate.d
116%{__install} -m 644 -p %{SOURCE4} \
117    %{buildroot}%{_sysconfdir}/logrotate.d/unit
118%{__mkdir} -p %{buildroot}%{_datadir}/doc/unit/examples
119%{__install} -m 644 -p %{SOURCE3} \
120    %{buildroot}%{_datadir}/doc/unit/examples/example.config
121%{__install} -m 644 -p CHANGES \
122    %{buildroot}%{_datadir}/doc/unit/
123%{__install} -m 644 -p NOTICE \
124    %{buildroot}%{_datadir}/doc/unit/COPYRIGHT
125%{__install} -m 644 -p README.md \
126    %{buildroot}%{_datadir}/doc/unit/
127%{__install} -m 644 -p CONTRIBUTING.md \
128    %{buildroot}%{_datadir}/doc/unit/
129
130%{__rm} -rf %{buildroot}%{_initrddir}/
131%{__install} -p -D -m 0644 %{SOURCE1} %{buildroot}%{_unitdir}/unit.service
132%{__install} -p -D -m 0644 %{SOURCE2} %{buildroot}%{_unitdir}/unit-debug.service
133
134QA_SKIP_BUILD_ROOT=1
135export QA_SKIP_BUILD_ROOT
136
137%check
138%if %{dotests}
139cd %{bdir} && make tests && ./build/tests
140%endif
141%{__rm} -rf %{buildroot}/usr/src
142cd %{bdir}
143grep -v 'usr/src' debugfiles.list > debugfiles.list.new && mv debugfiles.list.new debugfiles.list
144cat /dev/null > debugsources.list
145%if 0%{?suse_version} >= 1500
146cat /dev/null > debugsourcefiles.list
147%endif
148
149%clean
150%{__rm} -rf %{buildroot}
151
152%post
153getent group unit >/dev/null || groupadd -r unit
154getent passwd unit >/dev/null || \
155    useradd -r -g unit -s /sbin/nologin \
156    -d /nonexistent -c "unit user" unit
157if [ $1 -eq 1 ]; then
158    /usr/bin/systemctl preset unit.service >/dev/null 2>&1 ||:
159    /usr/bin/systemctl preset unit-debug.service >/dev/null 2>&1 ||:
160    cat <<BANNER
161----------------------------------------------------------------------
162
163Thank you for installing NGINX Unit!
164
165Additional modules are available in standalone packages.
166To see the available modules, run "yum list available unit-\*".
167
168Online documentation is available at https://unit.nginx.org/
169
170----------------------------------------------------------------------
171BANNER
172fi
173
174%preun
175if [ $1 -eq 0 ]; then
176    /usr/bin/systemctl --no-reload disable unit.service >/dev/null 2>&1 ||:
177    /usr/bin/systemctl stop unit.service >/dev/null 2>&1 ||:
178fi
179
180%postun
181/usr/bin/systemctl daemon-reload >/dev/null 2>&1 ||:
182if [ $1 -ge 1 ]; then
183    /usr/bin/systemctl try-restart unit.service >/dev/null 2>&1 ||:
184fi
185
186%triggerpostun -- unit < 1.22.0
187cat <<BANNER
188----------------------------------------------------------------------
189
190WARNING:
191
192Since version 1.22.0, Unit's non-privileged processes run as unit:unit by
193default.  Review your system permissions and Unit configuration so apps and
194routes that relied on these processes running as nobody:nogroup stay working.
195
196More info: https://unit.nginx.org/installation/#official-packages
197
198----------------------------------------------------------------------
199BANNER
200
201%files
202%defattr(-,root,root,-)
203%attr(0755,root,root) %{_sbindir}/unitd
204%attr(0755,root,root) %{_sbindir}/unitd-debug
205%{_unitdir}/unit.service
206%{_unitdir}/unit-debug.service
207%dir %attr(0755,root,root) %ghost %{_localstatedir}/run/unit
208%dir %{_datadir}/doc/unit
209%{_datadir}/doc/unit/*
210%dir %{_libdir}/unit/modules
211%dir %{_libdir}/unit/debug-modules
212%dir %{_sharedstatedir}/unit
213%dir %attr(0755,root,root) %{_localstatedir}/log/unit
214%config(noreplace) %{_sysconfdir}/logrotate.d/%{name}
215%{_mandir}/man8/unitd.8*
216
217%files devel
218%{_libdir}/libunit.a
219%{_libdir}/libunit-debug.a
220%{_includedir}/nxt_*.h
221
222%changelog
223