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