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