summaryrefslogtreecommitdiffhomepage
path: root/pkg/rpm/unit.spec.in
blob: 013236505864bdfa189ab3d9b519850870b9824e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
# distribution specific definitions
%define bdir %{_builddir}/%{name}-%{version}
%define dotests 0

%if 0%{?rhel}%{?fedora}
BuildRequires: gcc
%if 0%{?amzn2}
BuildRequires: openssl11-devel
%else
BuildRequires: openssl-devel
%endif
%endif

%if 0%{?rhel}
%if 0%{?amzn} == 0
%define dist .el%{?rhel}
%endif
%endif

%define CC_OPT %{optflags} -fPIC
%define LD_OPT -Wl,-z,relro -Wl,-z,now -pie

%define CONFIGURE_ARGS $(echo "%%CONFIGURE_ARGS%%")

Provides: nginx-unit

Name: unit
Summary: NGINX Unit
Version: %%VERSION%%
Release: %%RELEASE%%%{?dist}.ngx
License: ASL 2.0
Vendor: %%PACKAGE_VENDOR%%
URL: https://unit.nginx.org/
Group: System Environment/Daemons

Source0: unit-%{version}.tar.gz
Source1: unit.service
Source2: unit-debug.service
Source3: unit.example.config
Source4: unit.logrotate

BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: systemd
Requires(post):    systemd
Requires(preun):   systemd
Requires(postun):  systemd

BuildRequires: pcre2-devel
BuildRequires: pkgconfig
BuildRequires: clang
BuildRequires: llvm

Provides: unit-r%{version}

%description
NGINX Unit is a runtime and delivery environment for modern distributed
applications. It runs the application code in multiple languages
(PHP, Python, Go, etc.), and tightly couples it with traffic delivery
in and out of the application. Take this application server and proxy
directly in the cloud / container environments and fully control your app
dynamically via an API.

%if (0%{?fedora}) || (0%{?rhel} >= 8)
%define _debugsource_template %{nil}
%endif

%package devel
Summary: NGINX Unit (development files)
Version: %%VERSION%%
Release: %%RELEASE%%%{?dist}.ngx
Group: Development/Libraries
Requires: unit == %%VERSION%%-%%RELEASE%%%{?dist}.ngx
%description devel
Library and include files required for NGINX Unit modules development.

%prep
%setup -q

%build
%{__make} %{?_smp_mflags} -C pkg/contrib .njs

PKG_CONFIG_PATH=%{bdir}/pkg/contrib/njs/build \
./configure \
	%{CONFIGURE_ARGS} \
	--modulesdir=%{_libdir}/unit/debug-modules \
	--libdir=%{_libdir} \
	--cc-opt="%{CC_OPT}" \
	--ld-opt="%{LD_OPT}" \
	--debug
%{__make} %{?_smp_mflags}
%{__make} %{?_smp_mflags} build/lib/libunit.a
%{__mv} build build-debug

PKG_CONFIG_PATH=%{bdir}/pkg/contrib/njs/build \
./configure \
	%{CONFIGURE_ARGS} \
	--modulesdir=%{_libdir}/unit/modules \
	--libdir=%{_libdir} \
	--cc-opt="%{CC_OPT}" \
	--ld-opt="%{LD_OPT}"
%{__make} %{?_smp_mflags}
%{__mv} build build-nodebug

%if (0%{?fedora}) || (0%{?rhel} >= 8) || (0%{?amzn2})
%{__make} %{?_smp_mflags} -C pkg/contrib .libunit-wasm
%endif

%install
%{__rm} -rf %{buildroot}
%{__ln_s} build-nodebug build
DESTDIR=%{buildroot} make unitd-install libunit-install manpage-install
%{__mkdir} -p %{buildroot}%{_bindir}
%{__install} -m755 %{bdir}/tools/unitc \
    %{buildroot}%{_bindir}/unitc
%{__install} -m755 %{bdir}/tools/setup-unit \
    %{buildroot}%{_bindir}/setup-unit
%{__install} -m755 %{bdir}/build-debug/sbin/unitd \
    %{buildroot}%{_sbindir}/unitd-debug
%{__install} -m644 %{bdir}/build-debug/lib/libunit.a \
    %{buildroot}%{_libdir}/libunit-debug.a
%{__mkdir} -p %{buildroot}%{_libdir}/unit/modules
%{__mkdir} -p %{buildroot}%{_libdir}/unit/debug-modules
%{__mkdir} -p %{buildroot}%{_sharedstatedir}/unit
%{__mkdir} -p %{buildroot}%{_localstatedir}/log/unit
%{__mkdir} -p %{buildroot}%{_localstatedir}/run/unit
%{__mkdir} -p %{buildroot}%{_sysconfdir}/logrotate.d
%{__install} -m 644 -p %{SOURCE4} \
    %{buildroot}%{_sysconfdir}/logrotate.d/unit
