xref: /unit/pkg/rpm/unit.spec.in (revision 913)
1372Sdefan@nginx.com# distribution specific definitions
2911Sremi@remirepo.net%define use_systemd (0%{?rhel} >= 7 || 0%{?fedora} >= 19 || 0%{?suse_version} >= 1315)
3372Sdefan@nginx.com%define bdir %{_builddir}/%{name}-%{version}
4372Sdefan@nginx.com%define dotests 0
5372Sdefan@nginx.com
6372Sdefan@nginx.com%if ( 0%{?rhel} == 5 || 0%{?rhel} == 6 )
7372Sdefan@nginx.comRequires: initscripts >= 8.36
8911Sremi@remirepo.net%endif
9911Sremi@remirepo.net
10911Sremi@remirepo.net%if %{use_systemd}
11911Sremi@remirepo.netBuildRequires: systemd
12911Sremi@remirepo.netRequires(post):    systemd
13911Sremi@remirepo.netRequires(preun):   systemd
14911Sremi@remirepo.netRequires(postun):  systemd
15911Sremi@remirepo.net%endif
16911Sremi@remirepo.net
17911Sremi@remirepo.net%if 0%{?rhel}%{?fedora}
18911Sremi@remirepo.netBuildRequires: gcc
19778Sdefan@nginx.comBuildRequires: openssl-devel
20372Sdefan@nginx.com%endif
21372Sdefan@nginx.com
22911Sremi@remirepo.net%if 0%{?rhel}
23490Sdefan@nginx.com%if 0%{?amzn} == 0
24911Sremi@remirepo.net%define dist .el%{?rhel}
25372Sdefan@nginx.com%endif
26490Sdefan@nginx.com%endif
27372Sdefan@nginx.com
28778Sdefan@nginx.com%if 0%{?suse_version} >= 1315
29778Sdefan@nginx.comBuildRequires: libopenssl-devel
30372Sdefan@nginx.com%endif
31372Sdefan@nginx.com
32443Sdefan@nginx.com%define CC_OPT %{optflags} -fPIC
33443Sdefan@nginx.com%define LD_OPT -Wl,-z,relro -Wl,-z,now -pie
34443Sdefan@nginx.com
35372Sdefan@nginx.com%define CONFIGURE_ARGS $(echo "%%CONFIGURE_ARGS%%")
36372Sdefan@nginx.com
37372Sdefan@nginx.comProvides: nginx-unit
38372Sdefan@nginx.com
39372Sdefan@nginx.comName: unit
40372Sdefan@nginx.comSummary: NGINX Unit
41372Sdefan@nginx.comVersion: %%VERSION%%
42372Sdefan@nginx.comRelease: %%RELEASE%%%{?dist}.ngx
43372Sdefan@nginx.comLicense: ASL 2.0
44372Sdefan@nginx.comVendor: Nginx Software, Inc.
45372Sdefan@nginx.comURL: https://unit.nginx.org/
46372Sdefan@nginx.comPackager: Nginx Software, Inc. <https://www.nginx.com>
47372Sdefan@nginx.comGroup: System Environment/Daemons
48372Sdefan@nginx.com
49372Sdefan@nginx.comSource0: unit-%{version}.tar.gz
50372Sdefan@nginx.comSource1: unit.service
51372Sdefan@nginx.comSource2: unit.init
52372Sdefan@nginx.comSource3: unit.sysconf
53786Sdefan@nginx.comSource4: unit.example.config
54911Sremi@remirepo.netSource5: unit.logrotate
55372Sdefan@nginx.com
56372Sdefan@nginx.comBuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
57372Sdefan@nginx.com
58372Sdefan@nginx.com%description
59372Sdefan@nginx.comNGINX Unit is a runtime and delivery environment for modern distributed
60372Sdefan@nginx.comapplications. It runs the application code in multiple languages
61372Sdefan@nginx.com(PHP, Python, Go, etc.), and tightly couples it with traffic delivery
62372Sdefan@nginx.comin and out of the application. Take this application server and proxy
63372Sdefan@nginx.comdirectly in the cloud / container environments and fully control your app
64372Sdefan@nginx.comdynamically via an API.
65372Sdefan@nginx.com
66372Sdefan@nginx.com%if 0%{?suse_version}
67372Sdefan@nginx.com%debug_package
68372Sdefan@nginx.com%endif
69372Sdefan@nginx.com
70*913Sdefan@nginx.com%if 0%{?fedora}
71*913Sdefan@nginx.com%define _debugsource_template %{nil}
72*913Sdefan@nginx.com%endif
73*913Sdefan@nginx.com
74815Sdefan@nginx.com%package devel
75815Sdefan@nginx.comSummary: NGINX Unit (development files)
76815Sdefan@nginx.comVersion: %%VERSION%%
77815Sdefan@nginx.comRelease: %%RELEASE%%%{?dist}.ngx
78815Sdefan@nginx.comGroup: Development/Libraries
79859Sdefan@nginx.comRequires: unit == %%VERSION%%-%%RELEASE%%%{?dist}.ngx
80815Sdefan@nginx.com%description devel
81815Sdefan@nginx.comLibrary and include files required for NGINX Unit modules development.
82815Sdefan@nginx.com
83372Sdefan@nginx.com%prep
84372Sdefan@nginx.com%setup -q
85372Sdefan@nginx.com
86372Sdefan@nginx.com%build
87372Sdefan@nginx.com./configure \
88372Sdefan@nginx.com	%{CONFIGURE_ARGS} \
89372Sdefan@nginx.com	--modules=%{_libdir}/unit/debug-modules \
90815Sdefan@nginx.com	--libdir=%{_libdir} \
91443Sdefan@nginx.com	--cc-opt="%{CC_OPT}" \
92443Sdefan@nginx.com	--ld-opt="%{LD_OPT}" \
93372Sdefan@nginx.com	--debug
94372Sdefan@nginx.com%{__make} %{?_smp_mflags}
95815Sdefan@nginx.com%{__make} %{?_smp_mflags} build/libunit.a
96372Sdefan@nginx.com%{__mv} build build-debug
97372Sdefan@nginx.com./configure \
98372Sdefan@nginx.com	%{CONFIGURE_ARGS} \
99443Sdefan@nginx.com	--modules=%{_libdir}/unit/modules \
100815Sdefan@nginx.com	--libdir=%{_libdir} \
101443Sdefan@nginx.com	--cc-opt="%{CC_OPT}" \
102443Sdefan@nginx.com	--ld-opt="%{LD_OPT}"
103372Sdefan@nginx.com%{__make} %{?_smp_mflags}
104500Sdefan@nginx.com%{__mv} build build-nodebug
105372Sdefan@nginx.com
106372Sdefan@nginx.com%install
107372Sdefan@nginx.com%{__rm} -rf %{buildroot}
108500Sdefan@nginx.com%{__ln_s} build-nodebug build
109815Sdefan@nginx.comDESTDIR=%{buildroot} make unitd-install libunit-install
110372Sdefan@nginx.com%{__install} -m755 %{bdir}/build-debug/unitd \
111372Sdefan@nginx.com    %{buildroot}%{_sbindir}/unitd-debug
112815Sdefan@nginx.com%{__install} -m644 %{bdir}/build-debug/libunit.a \
113815Sdefan@nginx.com    %{buildroot}%{_libdir}/libunit-debug.a
114372Sdefan@nginx.com%{__mkdir} -p %{buildroot}%{_libdir}/unit/modules
115372Sdefan@nginx.com%{__mkdir} -p %{buildroot}%{_libdir}/unit/debug-modules
116372Sdefan@nginx.com%{__mkdir} -p %{buildroot}%{_sharedstatedir}/unit
117911Sremi@remirepo.net%{__mkdir} -p %{buildroot}%{_localstatedir}/log/unit
118911Sremi@remirepo.net%{__mkdir} -p %{buildroot}%{_localstatedir}/run/unit
119911Sremi@remirepo.net%if ! %{use_systemd}
120372Sdefan@nginx.com%{__mkdir} -p %{buildroot}%{_sysconfdir}/sysconfig
121372Sdefan@nginx.com%{__install} -m 644 -p %{SOURCE3} \
122911Sremi@remirepo.net    %{buildroot}%{_sysconfdir}/sysconfig/unitd
123911Sremi@remirepo.net%endif
124911Sremi@remirepo.net%{__mkdir} -p %{buildroot}%{_sysconfdir}/logrotate.d
125911Sremi@remirepo.net%{__install} -m 644 -p %{SOURCE5} \
126911Sremi@remirepo.net    %{buildroot}%{_sysconfdir}/logrotate.d/unit
127372Sdefan@nginx.com%{__mkdir} -p %{buildroot}%{_sysconfdir}/unit
128372Sdefan@nginx.com%{__mkdir} -p %{buildroot}%{_datadir}/doc/unit/examples
129786Sdefan@nginx.com%{__install} -m 644 -p %{SOURCE4} \
130372Sdefan@nginx.com    %{buildroot}%{_datadir}/doc/unit/examples/example.config
131372Sdefan@nginx.com%{__install} -m 644 -p CHANGES \
132372Sdefan@nginx.com    %{buildroot}%{_datadir}/doc/unit/
133372Sdefan@nginx.com%{__install} -m 644 -p NOTICE \
134372Sdefan@nginx.com    %{buildroot}%{_datadir}/doc/unit/COPYRIGHT
135372Sdefan@nginx.com%{__install} -m 644 -p README \
136372Sdefan@nginx.com    %{buildroot}%{_datadir}/doc/unit/
137372Sdefan@nginx.com
138372Sdefan@nginx.com# init scripts
139372Sdefan@nginx.com%if %{use_systemd}
140372Sdefan@nginx.com%{__rm} -rf %{buildroot}%{_initrddir}/
141372Sdefan@nginx.com%{__install} -p -D -m 0644 %{SOURCE1} %{buildroot}%{_unitdir}/unit.service
142372Sdefan@nginx.com%else
143372Sdefan@nginx.com%{__mkdir} -p %{buildroot}%{_initrddir}
144372Sdefan@nginx.com%{__install} -p -D -m 0755 %{SOURCE2} %{buildroot}%{_initrddir}/unit
145372Sdefan@nginx.com%endif
146372Sdefan@nginx.com
147372Sdefan@nginx.comQA_SKIP_BUILD_ROOT=1
148372Sdefan@nginx.comexport QA_SKIP_BUILD_ROOT
149372Sdefan@nginx.com
150372Sdefan@nginx.com%check
151372Sdefan@nginx.com%if %{dotests}
152372Sdefan@nginx.comcd %{bdir} && make tests && ./build/tests
153372Sdefan@nginx.com%endif
154*913Sdefan@nginx.com%{__rm} -rf %{buildroot}/usr/src
155*913Sdefan@nginx.comcd %{bdir}
156*913Sdefan@nginx.comgrep -v 'usr/src' debugfiles.list > debugfiles.list.new && mv debugfiles.list.new debugfiles.list
157*913Sdefan@nginx.comcat /dev/null > debugsources.list
158*913Sdefan@nginx.com%if 0%{?suse_version} >= 1500
159*913Sdefan@nginx.comcat /dev/null > debugsourcefiles.list
160*913Sdefan@nginx.com%endif
161372Sdefan@nginx.com
162372Sdefan@nginx.com%clean
163372Sdefan@nginx.com%{__rm} -rf %{buildroot}
164372Sdefan@nginx.com
165372Sdefan@nginx.com%post
166372Sdefan@nginx.comif [ $1 -eq 1 ]; then
167372Sdefan@nginx.com%if %{use_systemd}
168372Sdefan@nginx.com    /usr/bin/systemctl preset unit.service >/dev/null 2>&1 ||:
169372Sdefan@nginx.com%else
170372Sdefan@nginx.com    /sbin/chkconfig --add unit
171372Sdefan@nginx.com%endif
172372Sdefan@nginx.com    cat <<BANNER
173372Sdefan@nginx.com----------------------------------------------------------------------
174372Sdefan@nginx.com
175372Sdefan@nginx.comThank you for installing NGINX Unit!
176372Sdefan@nginx.com
177372Sdefan@nginx.comAdditional modules are available in standalone packages.
178372Sdefan@nginx.comTo see the available modules, run "yum list available unit-\*".
179372Sdefan@nginx.com
180372Sdefan@nginx.comOnline documentation is available at https://unit.nginx.org/
181372Sdefan@nginx.com
182372Sdefan@nginx.com----------------------------------------------------------------------
183372Sdefan@nginx.comBANNER
184372Sdefan@nginx.comfi
185372Sdefan@nginx.com
186372Sdefan@nginx.com%preun
187372Sdefan@nginx.comif [ $1 -eq 0 ]; then
188372Sdefan@nginx.com%if %{use_systemd}
189372Sdefan@nginx.com    /usr/bin/systemctl --no-reload disable unit.service >/dev/null 2>&1 ||:
190372Sdefan@nginx.com    /usr/bin/systemctl stop unit.service >/dev/null 2>&1 ||:
191372Sdefan@nginx.com%else
192372Sdefan@nginx.com    /sbin/service unit stop >/dev/null 2>&1
193372Sdefan@nginx.com    /sbin/chkconfig --del unit
194372Sdefan@nginx.com%endif
195372Sdefan@nginx.comfi
196372Sdefan@nginx.com
197372Sdefan@nginx.com%postun
198372Sdefan@nginx.com%if %{use_systemd}
199372Sdefan@nginx.com/usr/bin/systemctl daemon-reload >/dev/null 2>&1 ||:
200372Sdefan@nginx.com%endif
201372Sdefan@nginx.comif [ $1 -ge 1 ]; then
202372Sdefan@nginx.com%if %{use_systemd}
203372Sdefan@nginx.com    /usr/bin/systemctl try-restart unit.service >/dev/null 2>&1 ||:
204372Sdefan@nginx.com%else
205372Sdefan@nginx.com    /sbin/service unit condrestart >/dev/null 2>&1 ||:
206372Sdefan@nginx.com%endif
207372Sdefan@nginx.comfi
208372Sdefan@nginx.com
209372Sdefan@nginx.com%files
210372Sdefan@nginx.com%defattr(-,root,root,-)
211372Sdefan@nginx.com%attr(0755,root,root) %{_sbindir}/unitd
212372Sdefan@nginx.com%attr(0755,root,root) %{_sbindir}/unitd-debug
213372Sdefan@nginx.com%dir %{_sysconfdir}/unit
214372Sdefan@nginx.com%if %{use_systemd}
215372Sdefan@nginx.com%{_unitdir}/unit.service
216911Sremi@remirepo.net%dir %attr(0755,root,root) %ghost %{_localstatedir}/run/unit
217372Sdefan@nginx.com%else
218911Sremi@remirepo.net%config(noreplace) %{_sysconfdir}/sysconfig/unitd
219911Sremi@remirepo.net%dir %attr(0755,root,root) %{_localstatedir}/run/unit
220372Sdefan@nginx.com%{_initrddir}/unit
221372Sdefan@nginx.com%endif
222372Sdefan@nginx.com%dir %{_datadir}/doc/unit
223372Sdefan@nginx.com%{_datadir}/doc/unit/*
224372Sdefan@nginx.com%dir %{_libdir}/unit/modules
225372Sdefan@nginx.com%dir %{_libdir}/unit/debug-modules
226372Sdefan@nginx.com%dir %{_sharedstatedir}/unit
227911Sremi@remirepo.net%dir %attr(0700,root,root) %{_localstatedir}/log/unit
228911Sremi@remirepo.net%config(noreplace) %{_sysconfdir}/logrotate.d/%{name}
229372Sdefan@nginx.com
230815Sdefan@nginx.com%files devel
231815Sdefan@nginx.com%{_libdir}/libunit.a
232815Sdefan@nginx.com%{_libdir}/libunit-debug.a
233815Sdefan@nginx.com%{_includedir}/nxt_*.h
234815Sdefan@nginx.com
235372Sdefan@nginx.com%changelog
236