xref: /unit/pkg/rpm/unit.spec.in (revision 815)
1372Sdefan@nginx.com# distribution specific definitions
2562Sdefan@nginx.com%define use_systemd (0%{?rhel} && 0%{?rhel} >= 7) || (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
8778Sdefan@nginx.comBuildRequires: openssl-devel
9372Sdefan@nginx.com%endif
10372Sdefan@nginx.com
11372Sdefan@nginx.com%if 0%{?rhel} == 7
12372Sdefan@nginx.comRequires: systemd
13372Sdefan@nginx.comBuildRequires: systemd-units
14778Sdefan@nginx.comBuildRequires: openssl-devel
15490Sdefan@nginx.com%if 0%{?amzn} == 0
16372Sdefan@nginx.com%define dist .el7
17372Sdefan@nginx.com%endif
18490Sdefan@nginx.com%endif
19372Sdefan@nginx.com
20778Sdefan@nginx.com%if 0%{?suse_version} >= 1315
21372Sdefan@nginx.comBuildRequires: systemd
22372Sdefan@nginx.comRequires: systemd
23778Sdefan@nginx.comBuildRequires: libopenssl-devel
24372Sdefan@nginx.com%endif
25372Sdefan@nginx.com
26443Sdefan@nginx.com%define CC_OPT %{optflags} -fPIC
27443Sdefan@nginx.com%define LD_OPT -Wl,-z,relro -Wl,-z,now -pie
28443Sdefan@nginx.com
29372Sdefan@nginx.com%define CONFIGURE_ARGS $(echo "%%CONFIGURE_ARGS%%")
30372Sdefan@nginx.com
31372Sdefan@nginx.comProvides: nginx-unit
32372Sdefan@nginx.com
33372Sdefan@nginx.comName: unit
34372Sdefan@nginx.comSummary: NGINX Unit
35372Sdefan@nginx.comVersion: %%VERSION%%
36372Sdefan@nginx.comRelease: %%RELEASE%%%{?dist}.ngx
37372Sdefan@nginx.comLicense: ASL 2.0
38372Sdefan@nginx.comVendor: Nginx Software, Inc.
39372Sdefan@nginx.comURL: https://unit.nginx.org/
40372Sdefan@nginx.comPackager: Nginx Software, Inc. <https://www.nginx.com>
41372Sdefan@nginx.comGroup: System Environment/Daemons
42372Sdefan@nginx.com
43372Sdefan@nginx.comSource0: unit-%{version}.tar.gz
44372Sdefan@nginx.comSource1: unit.service
45372Sdefan@nginx.comSource2: unit.init
46372Sdefan@nginx.comSource3: unit.sysconf
47786Sdefan@nginx.comSource4: unit.example.config
48372Sdefan@nginx.com
49372Sdefan@nginx.comBuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
50372Sdefan@nginx.com
51372Sdefan@nginx.com%description
52372Sdefan@nginx.comNGINX Unit is a runtime and delivery environment for modern distributed
53372Sdefan@nginx.comapplications. It runs the application code in multiple languages
54372Sdefan@nginx.com(PHP, Python, Go, etc.), and tightly couples it with traffic delivery
55372Sdefan@nginx.comin and out of the application. Take this application server and proxy
56372Sdefan@nginx.comdirectly in the cloud / container environments and fully control your app
57372Sdefan@nginx.comdynamically via an API.
58372Sdefan@nginx.com
59372Sdefan@nginx.com%if 0%{?suse_version}
60372Sdefan@nginx.com%debug_package
61372Sdefan@nginx.com%endif
62372Sdefan@nginx.com
63*815Sdefan@nginx.com%package devel
64*815Sdefan@nginx.comSummary: NGINX Unit (development files)
65*815Sdefan@nginx.comVersion: %%VERSION%%
66*815Sdefan@nginx.comRelease: %%RELEASE%%%{?dist}.ngx
67*815Sdefan@nginx.comGroup: Development/Libraries
68*815Sdefan@nginx.com%description devel
69*815Sdefan@nginx.comLibrary and include files required for NGINX Unit modules development.
70*815Sdefan@nginx.com
71372Sdefan@nginx.com%prep
72372Sdefan@nginx.com%setup -q
73372Sdefan@nginx.com
74372Sdefan@nginx.com%build
75372Sdefan@nginx.com./configure \
76372Sdefan@nginx.com	%{CONFIGURE_ARGS} \
77372Sdefan@nginx.com	--modules=%{_libdir}/unit/debug-modules \
78*815Sdefan@nginx.com	--libdir=%{_libdir} \
79443Sdefan@nginx.com	--cc-opt="%{CC_OPT}" \
80443Sdefan@nginx.com	--ld-opt="%{LD_OPT}" \
81372Sdefan@nginx.com	--debug
82372Sdefan@nginx.com%{__make} %{?_smp_mflags}
83*815Sdefan@nginx.com%{__make} %{?_smp_mflags} build/libunit.a
84372Sdefan@nginx.com%{__mv} build build-debug
85372Sdefan@nginx.com./configure \
86372Sdefan@nginx.com	%{CONFIGURE_ARGS} \
87443Sdefan@nginx.com	--modules=%{_libdir}/unit/modules \
88*815Sdefan@nginx.com	--libdir=%{_libdir} \
89443Sdefan@nginx.com	--cc-opt="%{CC_OPT}" \
90443Sdefan@nginx.com	--ld-opt="%{LD_OPT}"
91372Sdefan@nginx.com%{__make} %{?_smp_mflags}
92500Sdefan@nginx.com%{__mv} build build-nodebug
93372Sdefan@nginx.com
94372Sdefan@nginx.com%install
95372Sdefan@nginx.com%{__rm} -rf %{buildroot}
96500Sdefan@nginx.com%{__ln_s} build-nodebug build
97*815Sdefan@nginx.comDESTDIR=%{buildroot} make unitd-install libunit-install
98372Sdefan@nginx.com%{__install} -m755 %{bdir}/build-debug/unitd \
99372Sdefan@nginx.com    %{buildroot}%{_sbindir}/unitd-debug
100*815Sdefan@nginx.com%{__install} -m644 %{bdir}/build-debug/libunit.a \
101*815Sdefan@nginx.com    %{buildroot}%{_libdir}/libunit-debug.a
102372Sdefan@nginx.com%{__mkdir} -p %{buildroot}%{_libdir}/unit/modules
103372Sdefan@nginx.com%{__mkdir} -p %{buildroot}%{_libdir}/unit/debug-modules
104372Sdefan@nginx.com%{__mkdir} -p %{buildroot}%{_sharedstatedir}/unit
105372Sdefan@nginx.com%{__mkdir} -p %{buildroot}%{_sysconfdir}/sysconfig
106372Sdefan@nginx.com%{__install} -m 644 -p %{SOURCE3} \
107372Sdefan@nginx.com    %{buildroot}%{_sysconfdir}/sysconfig/unit
108372Sdefan@nginx.com%{__mkdir} -p %{buildroot}%{_sysconfdir}/unit
109372Sdefan@nginx.com%{__mkdir} -p %{buildroot}%{_datadir}/doc/unit/examples
110786Sdefan@nginx.com%{__install} -m 644 -p %{SOURCE4} \
111372Sdefan@nginx.com    %{buildroot}%{_datadir}/doc/unit/examples/example.config
112372Sdefan@nginx.com%{__install} -m 644 -p CHANGES \
113372Sdefan@nginx.com    %{buildroot}%{_datadir}/doc/unit/
114372Sdefan@nginx.com%{__install} -m 644 -p NOTICE \
115372Sdefan@nginx.com    %{buildroot}%{_datadir}/doc/unit/COPYRIGHT
116372Sdefan@nginx.com%{__install} -m 644 -p README \
117372Sdefan@nginx.com    %{buildroot}%{_datadir}/doc/unit/
118372Sdefan@nginx.com
119372Sdefan@nginx.com# init scripts
120372Sdefan@nginx.com%if %{use_systemd}
121372Sdefan@nginx.com%{__rm} -rf %{buildroot}%{_initrddir}/
122372Sdefan@nginx.com%{__install} -p -D -m 0644 %{SOURCE1} %{buildroot}%{_unitdir}/unit.service
123372Sdefan@nginx.com%else
124372Sdefan@nginx.com%{__mkdir} -p %{buildroot}%{_initrddir}
125372Sdefan@nginx.com%{__install} -p -D -m 0755 %{SOURCE2} %{buildroot}%{_initrddir}/unit
126372Sdefan@nginx.com%endif
127372Sdefan@nginx.com
128372Sdefan@nginx.comQA_SKIP_BUILD_ROOT=1
129372Sdefan@nginx.comexport QA_SKIP_BUILD_ROOT
130372Sdefan@nginx.com
131372Sdefan@nginx.com%check
132372Sdefan@nginx.com%if %{dotests}
133372Sdefan@nginx.comcd %{bdir} && make tests && ./build/tests
134372Sdefan@nginx.com%endif
135372Sdefan@nginx.com
136372Sdefan@nginx.com%clean
137372Sdefan@nginx.com%{__rm} -rf %{buildroot}
138372Sdefan@nginx.com
139372Sdefan@nginx.com%post
140372Sdefan@nginx.comif [ $1 -eq 1 ]; then
141372Sdefan@nginx.com%if %{use_systemd}
142372Sdefan@nginx.com    /usr/bin/systemctl preset unit.service >/dev/null 2>&1 ||:
143372Sdefan@nginx.com%else
144372Sdefan@nginx.com    /sbin/chkconfig --add unit
145372Sdefan@nginx.com%endif
146372Sdefan@nginx.com    cat <<BANNER
147372Sdefan@nginx.com----------------------------------------------------------------------
148372Sdefan@nginx.com
149372Sdefan@nginx.comThank you for installing NGINX Unit!
150372Sdefan@nginx.com
151372Sdefan@nginx.comAdditional modules are available in standalone packages.
152372Sdefan@nginx.comTo see the available modules, run "yum list available unit-\*".
153372Sdefan@nginx.com
154372Sdefan@nginx.comOnline documentation is available at https://unit.nginx.org/
155372Sdefan@nginx.com
156372Sdefan@nginx.com----------------------------------------------------------------------
157372Sdefan@nginx.comBANNER
158372Sdefan@nginx.comfi
159372Sdefan@nginx.com
160372Sdefan@nginx.com%preun
161372Sdefan@nginx.comif [ $1 -eq 0 ]; then
162372Sdefan@nginx.com%if %{use_systemd}
163372Sdefan@nginx.com    /usr/bin/systemctl --no-reload disable unit.service >/dev/null 2>&1 ||:
164372Sdefan@nginx.com    /usr/bin/systemctl stop unit.service >/dev/null 2>&1 ||:
165372Sdefan@nginx.com%else
166372Sdefan@nginx.com    /sbin/service unit stop >/dev/null 2>&1
167372Sdefan@nginx.com    /sbin/chkconfig --del unit
168372Sdefan@nginx.com%endif
169372Sdefan@nginx.comfi
170372Sdefan@nginx.com
171372Sdefan@nginx.com%postun
172372Sdefan@nginx.com%if %{use_systemd}
173372Sdefan@nginx.com/usr/bin/systemctl daemon-reload >/dev/null 2>&1 ||:
174372Sdefan@nginx.com%endif
175372Sdefan@nginx.comif [ $1 -ge 1 ]; then
176372Sdefan@nginx.com%if %{use_systemd}
177372Sdefan@nginx.com    /usr/bin/systemctl try-restart unit.service >/dev/null 2>&1 ||:
178372Sdefan@nginx.com%else
179372Sdefan@nginx.com    /sbin/service unit condrestart >/dev/null 2>&1 ||:
180372Sdefan@nginx.com%endif
181372Sdefan@nginx.comfi
182372Sdefan@nginx.com
183372Sdefan@nginx.com%files
184372Sdefan@nginx.com%defattr(-,root,root,-)
185372Sdefan@nginx.com%attr(0755,root,root) %{_sbindir}/unitd
186372Sdefan@nginx.com%attr(0755,root,root) %{_sbindir}/unitd-debug
187372Sdefan@nginx.com%config(noreplace) %{_sysconfdir}/sysconfig/unit
188372Sdefan@nginx.com%dir %{_sysconfdir}/unit
189372Sdefan@nginx.com%if %{use_systemd}
190372Sdefan@nginx.com%{_unitdir}/unit.service
191372Sdefan@nginx.com%else
192372Sdefan@nginx.com%{_initrddir}/unit
193372Sdefan@nginx.com%endif
194372Sdefan@nginx.com%dir %{_datadir}/doc/unit
195372Sdefan@nginx.com%{_datadir}/doc/unit/*
196372Sdefan@nginx.com%dir %{_libdir}/unit/modules
197372Sdefan@nginx.com%dir %{_libdir}/unit/debug-modules
198372Sdefan@nginx.com%dir %{_sharedstatedir}/unit
199372Sdefan@nginx.com
200*815Sdefan@nginx.com%files devel
201*815Sdefan@nginx.com%{_libdir}/libunit.a
202*815Sdefan@nginx.com%{_libdir}/libunit-debug.a
203*815Sdefan@nginx.com%{_includedir}/nxt_*.h
204*815Sdefan@nginx.com
205372Sdefan@nginx.com%changelog
206