Line 0
Link Here
|
0 |
- |
1 |
# Copyright 1999-2015 Gentoo Foundation |
|
|
2 |
# Distributed under the terms of the GNU General Public License v2 |
3 |
# $Id$ |
4 |
|
5 |
EAPI=5 |
6 |
|
7 |
# Maintainer notes: |
8 |
# - http_rewrite-independent pcre-support makes sense for matching locations without an actual rewrite |
9 |
# - any http-module activates the main http-functionality and overrides USE=-http |
10 |
# - keep the following requirements in mind before adding external modules: |
11 |
# * alive upstream |
12 |
# * sane packaging |
13 |
# * builds cleanly |
14 |
# * does not need a patch for nginx core |
15 |
# - TODO: test the google-perftools module (included in vanilla tarball) |
16 |
|
17 |
# prevent perl-module from adding automagic perl DEPENDs |
18 |
GENTOO_DEPEND_ON_PERL="no" |
19 |
|
20 |
# devel_kit (https://github.com/simpl/ngx_devel_kit, BSD license) |
21 |
DEVEL_KIT_MODULE_PV="0.2.19" |
22 |
DEVEL_KIT_MODULE_P="ngx_devel_kit-${DEVEL_KIT_MODULE_PV}-r1" |
23 |
DEVEL_KIT_MODULE_URI="https://github.com/simpl/ngx_devel_kit/archive/v${DEVEL_KIT_MODULE_PV}.tar.gz" |
24 |
DEVEL_KIT_MODULE_WD="${WORKDIR}/ngx_devel_kit-${DEVEL_KIT_MODULE_PV}" |
25 |
|
26 |
# http_uploadprogress (https://github.com/masterzen/nginx-upload-progress-module, BSD-2 license) |
27 |
HTTP_UPLOAD_PROGRESS_MODULE_PV="0.9.1" |
28 |
HTTP_UPLOAD_PROGRESS_MODULE_P="ngx_http_upload_progress-${HTTP_UPLOAD_PROGRESS_MODULE_PV}-r1" |
29 |
HTTP_UPLOAD_PROGRESS_MODULE_URI="https://github.com/masterzen/nginx-upload-progress-module/archive/v${HTTP_UPLOAD_PROGRESS_MODULE_PV}.tar.gz" |
30 |
HTTP_UPLOAD_PROGRESS_MODULE_WD="${WORKDIR}/nginx-upload-progress-module-${HTTP_UPLOAD_PROGRESS_MODULE_PV}" |
31 |
|
32 |
# http_headers_more (https://github.com/agentzh/headers-more-nginx-module, BSD license) |
33 |
HTTP_HEADERS_MORE_MODULE_PV="0.261" |
34 |
HTTP_HEADERS_MORE_MODULE_P="ngx_http_headers_more-${HTTP_HEADERS_MORE_MODULE_PV}" |
35 |
HTTP_HEADERS_MORE_MODULE_URI="https://github.com/agentzh/headers-more-nginx-module/archive/v${HTTP_HEADERS_MORE_MODULE_PV}.tar.gz" |
36 |
HTTP_HEADERS_MORE_MODULE_WD="${WORKDIR}/headers-more-nginx-module-${HTTP_HEADERS_MORE_MODULE_PV}" |
37 |
|
38 |
# http_cache_purge (http://labs.frickle.com/nginx_ngx_cache_purge/, BSD-2 license) |
39 |
HTTP_CACHE_PURGE_MODULE_PV="2.3" |
40 |
HTTP_CACHE_PURGE_MODULE_P="ngx_http_cache_purge-${HTTP_CACHE_PURGE_MODULE_PV}" |
41 |
HTTP_CACHE_PURGE_MODULE_URI="http://labs.frickle.com/files/ngx_cache_purge-${HTTP_CACHE_PURGE_MODULE_PV}.tar.gz" |
42 |
HTTP_CACHE_PURGE_MODULE_WD="${WORKDIR}/ngx_cache_purge-${HTTP_CACHE_PURGE_MODULE_PV}" |
43 |
|
44 |
# http_slowfs_cache (http://labs.frickle.com/nginx_ngx_slowfs_cache/, BSD-2 license) |
45 |
HTTP_SLOWFS_CACHE_MODULE_PV="1.10" |
46 |
HTTP_SLOWFS_CACHE_MODULE_P="ngx_http_slowfs_cache-${HTTP_SLOWFS_CACHE_MODULE_PV}" |
47 |
HTTP_SLOWFS_CACHE_MODULE_URI="http://labs.frickle.com/files/ngx_slowfs_cache-${HTTP_SLOWFS_CACHE_MODULE_PV}.tar.gz" |
48 |
HTTP_SLOWFS_CACHE_MODULE_WD="${WORKDIR}/ngx_slowfs_cache-${HTTP_SLOWFS_CACHE_MODULE_PV}" |
49 |
|
50 |
# http_fancyindex (https://github.com/aperezdc/ngx-fancyindex, BSD license) |
51 |
HTTP_FANCYINDEX_MODULE_PV="0.3.5" |
52 |
HTTP_FANCYINDEX_MODULE_P="ngx_http_fancyindex-${HTTP_FANCYINDEX_MODULE_PV}" |
53 |
HTTP_FANCYINDEX_MODULE_URI="https://github.com/aperezdc/ngx-fancyindex/archive/v${HTTP_FANCYINDEX_MODULE_PV}.tar.gz" |
54 |
HTTP_FANCYINDEX_MODULE_WD="${WORKDIR}/ngx-fancyindex-${HTTP_FANCYINDEX_MODULE_PV}" |
55 |
|
56 |
# http_lua (https://github.com/openresty/lua-nginx-module, BSD license) |
57 |
HTTP_LUA_MODULE_PV="0.9.16" |
58 |
HTTP_LUA_MODULE_P="ngx_http_lua-${HTTP_LUA_MODULE_PV}" |
59 |
HTTP_LUA_MODULE_URI="https://github.com/openresty/lua-nginx-module/archive/v${HTTP_LUA_MODULE_PV}.tar.gz" |
60 |
HTTP_LUA_MODULE_WD="${WORKDIR}/lua-nginx-module-${HTTP_LUA_MODULE_PV}" |
61 |
|
62 |
# http_auth_pam (https://github.com/stogh/ngx_http_auth_pam_module/, http://web.iti.upv.es/~sto/nginx/, BSD-2 license) |
63 |
HTTP_AUTH_PAM_MODULE_PV="1.4" |
64 |
HTTP_AUTH_PAM_MODULE_P="ngx_http_auth_pam-${HTTP_AUTH_PAM_MODULE_PV}" |
65 |
HTTP_AUTH_PAM_MODULE_URI="https://github.com/stogh/ngx_http_auth_pam_module/archive/v${HTTP_AUTH_PAM_MODULE_PV}.tar.gz" |
66 |
HTTP_AUTH_PAM_MODULE_WD="${WORKDIR}/ngx_http_auth_pam_module-${HTTP_AUTH_PAM_MODULE_PV}" |
67 |
|
68 |
# http_upstream_check (https://github.com/yaoweibin/nginx_upstream_check_module, BSD license) |
69 |
HTTP_UPSTREAM_CHECK_MODULE_PV="0.3.0" |
70 |
HTTP_UPSTREAM_CHECK_MODULE_P="ngx_http_upstream_check-${HTTP_UPSTREAM_CHECK_MODULE_PV}" |
71 |
HTTP_UPSTREAM_CHECK_MODULE_URI="https://github.com/yaoweibin/nginx_upstream_check_module/archive/v${HTTP_UPSTREAM_CHECK_MODULE_PV}.tar.gz" |
72 |
HTTP_UPSTREAM_CHECK_MODULE_WD="${WORKDIR}/nginx_upstream_check_module-${HTTP_UPSTREAM_CHECK_MODULE_PV}" |
73 |
|
74 |
# http_metrics (https://github.com/zenops/ngx_metrics, BSD license) |
75 |
HTTP_METRICS_MODULE_PV="0.1.1" |
76 |
HTTP_METRICS_MODULE_P="ngx_metrics-${HTTP_METRICS_MODULE_PV}" |
77 |
HTTP_METRICS_MODULE_URI="https://github.com/madvertise/ngx_metrics/archive/v${HTTP_METRICS_MODULE_PV}.tar.gz" |
78 |
HTTP_METRICS_MODULE_WD="${WORKDIR}/ngx_metrics-${HTTP_METRICS_MODULE_PV}" |
79 |
|
80 |
# naxsi-core (https://github.com/nbs-system/naxsi, GPLv2+) |
81 |
HTTP_NAXSI_MODULE_PV="0.54" |
82 |
HTTP_NAXSI_MODULE_P="ngx_http_naxsi-${HTTP_NAXSI_MODULE_PV}" |
83 |
HTTP_NAXSI_MODULE_URI="https://github.com/nbs-system/naxsi/archive/${HTTP_NAXSI_MODULE_PV}.tar.gz" |
84 |
HTTP_NAXSI_MODULE_WD="${WORKDIR}/naxsi-${HTTP_NAXSI_MODULE_PV}/naxsi_src" |
85 |
|
86 |
# nginx-rtmp-module (https://github.com/arut/nginx-rtmp-module, BSD license) |
87 |
RTMP_MODULE_PV="1.1.7" |
88 |
RTMP_MODULE_P="ngx_rtmp-${RTMP_MODULE_PV}" |
89 |
RTMP_MODULE_URI="https://github.com/arut/nginx-rtmp-module/archive/v${RTMP_MODULE_PV}.tar.gz" |
90 |
RTMP_MODULE_WD="${WORKDIR}/nginx-rtmp-module-${RTMP_MODULE_PV}" |
91 |
|
92 |
# nginx-dav-ext-module (https://github.com/arut/nginx-dav-ext-module, BSD license) |
93 |
HTTP_DAV_EXT_MODULE_PV="0.0.3" |
94 |
HTTP_DAV_EXT_MODULE_P="ngx_http_dav_ext-${HTTP_DAV_EXT_MODULE_PV}" |
95 |
HTTP_DAV_EXT_MODULE_URI="https://github.com/arut/nginx-dav-ext-module/archive/v${HTTP_DAV_EXT_MODULE_PV}.tar.gz" |
96 |
HTTP_DAV_EXT_MODULE_WD="${WORKDIR}/nginx-dav-ext-module-${HTTP_DAV_EXT_MODULE_PV}" |
97 |
|
98 |
# echo-nginx-module (https://github.com/agentzh/echo-nginx-module, BSD license) |
99 |
HTTP_ECHO_MODULE_PV="0.58" |
100 |
HTTP_ECHO_MODULE_P="ngx_http_echo-${HTTP_ECHO_MODULE_PV}" |
101 |
HTTP_ECHO_MODULE_URI="https://github.com/agentzh/echo-nginx-module/archive/v${HTTP_ECHO_MODULE_PV}.tar.gz" |
102 |
HTTP_ECHO_MODULE_WD="${WORKDIR}/echo-nginx-module-${HTTP_ECHO_MODULE_PV}" |
103 |
|
104 |
# mod_security for nginx (https://modsecurity.org/, Apache-2.0) |
105 |
# keep the MODULE_P here consistent with upstream to avoid tarball duplication |
106 |
HTTP_SECURITY_MODULE_PV="2.9.0" |
107 |
HTTP_SECURITY_MODULE_P="modsecurity-${HTTP_SECURITY_MODULE_PV}" |
108 |
HTTP_SECURITY_MODULE_URI="https://www.modsecurity.org/tarball/${HTTP_SECURITY_MODULE_PV}/${HTTP_SECURITY_MODULE_P}.tar.gz" |
109 |
HTTP_SECURITY_MODULE_WD="${WORKDIR}/${HTTP_SECURITY_MODULE_P}" |
110 |
|
111 |
# push-stream-module (http://www.nginxpushstream.com, https://github.com/wandenberg/nginx-push-stream-module, GPL-3) |
112 |
HTTP_PUSH_STREAM_MODULE_PV="0.5.1" |
113 |
HTTP_PUSH_STREAM_MODULE_P="ngx_http_push_stream-${HTTP_PUSH_STREAM_MODULE_PV}" |
114 |
HTTP_PUSH_STREAM_MODULE_URI="https://github.com/wandenberg/nginx-push-stream-module/archive/${HTTP_PUSH_STREAM_MODULE_PV}.tar.gz" |
115 |
HTTP_PUSH_STREAM_MODULE_WD="${WORKDIR}/nginx-push-stream-module-${HTTP_PUSH_STREAM_MODULE_PV}" |
116 |
|
117 |
# sticky-module (https://bitbucket.org/nginx-goodies/nginx-sticky-module-ng, BSD-2) |
118 |
HTTP_STICKY_MODULE_PV="1.2.6" |
119 |
HTTP_STICKY_MODULE_P="nginx_http_sticky_module_ng-${HTTP_STICKY_MODULE_PV}" |
120 |
HTTP_STICKY_MODULE_URI="https://bitbucket.org/nginx-goodies/nginx-sticky-module-ng/get/${HTTP_STICKY_MODULE_PV}.tar.bz2" |
121 |
HTTP_STICKY_MODULE_WD="${WORKDIR}/nginx-goodies-nginx-sticky-module-ng-c78b7dd79d0d" |
122 |
|
123 |
# mogilefs-module (http://www.grid.net.ru/nginx/mogilefs.en.html, BSD-2) |
124 |
HTTP_MOGILEFS_MODULE_PV="1.0.4" |
125 |
HTTP_MOGILEFS_MODULE_P="ngx_mogilefs_module-${HTTP_MOGILEFS_MODULE_PV}" |
126 |
HTTP_MOGILEFS_MODULE_URI="http://www.grid.net.ru/nginx/download/nginx_mogilefs_module-${HTTP_MOGILEFS_MODULE_PV}.tar.gz" |
127 |
HTTP_MOGILEFS_MODULE_WD="${WORKDIR}/nginx_mogilefs_module-${HTTP_MOGILEFS_MODULE_PV}" |
128 |
|
129 |
# memc-module (https://github.com/openresty/memc-nginx-module, BSD-2) |
130 |
HTTP_MEMC_MODULE_PV="0.16" |
131 |
HTTP_MEMC_MODULE_P="ngx_memc_module-${HTTP_MEMC_MODULE_PV}" |
132 |
HTTP_MEMC_MODULE_URI="https://github.com/openresty/memc-nginx-module/archive/v${HTTP_MEMC_MODULE_PV}.tar.gz" |
133 |
HTTP_MEMC_MODULE_WD="${WORKDIR}/memc-nginx-module-${HTTP_MEMC_MODULE_PV}" |
134 |
|
135 |
inherit eutils ssl-cert toolchain-funcs perl-module flag-o-matic user systemd versionator multilib |
136 |
|
137 |
DESCRIPTION="Robust, small and high performance http and reverse proxy server" |
138 |
HOMEPAGE="http://nginx.org" |
139 |
SRC_URI="http://nginx.org/download/${P}.tar.gz |
140 |
${DEVEL_KIT_MODULE_URI} -> ${DEVEL_KIT_MODULE_P}.tar.gz |
141 |
nginx_modules_http_upload_progress? ( ${HTTP_UPLOAD_PROGRESS_MODULE_URI} -> ${HTTP_UPLOAD_PROGRESS_MODULE_P}.tar.gz ) |
142 |
nginx_modules_http_headers_more? ( ${HTTP_HEADERS_MORE_MODULE_URI} -> ${HTTP_HEADERS_MORE_MODULE_P}.tar.gz ) |
143 |
nginx_modules_http_cache_purge? ( ${HTTP_CACHE_PURGE_MODULE_URI} -> ${HTTP_CACHE_PURGE_MODULE_P}.tar.gz ) |
144 |
nginx_modules_http_slowfs_cache? ( ${HTTP_SLOWFS_CACHE_MODULE_URI} -> ${HTTP_SLOWFS_CACHE_MODULE_P}.tar.gz ) |
145 |
nginx_modules_http_fancyindex? ( ${HTTP_FANCYINDEX_MODULE_URI} -> ${HTTP_FANCYINDEX_MODULE_P}.tar.gz ) |
146 |
nginx_modules_http_lua? ( ${HTTP_LUA_MODULE_URI} -> ${HTTP_LUA_MODULE_P}.tar.gz ) |
147 |
nginx_modules_http_auth_pam? ( ${HTTP_AUTH_PAM_MODULE_URI} -> ${HTTP_AUTH_PAM_MODULE_P}.tar.gz ) |
148 |
nginx_modules_http_upstream_check? ( ${HTTP_UPSTREAM_CHECK_MODULE_URI} -> ${HTTP_UPSTREAM_CHECK_MODULE_P}.tar.gz ) |
149 |
nginx_modules_http_metrics? ( ${HTTP_METRICS_MODULE_URI} -> ${HTTP_METRICS_MODULE_P}.tar.gz ) |
150 |
nginx_modules_http_naxsi? ( ${HTTP_NAXSI_MODULE_URI} -> ${HTTP_NAXSI_MODULE_P}.tar.gz ) |
151 |
rtmp? ( ${RTMP_MODULE_URI} -> ${RTMP_MODULE_P}.tar.gz ) |
152 |
nginx_modules_http_dav_ext? ( ${HTTP_DAV_EXT_MODULE_URI} -> ${HTTP_DAV_EXT_MODULE_P}.tar.gz ) |
153 |
nginx_modules_http_echo? ( ${HTTP_ECHO_MODULE_URI} -> ${HTTP_ECHO_MODULE_P}.tar.gz ) |
154 |
nginx_modules_http_security? ( ${HTTP_SECURITY_MODULE_URI} -> ${HTTP_SECURITY_MODULE_P}.tar.gz ) |
155 |
nginx_modules_http_push_stream? ( ${HTTP_PUSH_STREAM_MODULE_URI} -> ${HTTP_PUSH_STREAM_MODULE_P}.tar.gz ) |
156 |
nginx_modules_http_sticky? ( ${HTTP_STICKY_MODULE_URI} -> ${HTTP_STICKY_MODULE_P}.tar.bz2 ) |
157 |
nginx_modules_http_mogilefs? ( ${HTTP_MOGILEFS_MODULE_URI} -> ${HTTP_MOGILEFS_MODULE_P}.tar.gz ) |
158 |
nginx_modules_http_memc? ( ${HTTP_MEMC_MODULE_URI} -> ${HTTP_MEMC_MODULE_P}.tar.gz )" |
159 |
|
160 |
LICENSE="BSD-2 BSD SSLeay MIT GPL-2 GPL-2+ |
161 |
nginx_modules_http_security? ( Apache-2.0 ) |
162 |
nginx_modules_http_push_stream? ( GPL-3 )" |
163 |
|
164 |
SLOT="mainline" |
165 |
KEYWORDS="~amd64 ~arm ~arm64 ~ppc ~x86 ~x86-fbsd ~amd64-linux ~x86-linux" |
166 |
|
167 |
NGINX_MODULES_STD="access auth_basic autoindex browser charset empty_gif fastcgi |
168 |
geo gzip limit_req limit_conn map memcached proxy referer rewrite scgi ssi |
169 |
split_clients upstream_ip_hash userid uwsgi" |
170 |
NGINX_MODULES_OPT="addition auth_request dav degradation flv geoip gunzip gzip_static |
171 |
image_filter mp4 perl random_index realip secure_link stub_status sub xslt" |
172 |
NGINX_MODULES_MAIL="imap pop3 smtp" |
173 |
NGINX_MODULES_3RD=" |
174 |
http_upload_progress |
175 |
http_headers_more |
176 |
http_cache_purge |
177 |
http_slowfs_cache |
178 |
http_fancyindex |
179 |
http_lua |
180 |
http_auth_pam |
181 |
http_upstream_check |
182 |
http_metrics |
183 |
http_naxsi |
184 |
http_dav_ext |
185 |
http_echo |
186 |
http_security |
187 |
http_push_stream |
188 |
http_sticky |
189 |
http_ajp |
190 |
http_mogilefs |
191 |
http_memc" |
192 |
|
193 |
IUSE="aio debug +http http2 +http-cache ipv6 libatomic libressl luajit +pcre pcre-jit rtmp |
194 |
selinux ssl threads userland_GNU vim-syntax" |
195 |
|
196 |
for mod in $NGINX_MODULES_STD; do |
197 |
IUSE="${IUSE} +nginx_modules_http_${mod}" |
198 |
done |
199 |
|
200 |
for mod in $NGINX_MODULES_OPT; do |
201 |
IUSE="${IUSE} nginx_modules_http_${mod}" |
202 |
done |
203 |
|
204 |
for mod in $NGINX_MODULES_MAIL; do |
205 |
IUSE="${IUSE} nginx_modules_mail_${mod}" |
206 |
done |
207 |
|
208 |
for mod in $NGINX_MODULES_3RD; do |
209 |
IUSE="${IUSE} nginx_modules_${mod}" |
210 |
done |
211 |
|
212 |
# Add so we can warn users updating about config changes |
213 |
IUSE="${IUSE} nginx_modules_http_spdy" |
214 |
|
215 |
CDEPEND=" |
216 |
pcre? ( >=dev-libs/libpcre-4.2 ) |
217 |
pcre-jit? ( >=dev-libs/libpcre-8.20[jit] ) |
218 |
ssl? ( |
219 |
!libressl? ( dev-libs/openssl:0= ) |
220 |
libressl? ( dev-libs/libressl:= ) |
221 |
) |
222 |
http2? ( |
223 |
!libressl? ( >=dev-libs/openssl-1.0.1c:0= ) |
224 |
libressl? ( dev-libs/libressl:= ) |
225 |
) |
226 |
http-cache? ( |
227 |
userland_GNU? ( |
228 |
!libressl? ( dev-libs/openssl:0= ) |
229 |
libressl? ( dev-libs/libressl:= ) |
230 |
) |
231 |
) |
232 |
nginx_modules_http_geoip? ( dev-libs/geoip ) |
233 |
nginx_modules_http_gunzip? ( sys-libs/zlib ) |
234 |
nginx_modules_http_gzip? ( sys-libs/zlib ) |
235 |
nginx_modules_http_gzip_static? ( sys-libs/zlib ) |
236 |
nginx_modules_http_image_filter? ( media-libs/gd[jpeg,png] ) |
237 |
nginx_modules_http_perl? ( >=dev-lang/perl-5.8 ) |
238 |
nginx_modules_http_rewrite? ( >=dev-libs/libpcre-4.2 ) |
239 |
nginx_modules_http_secure_link? ( |
240 |
userland_GNU? ( |
241 |
!libressl? ( dev-libs/openssl:0= ) |
242 |
libressl? ( dev-libs/libressl:= ) |
243 |
) |
244 |
) |
245 |
nginx_modules_http_xslt? ( dev-libs/libxml2 dev-libs/libxslt ) |
246 |
nginx_modules_http_lua? ( !luajit? ( dev-lang/lua:0= ) luajit? ( dev-lang/luajit:2= ) ) |
247 |
nginx_modules_http_auth_pam? ( virtual/pam ) |
248 |
nginx_modules_http_metrics? ( dev-libs/yajl ) |
249 |
nginx_modules_http_dav_ext? ( dev-libs/expat ) |
250 |
nginx_modules_http_security? ( >=dev-libs/libxml2-2.7.8 dev-libs/apr-util www-servers/apache )" |
251 |
RDEPEND="${CDEPEND} |
252 |
selinux? ( sec-policy/selinux-nginx ) |
253 |
!www-servers/nginx:0" |
254 |
DEPEND="${CDEPEND} |
255 |
arm? ( dev-libs/libatomic_ops ) |
256 |
libatomic? ( dev-libs/libatomic_ops )" |
257 |
PDEPEND="vim-syntax? ( app-vim/nginx-syntax )" |
258 |
|
259 |
REQUIRED_USE="pcre-jit? ( pcre ) |
260 |
nginx_modules_http_lua? ( nginx_modules_http_rewrite ) |
261 |
nginx_modules_http_naxsi? ( pcre ) |
262 |
nginx_modules_http_dav_ext? ( nginx_modules_http_dav ) |
263 |
nginx_modules_http_metrics? ( nginx_modules_http_stub_status ) |
264 |
nginx_modules_http_security? ( pcre ) |
265 |
nginx_modules_http_push_stream? ( ssl )" |
266 |
|
267 |
pkg_setup() { |
268 |
NGINX_HOME="/var/lib/nginx" |
269 |
NGINX_HOME_TMP="${NGINX_HOME}/tmp" |
270 |
|
271 |
ebegin "Creating nginx user and group" |
272 |
enewgroup ${PN} |
273 |
enewuser ${PN} -1 -1 "${NGINX_HOME}" ${PN} |
274 |
eend $? |
275 |
|
276 |
if use libatomic; then |
277 |
ewarn "GCC 4.1+ features built-in atomic operations." |
278 |
ewarn "Using libatomic_ops is only needed if using" |
279 |
ewarn "a different compiler or a GCC prior to 4.1" |
280 |
fi |
281 |
|
282 |
if [[ -n $NGINX_ADD_MODULES ]]; then |
283 |
ewarn "You are building custom modules via \$NGINX_ADD_MODULES!" |
284 |
ewarn "This nginx installation is not supported!" |
285 |
ewarn "Make sure you can reproduce the bug without those modules" |
286 |
ewarn "_before_ reporting bugs." |
287 |
fi |
288 |
|
289 |
if use !http; then |
290 |
ewarn "To actually disable all http-functionality you also have to disable" |
291 |
ewarn "all nginx http modules." |
292 |
fi |
293 |
|
294 |
if use nginx_modules_http_ajp; then |
295 |
eerror "The AJP module currently doesn't build for nginx >1.8." |
296 |
eerror "It will be reintroduced with the 1.9 series when proven stable." |
297 |
eerror "Either disable it or stick with nginx 1.7.x." |
298 |
die "AJP module not supported" |
299 |
fi |
300 |
|
301 |
if use nginx_modules_http_mogilefs && use threads; then |
302 |
eerror "mogilefs won't compile with threads support." |
303 |
eerror "Please disable either flag and try again." |
304 |
die "Can't compile mogilefs with threads support" |
305 |
fi |
306 |
} |
307 |
|
308 |
src_prepare() { |
309 |
epatch_user |
310 |
|
311 |
epatch "${FILESDIR}/${PN}-1.4.1-fix-perl-install-path.patch" |
312 |
|
313 |
if use nginx_modules_http_upstream_check; then |
314 |
epatch "${FILESDIR}/check-1.9.2".patch |
315 |
fi |
316 |
|
317 |
if use nginx_modules_http_lua; then |
318 |
sed -i -e 's/-llua5.1/-llua/' "${HTTP_LUA_MODULE_WD}/config" || die |
319 |
fi |
320 |
|
321 |
find auto/ -type f -print0 | xargs -0 sed -i 's:\&\& make:\&\& \\$(MAKE):' || die |
322 |
# We have config protection, don't rename etc files |
323 |
sed -i 's:.default::' auto/install || die |
324 |
# remove useless files |
325 |
sed -i -e '/koi-/d' -e '/win-/d' auto/install || die |
326 |
|
327 |
# don't install to /etc/nginx/ if not in use |
328 |
local module |
329 |
for module in fastcgi scgi uwsgi ; do |
330 |
if ! use nginx_modules_http_${module}; then |
331 |
sed -i -e "/${module}/d" auto/install || die |
332 |
fi |
333 |
done |
334 |
} |
335 |
|
336 |
src_configure() { |
337 |
# mod_security needs to generate nginx/modsecurity/config before including it |
338 |
if use nginx_modules_http_security; then |
339 |
cd "${HTTP_SECURITY_MODULE_WD}" |
340 |
if use luajit ; then |
341 |
sed -i \ |
342 |
-e 's|^\(LUA_PKGNAMES\)=.*|\1="luajit"|' \ |
343 |
configure || die |
344 |
fi |
345 |
./configure \ |
346 |
--enable-standalone-module \ |
347 |
$(use_enable pcre-jit) \ |
348 |
$(use_with nginx_modules_http_lua lua) || die "configure failed for mod_security" |
349 |
fi |
350 |
|
351 |
cd "${S}" |
352 |
|
353 |
local myconf=() http_enabled= mail_enabled= |
354 |
|
355 |
use aio && myconf+=( --with-file-aio ) |
356 |
use debug && myconf+=( --with-debug ) |
357 |
use http2 && myconf+=( --with-http_v2_module ) |
358 |
use ipv6 && myconf+=( --with-ipv6 ) |
359 |
use libatomic && myconf+=( --with-libatomic ) |
360 |
use pcre && myconf+=( --with-pcre ) |
361 |
use pcre-jit && myconf+=( --with-pcre-jit ) |
362 |
use threads && myconf+=( --with-threads ) |
363 |
|
364 |
# HTTP modules |
365 |
for mod in $NGINX_MODULES_STD; do |
366 |
if use nginx_modules_http_${mod}; then |
367 |
http_enabled=1 |
368 |
else |
369 |
myconf+=( --without-http_${mod}_module ) |
370 |
fi |
371 |
done |
372 |
|
373 |
for mod in $NGINX_MODULES_OPT; do |
374 |
if use nginx_modules_http_${mod}; then |
375 |
http_enabled=1 |
376 |
myconf+=( --with-http_${mod}_module ) |
377 |
fi |
378 |
done |
379 |
|
380 |
if use nginx_modules_http_fastcgi; then |
381 |
myconf+=( --with-http_realip_module ) |
382 |
fi |
383 |
|
384 |
# third-party modules |
385 |
if use nginx_modules_http_upload_progress; then |
386 |
http_enabled=1 |
387 |
myconf+=( --add-module=${HTTP_UPLOAD_PROGRESS_MODULE_WD} ) |
388 |
fi |
389 |
|
390 |
if use nginx_modules_http_headers_more; then |
391 |
http_enabled=1 |
392 |
myconf+=( --add-module=${HTTP_HEADERS_MORE_MODULE_WD} ) |
393 |
fi |
394 |
|
395 |
if use nginx_modules_http_cache_purge; then |
396 |
http_enabled=1 |
397 |
myconf+=( --add-module=${HTTP_CACHE_PURGE_MODULE_WD} ) |
398 |
fi |
399 |
|
400 |
if use nginx_modules_http_slowfs_cache; then |
401 |
http_enabled=1 |
402 |
myconf+=( --add-module=${HTTP_SLOWFS_CACHE_MODULE_WD} ) |
403 |
fi |
404 |
|
405 |
if use nginx_modules_http_fancyindex; then |
406 |
http_enabled=1 |
407 |
myconf+=( --add-module=${HTTP_FANCYINDEX_MODULE_WD} ) |
408 |
fi |
409 |
|
410 |
if use nginx_modules_http_lua; then |
411 |
http_enabled=1 |
412 |
if use luajit; then |
413 |
export LUAJIT_LIB=$(pkg-config --variable libdir luajit) |
414 |
export LUAJIT_INC=$(pkg-config --variable includedir luajit) |
415 |
else |
416 |
export LUA_LIB=$(pkg-config --variable libdir lua) |
417 |
export LUA_INC=$(pkg-config --variable includedir lua) |
418 |
fi |
419 |
myconf+=( --add-module=${DEVEL_KIT_MODULE_WD} ) |
420 |
myconf+=( --add-module=${HTTP_LUA_MODULE_WD} ) |
421 |
fi |
422 |
|
423 |
if use nginx_modules_http_auth_pam; then |
424 |
http_enabled=1 |
425 |
myconf+=( --add-module=${HTTP_AUTH_PAM_MODULE_WD} ) |
426 |
fi |
427 |
|
428 |
if use nginx_modules_http_upstream_check; then |
429 |
http_enabled=1 |
430 |
myconf+=( --add-module=${HTTP_UPSTREAM_CHECK_MODULE_WD} ) |
431 |
fi |
432 |
|
433 |
if use nginx_modules_http_metrics; then |
434 |
http_enabled=1 |
435 |
myconf+=( --add-module=${HTTP_METRICS_MODULE_WD} ) |
436 |
fi |
437 |
|
438 |
if use nginx_modules_http_naxsi ; then |
439 |
http_enabled=1 |
440 |
myconf+=( --add-module=${HTTP_NAXSI_MODULE_WD} ) |
441 |
fi |
442 |
|
443 |
if use rtmp ; then |
444 |
http_enabled=1 |
445 |
myconf+=( --add-module=${RTMP_MODULE_WD} ) |
446 |
fi |
447 |
|
448 |
if use nginx_modules_http_dav_ext ; then |
449 |
http_enabled=1 |
450 |
myconf+=( --add-module=${HTTP_DAV_EXT_MODULE_WD} ) |
451 |
fi |
452 |
|
453 |
if use nginx_modules_http_echo ; then |
454 |
http_enabled=1 |
455 |
myconf+=( --add-module=${HTTP_ECHO_MODULE_WD} ) |
456 |
fi |
457 |
|
458 |
if use nginx_modules_http_security ; then |
459 |
http_enabled=1 |
460 |
myconf+=( --add-module=${HTTP_SECURITY_MODULE_WD}/nginx/modsecurity ) |
461 |
fi |
462 |
|
463 |
if use nginx_modules_http_push_stream ; then |
464 |
http_enabled=1 |
465 |
myconf+=( --add-module=${HTTP_PUSH_STREAM_MODULE_WD} ) |
466 |
fi |
467 |
|
468 |
if use nginx_modules_http_sticky ; then |
469 |
http_enabled=1 |
470 |
myconf+=( --add-module=${HTTP_STICKY_MODULE_WD} ) |
471 |
fi |
472 |
|
473 |
if use nginx_modules_http_mogilefs ; then |
474 |
http_enabled=1 |
475 |
myconf+=( --add-module=${HTTP_MOGILEFS_MODULE_WD} ) |
476 |
fi |
477 |
|
478 |
if use nginx_modules_http_memc ; then |
479 |
http_enabled=1 |
480 |
myconf+=( --add-module=${HTTP_MEMC_MODULE_WD} ) |
481 |
fi |
482 |
|
483 |
if use http || use http-cache || use http2; then |
484 |
http_enabled=1 |
485 |
fi |
486 |
|
487 |
if [ $http_enabled ]; then |
488 |
use http-cache || myconf+=( --without-http-cache ) |
489 |
use ssl && myconf+=( --with-http_ssl_module ) |
490 |
else |
491 |
myconf+=( --without-http --without-http-cache ) |
492 |
fi |
493 |
|
494 |
# MAIL modules |
495 |
for mod in $NGINX_MODULES_MAIL; do |
496 |
if use nginx_modules_mail_${mod}; then |
497 |
mail_enabled=1 |
498 |
else |
499 |
myconf+=( --without-mail_${mod}_module ) |
500 |
fi |
501 |
done |
502 |
|
503 |
if [ $mail_enabled ]; then |
504 |
myconf+=( --with-mail ) |
505 |
use ssl && myconf+=( --with-mail_ssl_module ) |
506 |
fi |
507 |
|
508 |
# custom modules |
509 |
for mod in $NGINX_ADD_MODULES; do |
510 |
myconf+=( --add-module=${mod} ) |
511 |
done |
512 |
|
513 |
# https://bugs.gentoo.org/286772 |
514 |
export LANG=C LC_ALL=C |
515 |
tc-export CC |
516 |
|
517 |
if ! use prefix; then |
518 |
myconf+=( --user=${PN}" "--group=${PN} ) |
519 |
fi |
520 |
|
521 |
./configure \ |
522 |
--prefix="${EPREFIX}"/usr \ |
523 |
--conf-path="${EPREFIX}"/etc/${PN}/${PN}.conf \ |
524 |
--error-log-path="${EPREFIX}"/var/log/${PN}/error_log \ |
525 |
--pid-path="${EPREFIX}"/run/${PN}.pid \ |
526 |
--lock-path="${EPREFIX}"/run/lock/${PN}.lock \ |
527 |
--with-cc-opt="-I${EROOT}usr/include" \ |
528 |
--with-ld-opt="-L${EROOT}usr/$(get_libdir)" \ |
529 |
--http-log-path="${EPREFIX}"/var/log/${PN}/access_log \ |
530 |
--http-client-body-temp-path="${EPREFIX}${NGINX_HOME_TMP}"/client \ |
531 |
--http-proxy-temp-path="${EPREFIX}${NGINX_HOME_TMP}"/proxy \ |
532 |
--http-fastcgi-temp-path="${EPREFIX}${NGINX_HOME_TMP}"/fastcgi \ |
533 |
--http-scgi-temp-path="${EPREFIX}${NGINX_HOME_TMP}"/scgi \ |
534 |
--http-uwsgi-temp-path="${EPREFIX}${NGINX_HOME_TMP}"/uwsgi \ |
535 |
"${myconf[@]}" || die "configure failed" |
536 |
|
537 |
# A purely cosmetic change that makes nginx -V more readable. This can be |
538 |
# good if people outside the gentoo community would troubleshoot and |
539 |
# question the users setup. |
540 |
sed -i -e "s|${WORKDIR}|external_module|g" objs/ngx_auto_config.h || die |
541 |
} |
542 |
|
543 |
src_compile() { |
544 |
use nginx_modules_http_security && emake -C "${HTTP_SECURITY_MODULE_WD}" |
545 |
|
546 |
# https://bugs.gentoo.org/286772 |
547 |
export LANG=C LC_ALL=C |
548 |
emake LINK="${CC} ${LDFLAGS}" OTHERLDFLAGS="${LDFLAGS}" |
549 |
} |
550 |
|
551 |
src_install() { |
552 |
emake DESTDIR="${D%/}" install |
553 |
|
554 |
cp "${FILESDIR}"/nginx.conf "${ED}"etc/nginx/nginx.conf || die |
555 |
|
556 |
newinitd "${FILESDIR}"/nginx.initd-r2 nginx |
557 |
|
558 |
systemd_newunit "${FILESDIR}"/nginx.service-r1 nginx.service |
559 |
|
560 |
doman man/nginx.8 |
561 |
dodoc CHANGES* README |
562 |
|
563 |
# just keepdir. do not copy the default htdocs files (bug #449136) |
564 |
keepdir /var/www/localhost |
565 |
rm -rf "${D}"usr/html || die |
566 |
|
567 |
# set up a list of directories to keep |
568 |
local keepdir_list="${NGINX_HOME_TMP}"/client |
569 |
local module |
570 |
for module in proxy fastcgi scgi uwsgi; do |
571 |
use nginx_modules_http_${module} && keepdir_list+=" ${NGINX_HOME_TMP}/${module}" |
572 |
done |
573 |
|
574 |
keepdir /var/log/nginx ${keepdir_list} |
575 |
|
576 |
# this solves a problem with SELinux where nginx doesn't see the directories |
577 |
# as root and tries to create them as nginx |
578 |
fperms 0750 "${NGINX_HOME_TMP}" |
579 |
fowners ${PN}:0 "${NGINX_HOME_TMP}" |
580 |
|
581 |
fperms 0700 /var/log/nginx ${keepdir_list} |
582 |
fowners ${PN}:${PN} /var/log/nginx ${keepdir_list} |
583 |
|
584 |
# logrotate |
585 |
insinto /etc/logrotate.d |
586 |
newins "${FILESDIR}"/nginx.logrotate-r1 nginx |
587 |
|
588 |
if use nginx_modules_http_perl; then |
589 |
cd "${S}"/objs/src/http/modules/perl/ |
590 |
emake DESTDIR="${D}" INSTALLDIRS=vendor |
591 |
perl_delete_localpod |
592 |
fi |
593 |
|
594 |
if use nginx_modules_http_cache_purge; then |
595 |
docinto ${HTTP_CACHE_PURGE_MODULE_P} |
596 |
dodoc "${HTTP_CACHE_PURGE_MODULE_WD}"/{CHANGES,README.md,TODO.md} |
597 |
fi |
598 |
|
599 |
if use nginx_modules_http_slowfs_cache; then |
600 |
docinto ${HTTP_SLOWFS_CACHE_MODULE_P} |
601 |
dodoc "${HTTP_SLOWFS_CACHE_MODULE_WD}"/{CHANGES,README.md} |
602 |
fi |
603 |
|
604 |
if use nginx_modules_http_fancyindex; then |
605 |
docinto ${HTTP_FANCYINDEX_MODULE_P} |
606 |
dodoc "${HTTP_FANCYINDEX_MODULE_WD}"/README.rst |
607 |
fi |
608 |
|
609 |
if use nginx_modules_http_lua; then |
610 |
docinto ${HTTP_LUA_MODULE_P} |
611 |
dodoc "${HTTP_LUA_MODULE_WD}"/{Changes,README.markdown} |
612 |
fi |
613 |
|
614 |
if use nginx_modules_http_auth_pam; then |
615 |
docinto ${HTTP_AUTH_PAM_MODULE_P} |
616 |
dodoc "${HTTP_AUTH_PAM_MODULE_WD}"/{README.md,ChangeLog} |
617 |
fi |
618 |
|
619 |
if use nginx_modules_http_upstream_check; then |
620 |
docinto ${HTTP_UPSTREAM_CHECK_MODULE_P} |
621 |
dodoc "${HTTP_UPSTREAM_CHECK_MODULE_WD}"/{README,CHANGES} |
622 |
fi |
623 |
|
624 |
if use nginx_modules_http_naxsi; then |
625 |
insinto /etc/nginx |
626 |
doins "${HTTP_NAXSI_MODULE_WD}"/../naxsi_config/naxsi_core.rules |
627 |
fi |
628 |
|
629 |
if use rtmp; then |
630 |
docinto ${RTMP_MODULE_P} |
631 |
dodoc "${RTMP_MODULE_WD}"/{AUTHORS,README.md,stat.xsl} |
632 |
fi |
633 |
|
634 |
if use nginx_modules_http_dav_ext; then |
635 |
docinto ${HTTP_DAV_EXT_MODULE_P} |
636 |
dodoc "${HTTP_DAV_EXT_MODULE_WD}"/README |
637 |
fi |
638 |
|
639 |
if use nginx_modules_http_echo; then |
640 |
docinto ${HTTP_ECHO_MODULE_P} |
641 |
dodoc "${HTTP_ECHO_MODULE_WD}"/{README.markdown,doc/HttpEchoModule.wiki} |
642 |
fi |
643 |
|
644 |
if use nginx_modules_http_security; then |
645 |
docinto ${HTTP_SECURITY_MODULE_P} |
646 |
dodoc "${HTTP_SECURITY_MODULE_WD}"/{CHANGES,README.TXT,authors.txt} |
647 |
fi |
648 |
|
649 |
if use nginx_modules_http_push_stream; then |
650 |
docinto ${HTTP_PUSH_STREAM_MODULE_P} |
651 |
dodoc "${HTTP_PUSH_STREAM_MODULE_WD}"/{AUTHORS,CHANGELOG.textile,README.textile} |
652 |
fi |
653 |
|
654 |
if use nginx_modules_http_sticky; then |
655 |
docinto ${HTTP_STICKY_MODULE_P} |
656 |
dodoc "${HTTP_STICKY_MODULE_WD}"/{README.md,Changelog.txt,docs/sticky.pdf} |
657 |
fi |
658 |
|
659 |
if use nginx_modules_http_memc; then |
660 |
docinto ${HTTP_MEMC_MODULE_P} |
661 |
dodoc "${HTTP_MEMC_MODULE_WD}"/README.markdown |
662 |
fi |
663 |
} |
664 |
|
665 |
pkg_postinst() { |
666 |
if use ssl; then |
667 |
if [ ! -f "${EROOT}"etc/ssl/${PN}/${PN}.key ]; then |
668 |
install_cert /etc/ssl/${PN}/${PN} |
669 |
use prefix || chown ${PN}:${PN} "${EROOT}"etc/ssl/${PN}/${PN}.{crt,csr,key,pem} |
670 |
fi |
671 |
fi |
672 |
|
673 |
if use nginx_modules_http_spdy; then |
674 |
ewarn "In nginx 1.9.5 the spdy module was superseded by http2." |
675 |
ewarn "Update your configs and package.use accordingly." |
676 |
fi |
677 |
|
678 |
if use nginx_modules_http_lua && use http2; then |
679 |
ewarn "Lua 3rd party module author warns against using ${P} with" |
680 |
ewarn "NGINX_MODULES_HTTP=\"lua http2\". For more info, see http://git.io/OldLsg" |
681 |
fi |
682 |
|
683 |
# This is the proper fix for bug #458726/#469094, resp. CVE-2013-0337 for |
684 |
# existing installations |
685 |
local fix_perms=0 |
686 |
|
687 |
for rv in ${REPLACING_VERSIONS} ; do |
688 |
version_compare ${rv} 1.4.1-r2 |
689 |
[[ $? -eq 1 ]] && fix_perms=1 |
690 |
done |
691 |
|
692 |
if [[ $fix_perms -eq 1 ]] ; then |
693 |
ewarn "To fix a security bug (CVE-2013-0337, bug #458726) had the following" |
694 |
ewarn "directories the world-readable bit removed (if set):" |
695 |
ewarn " ${EPREFIX}/var/log/nginx" |
696 |
ewarn " ${EPREFIX}${NGINX_HOME_TMP}/{,client,proxy,fastcgi,scgi,uwsgi}" |
697 |
ewarn "Check if this is correct for your setup before restarting nginx!" |
698 |
ewarn "This is a one-time change and will not happen on subsequent updates." |
699 |
ewarn "Furthermore nginx' temp directories got moved to ${NGINX_HOME_TMP}" |
700 |
chmod -f o-rwx "${EPREFIX}"/var/log/nginx "${EPREFIX}${NGINX_HOME_TMP}"/{,client,proxy,fastcgi,scgi,uwsgi} |
701 |
fi |
702 |
|
703 |
# If the nginx user can't change into or read the dir, display a warning. |
704 |
# If su is not available we display the warning nevertheless since we can't check properly |
705 |
su -s /bin/sh -c 'cd /var/log/nginx/ && ls' nginx >&/dev/null |
706 |
if [ $? -ne 0 ] ; then |
707 |
ewarn "Please make sure that the nginx user or group has at least" |
708 |
ewarn "'rx' permissions on /var/log/nginx (default on a fresh install)" |
709 |
ewarn "Otherwise you end up with empty log files after a logrotate." |
710 |
fi |
711 |
} |