xref: /unit/pkg/rpm/unit.spec.in (revision 372:616449084bee)
1# distribution specific definitions
2%define use_systemd (0%{?rhel} && 0%{?rhel} >= 7) || (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 0%{?rhel} == 7
11Requires: systemd
12BuildRequires: systemd-units
13%define dist .el7
14%endif
15
16%if 0%{?suse_version} == 1315
17BuildRequires: systemd
18Requires: systemd
19%endif
20
21%define CONFIGURE_ARGS $(echo "%%CONFIGURE_ARGS%%")
22
23Provides: nginx-unit
24
25Name: unit
26Summary: NGINX Unit
27Version: %%VERSION%%
28Release: %%RELEASE%%%{?dist}.ngx
29License: ASL 2.0
30Vendor: Nginx Software, Inc.
31URL: https://unit.nginx.org/
32Packager: Nginx Software, Inc. <https://www.nginx.com>
33Group: System Environment/Daemons
34
35Source0: unit-%{version}.tar.gz
36Source1: unit.service
37Source2: unit.init
38Source3: unit.sysconf
39Source4: unit.saveconfig.sh
40Source5: unit.loadconfig.sh
41Source6: unit.example.config
42
43BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
44
45%description
46NGINX Unit is a runtime and delivery environment for modern distributed
47applications. It runs the application code in multiple languages
48(PHP, Python, Go, etc.), and tightly couples it with traffic delivery
49in and out of the application. Take this application server and proxy
50directly in the cloud / container environments and fully control your app
51dynamically via an API.
52
53%if 0%{?suse_version}
54%debug_package
55%endif
56
57%prep
58%setup -q
59
60%build
61./configure \
62	%{CONFIGURE_ARGS} \
63	--modules=%{_libdir}/unit/debug-modules \
64	--debug
65%{__make} %{?_smp_mflags}
66%{__mv} build build-debug
67./configure \
68	%{CONFIGURE_ARGS} \
69	--modules=%{_libdir}/unit/modules
70%{__make} %{?_smp_mflags}
71
72%install
73%{__rm} -rf %{buildroot}
74DESTDIR=%{buildroot} make unitd-install
75%{__install} -m755 %{bdir}/build-debug/unitd \
76    %{buildroot}%{_sbindir}/unitd-debug
77%{__mkdir} -p %{buildroot}%{_libdir}/unit/modules
78%{__mkdir} -p %{buildroot}%{_libdir}/unit/debug-modules
79%{__mkdir} -p %{buildroot}%{_sharedstatedir}/unit
80%{__mkdir} -p %{buildroot}%{_sysconfdir}/sysconfig
81%{__install} -m 644 -p %{SOURCE3} \
82    %{buildroot}%{_sysconfdir}/sysconfig/unit
83%{__mkdir} -p %{buildroot}%{_sysconfdir}/unit
84%{__mkdir} -p %{buildroot}%{_datadir}/doc/unit/examples
85%{__install} -m 644 -p %{SOURCE6} \
86    %{buildroot}%{_datadir}/doc/unit/examples/example.config
87%{__install} -m 644 -p CHANGES \
88    %{buildroot}%{_datadir}/doc/unit/
89%{__install} -m 644 -p NOTICE \
90    %{buildroot}%{_datadir}/doc/unit/COPYRIGHT
91%{__install} -m 644 -p README \
92    %{buildroot}%{_datadir}/doc/unit/
93
94# init scripts
95%if %{use_systemd}
96%{__rm} -rf %{buildroot}%{_initrddir}/
97%{__install} -p -D -m 0644 %{SOURCE1} %{buildroot}%{_unitdir}/unit.service
98%{__mkdir} -p %{buildroot}%{_libexecdir}/initscripts/legacy-actions/unit
99%{__install} -m755 %SOURCE4 \
100    %{buildroot}%{_libexecdir}/initscripts/legacy-actions/unit/saveconfig
101%{__install} -m755 %SOURCE5 \
102    %{buildroot}%{_libexecdir}/initscripts/legacy-actions/unit/loadconfig
103%else
104%{__mkdir} -p %{buildroot}%{_initrddir}
105%{__install} -p -D -m 0755 %{SOURCE2} %{buildroot}%{_initrddir}/unit
106%endif
107
108QA_SKIP_BUILD_ROOT=1
109export QA_SKIP_BUILD_ROOT
110
111%check
112%if %{dotests}
113cd %{bdir} && make tests && ./build/tests
114%endif
115
116%clean
117%{__rm} -rf %{buildroot}
118
119%post
120if [ $1 -eq 1 ]; then
121%if %{use_systemd}
122    /usr/bin/systemctl preset unit.service >/dev/null 2>&1 ||:
123%else
124    /sbin/chkconfig --add unit
125%endif
126    cat <<BANNER
127----------------------------------------------------------------------
128
129Thank you for installing NGINX Unit!
130
131Additional modules are available in standalone packages.
132To see the available modules, run "yum list available unit-\*".
133
134Online documentation is available at https://unit.nginx.org/
135
136----------------------------------------------------------------------
137BANNER
138fi
139
140%preun
141if [ $1 -eq 0 ]; then
142%if %{use_systemd}
143    /usr/bin/systemctl --no-reload disable unit.service >/dev/null 2>&1 ||:
144    /usr/bin/systemctl stop unit.service >/dev/null 2>&1 ||:
145%else
146    /sbin/service unit stop >/dev/null 2>&1
147    /sbin/chkconfig --del unit
148%endif
149fi
150
151%postun
152%if %{use_systemd}
153/usr/bin/systemctl daemon-reload >/dev/null 2>&1 ||:
154%endif
155if [ $1 -ge 1 ]; then
156%if %{use_systemd}
157    /usr/bin/systemctl try-restart unit.service >/dev/null 2>&1 ||:
158%else
159    /sbin/service unit condrestart >/dev/null 2>&1 ||:
160%endif
161fi
162
163%files
164%defattr(-,root,root,-)
165%attr(0755,root,root) %{_sbindir}/unitd
166%attr(0755,root,root) %{_sbindir}/unitd-debug
167%config(noreplace) %{_sysconfdir}/sysconfig/unit
168%dir %{_sysconfdir}/unit
169%if %{use_systemd}
170%{_unitdir}/unit.service
171%dir %{_libexecdir}/initscripts/legacy-actions/unit
172%{_libexecdir}/initscripts/legacy-actions/unit/*
173%else
174%{_initrddir}/unit
175%endif
176%dir %{_datadir}/doc/unit
177%{_datadir}/doc/unit/*
178%dir %{_libdir}/unit/modules
179%dir %{_libdir}/unit/debug-modules
180%dir %{_sharedstatedir}/unit
181
182%changelog
183