%{__mkdir} -p %{buildroot}%{_datadir}/doc/unit/examples
%{__install} -m 644 -p %{SOURCE3} \
    %{buildroot}%{_datadir}/doc/unit/examples/example.config
%{__install} -m 644 -p CHANGES \
    %{buildroot}%{_datadir}/doc/unit/
%{__install} -m 644 -p NOTICE \
    %{buildroot}%{_datadir}/doc/unit/COPYRIGHT
%{__install} -m 644 -p README.md \
    %{buildroot}%{_datadir}/doc/unit/
%{__install} -m 644 -p CONTRIBUTING.md \
    %{buildroot}%{_datadir}/doc/unit/

%{__rm} -rf %{buildroot}%{_initrddir}/
%{__install} -p -D -m 0644 %{SOURCE1} %{buildroot}%{_unitdir}/unit.service
%{__install} -p -D -m 0644 %{SOURCE2} %{buildroot}%{_unitdir}/unit-debug.service

%if (0%{?fedora}) || (0%{?rhel} >= 8) || (0%{?amzn2})
%{__mkdir} -p %{buildroot}%{_includedir}/unit/
%{__install} -m 644 pkg/contrib/libunit-wasm/src/c/libunit-wasm.a %{buildroot}%{_libdir}/
%{__install} -m 644 pkg/contrib/libunit-wasm/src/c/include/unit/unit-wasm.h %{buildroot}%{_includedir}/unit/
%endif

QA_SKIP_BUILD_ROOT=1
export QA_SKIP_BUILD_ROOT

%check
%if %{dotests}
cd %{bdir} && make tests && ./build/tests
%endif
%{__rm} -rf %{buildroot}/usr/src
cd %{bdir}
grep -v 'usr/src' debugfiles.list > debugfiles.list.new && mv debugfiles.list.new debugfiles.list
cat /dev/null > debugsources.list

%clean
%{__rm} -rf %{buildroot}

%post
getent group unit >/dev/null || groupadd -r unit
getent passwd unit >/dev/null || \
    useradd -r -g unit -s /sbin/nologin \
    -d /nonexistent -c "unit user" unit
if [ $1 -eq 1 ]; then
    /usr/bin/systemctl preset unit.service >/dev/null 2>&1 ||:
    /usr/bin/systemctl preset unit-debug.service >/dev/null 2>&1 ||:
    cat <<BANNER
----------------------------------------------------------------------

Thank you for installing NGINX Unit!

Additional modules are available in standalone packages.
To see the available modules, run "yum list available unit-\*".

Online documentation is available at https://unit.nginx.org/

----------------------------------------------------------------------
BANNER
fi

%preun
if [ $1 -eq 0 ]; then
    /usr/bin/systemctl --no-reload disable unit.service >/dev/null 2>&1 ||:
    /usr/bin/systemctl stop unit.service >/dev/null 2>&1 ||:
fi

%postun
/usr/bin/systemctl daemon-reload >/dev/null 2>&1 ||:
if [ $1 -ge 1 ]; then
    /usr/bin/systemctl try-restart unit.service >/dev/null 2>&1 ||:
fi

%triggerpostun -- unit < 1.22.0
cat <<BANNER
----------------------------------------------------------------------

WARNING:

Since version 1.22.0, Unit's non-privileged processes run as unit:unit by
default.  Review your system permissions and Unit configuration so apps and
routes that relied on these processes running as nobody:nogroup stay working.

More info: https://unit.nginx.org/installation/#official-packages

----------------------------------------------------------------------
BANNER

%files
%defattr(-,root,root,-)
%attr(0755,root,root) %{_bindir}/unitc
%attr(0755,root,root) %{_bindir}/setup-unit
%attr(0755,root,root) %{_sbindir}/unitd
%attr(0755,root,root) %{_sbindir}/unitd-debug
%{_unitdir}/unit.service
%{_unitdir}/unit-debug.service
%dir %attr(0755,root,root) %ghost %{_localstatedir}/run/unit
%dir %{_datadir}/doc/unit
%{_datadir}/doc/unit/*
%dir %{_libdir}/unit/modules
%dir %{_libdir}/unit/debug-modules
%dir %{_sharedstatedir}/unit
%dir %attr(0755,root,root) %{_localstatedir}/log/unit
%config(noreplace) %{_sysconfdir}/logrotate.d/%{name}
%{_mandir}/man8/unitd.8*

%files devel
%{_libdir}/libunit.a
%{_libdir}/libunit-debug.a
%if (0%{?fedora}) || (0%{?rhel} >= 8) || (0%{?amzn2})
%{_libdir}/libunit-wasm.a
%dir %{_includedir}/unit
%{_includedir}/unit/*.h
%endif
%{_includedir}/nxt_*.h
%{_datadir}/pkgconfig/unit.pc

%changelog