summaryrefslogtreecommitdiffstats
path: root/unit.spec
blob: 012bc5a50ae349c6ef7f46df4304735dc2e56406 (plain)
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
# remirepo/fedora spec file for unit-php
#
# Copyright (c) 2019 Remi Collet
# License: CC-BY-SA
# http://creativecommons.org/licenses/by-sa/4.0/
#
# Please, preserve the changelog entries
#

%global gh_owner    nginx
%global project     unit
%global gh_commit   7d53cc7029a7fe1b3195c37a13ff8e83640e88ad
%global gh_short    %(c=%{gh_commit}; echo ${c:0:7})

# distribution specific definitions
%global use_systemd (0%{?rhel} >= 7 || 0%{?fedora} >= 19)
%global with_tests  0%{!?_without_tests:1}

Name:              unit
Summary:           NGINX Unit application server
Version:           1.11.0
Release:           1%{?dist}
License:           ASL 2.0
URL:               https://unit.nginx.org/

Source0:           https://github.com/%{gh_owner}/%{project}/archive/%{gh_commit}/%{project}-%{version}-%{gh_short}.tar.gz
Source1:           unit.service
Source2:           unit.init
Source3:           unit.sysconf
Source4:           unit.logrotate

# Use system crypto policy
Patch0:            https://github.com/nginx/unit/pull/215.patch

BuildRequires:     gcc
BuildRequires:     openssl-devel
%if %{use_systemd}
BuildRequires:     systemd
Requires(post):    systemd
Requires(preun):   systemd
Requires(postun):  systemd
%else
Requires(post):    chkconfig
Requires(preun):   chkconfig
Requires(preun):   initscripts
Requires(postun):  initscripts
%endif
Requires:          logrotate

Provides:          nginx-unit = %{version}-%{release}


%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.


%package devel
Summary: NGINX Unit (development files)
Requires: %{name}%{?_isa} = %{version}-%{release}

%description devel
Library and include files required for NGINX Unit modules development.


%prep
%setup -qn %{project}-%{gh_commit}
%patch0 -p1 -b .syspol

cp pkg/rpm/rpmbuild/SOURCES/unit.example.config example.config


%build
unitconf() {
./configure \
  --libdir=%{_libdir} \
  --prefix=%{_prefix} \
  --state=%{_sharedstatedir}/unit \
%if %{use_systemd}
  --control="unix:/run/unit/control.sock" \
  --pid=/run/unit/unit.pid \
%else
  --control="unix:/var/run/unit/control.sock" \
  --pid=/var/run/unit/unit.pid \
%endif
  --log=/var/log/unit/unit.log \
  --openssl \
  --cc-opt="%{optflags}" \
  --tests \
  $*
}

unitconf \
  --modules=%{_libdir}/unit/debug-modules \
  --debug
make %{?_smp_mflags}
make %{?_smp_mflags} build/libunit.a
mv build build-debug

unitconf \
  --modules=%{_libdir}/unit/modules
make %{?_smp_mflags}


%install
DESTDIR=%{buildroot} make unitd-install libunit-install

install -m755 build-debug/unitd     %{buildroot}%{_sbindir}/unitd-debug
install -m644 build-debug/libunit.a %{buildroot}%{_libdir}/libunit-debug.a

mkdir -p %{buildroot}%{_sysconfdir}/%{name}
mkdir -p %{buildroot}%{_libdir}/%{name}/modules
mkdir -p %{buildroot}%{_libdir}/%{name}/debug-modules
mkdir -p %{buildroot}%{_sharedstatedir}/%{name}
mkdir -p %{buildroot}%{_localstatedir}/log/%{name}
mkdir -p %{buildroot}%{_localstatedir}/run/%{name}

install -p -D -m 0644 %{SOURCE4} %{buildroot}%{_sysconfdir}/logrotate.d/%{name}

# init scripts
%if %{use_systemd}
install -p -D -m 0644 %{SOURCE1} %{buildroot}%{_unitdir}/%{name}.service
mkdir -p %{buildroot}%{_sysconfdir}/systemd/system/%{name}.service.d

%else
install -p -D -m 0644 %{SOURCE3} %{buildroot}%{_sysconfdir}/sysconfig/unitd
install -p -D -m 0755 %{SOURCE2} %{buildroot}%{_initrddir}/%{name}
%endif


%check
%if %{with_tests}
make tests %{?_smp_mflags}
./build/tests
%endif


%post
%if %{use_systemd}
%systemd_post %{name}.service
%else
/sbin/chkconfig --add unit
%endif

%preun
%if %{use_systemd}
%systemd_preun %{name}.service
%else
if [ $1 -eq 0 ]; then
    /sbin/service unit stop >/dev/null 2>&1
    /sbin/chkconfig --del unit
fi
%endif

%postun
%if %{use_systemd}
%systemd_postun_with_restart %{name}.service
%else
if [ $1 -ge 1 ]; then
    /sbin/service unit condrestart >/dev/null 2>&1 ||:
fi
%endif


%files
%{!?_licensedir:%global license %%doc}
%license LICENSE
%doc NOTICE README CHANGES
%doc example.config
%attr(0755,root,root) %{_sbindir}/unitd
%attr(0755,root,root) %{_sbindir}/unitd-debug
%dir %{_sysconfdir}/unit
%dir %{_libdir}/unit/modules
%dir %{_libdir}/unit/debug-modules
%dir %{_sharedstatedir}/unit
%dir %attr(0700,root,root) %{_localstatedir}/log/unit
%config(noreplace) %{_sysconfdir}/logrotate.d/%{name}

%if %{use_systemd}
%dir %{_sysconfdir}/systemd/system/%{name}.service.d
%{_unitdir}/unit.service
%dir %attr(0755,root,root) %ghost /run/unit

%else
%config(noreplace) %{_sysconfdir}/sysconfig/unitd
%dir %attr(0755,root,root) %{_localstatedir}/run/unit
%{_initrddir}/unit
%endif

%files devel
# API is not stable YET, so keep the static library for now (like upstream packages)
%{_libdir}/libunit.a
%{_libdir}/libunit-debug.a
%{_includedir}/nxt_*.h


%changelog
* Fri Sep 20 2019 Remi Collet <remi@remirepo.net> - 1.11.0-1
- update to 1.11.0

* Fri Aug 23 2019 Remi Collet <remi@remirepo.net> - 1.10.0-1
- update to 1.10.0

* Fri May 31 2019 Remi Collet <remi@remirepo.net> - 1.9.0-1
- update to 1.9.0

* Sat Mar  2 2019 Remi Collet <remi@remirepo.net> - 1.8.0-1
- update to 1.8.0

* Fri Feb  8 2019 Remi Collet <remi@remirepo.net> - 1.7.1-1
- update to 1.7.1

* Thu Jan 17 2019 Remi Collet <remi@remirepo.net> - 1.7-2
- provide logrotate configuration

* Tue Jan 15 2019 Remi Collet <remi@remirepo.net> - 1.7-1
- initial package
- open https://github.com/nginx/unit/pull/215 system crypto policy
- open https://github.com/nginx/unit/pull/212 systemd improvments