xref: /unit/pkg/rpm/unit.spec.in (revision 911:7012b4fd5113)
1# distribution specific definitions
2%define use_systemd (0%{?rhel} >= 7 || 0%{?fedora} >= 19 || 0%{?suse_version} >= 1315)
3%define bdir %{_builddir}/%{name}-%{version}
4%define dotests 0
5
6%if ( 0%{?rhel} == 5 || 0%{?rhel} == 6 )
7Requires: initscripts >= 8.36
8%endif
9
10%if %{use_systemd}
11BuildRequires: systemd
12Requires(post):    systemd
13Requires(preun):   systemd
14Requires(postun):  systemd
15%endif
16
17%if 0%{?rhel}%{?fedora}
18BuildRequires: gcc
19BuildRequires: openssl-devel
20%endif
21
22%if 0%{?rhel}
23%if 0%{?amzn} == 0
24%define dist .el%{?rhel}
25%endif
26%endif
27
28%if 0%{?suse_version} >= 1315
29BuildRequires: libopenssl-devel
30%endif
31
32%define CC_OPT %{optflags} -fPIC
33%define LD_OPT -Wl,-z,relro -Wl,-z,now -pie
34
35%define CONFIGURE_ARGS $(echo "%%CONFIGURE_ARGS%%")
36
37Provides: nginx-unit
38
39Name: unit
40Summary: NGINX Unit
41Version: %%VERSION%%
42Release: %%RELEASE%%%{?dist}.ngx
43License: ASL 2.0
44Vendor: Nginx Software, Inc.
45URL: https://unit.nginx.org/
46Packager: Nginx Software, Inc. <https://www.nginx.com>
47Group: System Environment/Daemons
48
49Source0: unit-%{version}.tar.gz
50Source1: unit.service
51Source2: unit.init
52Source3: unit.sysconf
53Source4: unit.example.config
54Source5: unit.logrotate
55
56BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
57
58%description
59NGINX Unit is a runtime and delivery environment for modern distributed
60applications. It runs the application code in multiple languages
61(PHP, Python, Go, etc.), and tightly couples it with traffic delivery
62in and out of the application. Take this application server and proxy
63directly in the cloud / container environments and fully control your app
64dynamically via an API.
65
66%if 0%{?suse_version}
67%debug_package
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
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%if ! %{use_systemd}
116%{__mkdir} -p %{buildroot}%{_sysconfdir}/sysconfig
117%{__install} -m 644 -p %{SOURCE3} \
118    %{buildroot}%{_sysconfdir}/sysconfig/unitd
119%endif
120%{__mkdir} -p %{buildroot}%{_sysconfdir}/logrotate.d
121%{__install} -m 644 -p %{SOURCE5} \
122    %{buildroot}%{_sysconfdir}/logrotate.d/unit
123%{__mkdir} -p %{buildroot}%{_sysconfdir}/unit
124%{__mkdir} -p %{buildroot}%{_datadir}/doc/unit/examples
125%{__install} -m 644 -p %{SOURCE4} \
126    %{buildroot}%{_datadir}/doc/unit/examples/example.config
127%{__install} -m 644 -p CHANGES \
128    %{buildroot}%{_datadir}/doc/unit/
129%{__install} -m 644 -p NOTICE \
130    %{buildroot}%{_datadir}/doc/unit/COPYRIGHT
131%{__install} -m 644 -p README \
132    %{buildroot}%{_datadir}/doc/unit/
133
134# init scripts
135%if %{use_systemd}
136%{__rm} -rf %{buildroot}%{_initrddir}/
137%{__install} -p -D -m 0644 %{SOURCE1} %{buildroot}%{_unitdir}/unit.service
138%else
139%{__mkdir} -p %{buildroot}%{_initrddir}
140%{__install} -p -D -m 0755 %{SOURCE2} %{buildroot}%{_initrddir}/unit
141%endif
142
143QA_SKIP_BUILD_ROOT=1
144export QA_SKIP_BUILD_ROOT
145
146%check
147%if %{dotests}
148cd %{bdir} && make tests && ./build/tests
149%endif
150
151%clean
152%{__rm} -rf %{buildroot}
153
154%post
155if [ $1 -eq 1 ]; then
156%if %{use_systemd}
157    /usr/bin/systemctl preset unit.service >/dev/null 2>&1 ||:
158%else
159    /sbin/chkconfig --add unit
160%endif
161    cat <<BANNER
162----------------------------------------------------------------------
163
164Thank you for installing NGINX Unit!
165
166Additional modules are available in standalone packages.
167To see the available modules, run "yum list available unit-\*".
168
169Online documentation is available at https://unit.nginx.org/
170
171----------------------------------------------------------------------
172BANNER
173fi
174
175%preun
176if [ $1 -eq 0 ]; then
177%if %{use_systemd}
178    /usr/bin/systemctl --no-reload disable unit.service >/dev/null 2>&1 ||:
179    /usr/bin/systemctl stop unit.service >/dev/null 2>&1 ||:
180%else
181    /sbin/service unit stop >/dev/null 2>&1
182    /sbin/chkconfig --del unit
183%endif
184fi
185
186%postun
187%if %{use_systemd}
188/usr/bin/systemctl daemon-reload >/dev/null 2>&1 ||:
189%endif
190if [ $1 -ge 1 ]; then
191%if %{use_systemd}
192    /usr/bin/systemctl try-restart unit.service >/dev/null 2>&1 ||:
193%else
194    /sbin/service unit condrestart >/dev/null 2>&1 ||:
195%endif
196fi
197
198%files
199%defattr(-,root,root,-)
200%attr(0755,root,root) %{_sbindir}/unitd
201%attr(0755,root,root) %{_sbindir}/unitd-debug
202%dir %{_sysconfdir}/unit
203%if %{use_systemd}
204%{_unitdir}/unit.service
205%dir %attr(0755,root,root) %ghost %{_localstatedir}/run/unit
206%else
207%config(noreplace) %{_sysconfdir}/sysconfig/unitd
208%dir %attr(0755,root,root) %{_localstatedir}/run/unit
209%{_initrddir}/unit
210%endif
211%dir %{_datadir}/doc/unit
212%{_datadir}/doc/unit/*
213%dir %{_libdir}/unit/modules
214%dir %{_libdir}/unit/debug-modules
215%dir %{_sharedstatedir}/unit
216%dir %attr(0700,root,root) %{_localstatedir}/log/unit
217%config(noreplace) %{_sysconfdir}/logrotate.d/%{name}
218
219%files devel
220%{_libdir}/libunit.a
221%{_libdir}/libunit-debug.a
222%{_includedir}/nxt_*.h
223
224%changelog
225