source: trunk/dports/www/nginx/Portfile @ 125959

Last change on this file since 125959 was 125928, checked in by cal@…, 5 years ago

nginx: fix activation

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 15.4 KB
Line 
1# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
2# $Id: Portfile 125928 2014-09-29 19:58:38Z cal@macports.org $
3
4PortSystem          1.0
5
6name                nginx
7version             1.7.5
8revision            1
9categories          www mail
10platforms           darwin
11license             BSD
12maintainers         cal openmaintainer
13
14description         High-performance HTTP(S) server, HTTP(S) reverse proxy and IMAP/POP3 proxy server
15long_description    \
16    Nginx ("engine x") is a high-performance HTTP(S) server and reverse proxy, \
17    as well as an IMAP/POP3 proxy server. Nginx was written by Igor Sysoev for \
18    Rambler.ru, Russia's second-most visited website, where it has been running \
19    in production for over two and a half years. Igor has released the source \
20    code under a BSD-like license. Although still in beta, Nginx is known for \
21    its stability, rich feature set, simple configuration, and low resource \
22    consumption.
23
24homepage            http://nginx.org/
25master_sites        http://nginx.org/download:nginx \
26                    http://www.grid.net.ru/nginx/download/:upload_module \
27                    googlecode:mod-zip:zip_module \
28                    http://people.freebsd.org/~osa/:redis_module \
29                    https://github.com/masterzen/nginx-upload-progress-module/archive/:uploadprogress_module \
30                    https://github.com/arut/nginx-dav-ext-module/archive/:davext_module \
31                    https://github.com/arut/nginx-rtmp-module/archive/:rtmp_module \
32                    https://github.com/slact/nginx_http_push_module/archive/:http_push_module \
33                    https://github.com/simpl/ngx_devel_kit/archive/:devel_kit_module \
34                    https://github.com/openresty/lua-nginx-module/archive/:lua_module
35
36distfiles           ${name}-${version}${extract.suffix}:nginx
37checksums           ${name}-${version}${extract.suffix} \
38                    rmd160  4bd7b1c8a39eb366548a31073249b5bb4baac498 \
39                    sha256  d670006fbeca226d1dd18ad749d9fe6f8b18642f94de3377e0ac69a660e3ca9b
40
41depends_lib         port:pcre \
42                    port:zlib
43
44patchfiles          patch-auto__install.diff \
45                    patch-conf__nginx.conf.diff
46
47set nginx_share     ${prefix}/share/${name}
48set nginx_examples  ${nginx_share}/examples
49set nginx_confdir   ${prefix}/etc/${name}
50set nginx_logdir    ${prefix}/var/log/${name}
51set nginx_rundir    ${prefix}/var/run/${name}
52set nginx_pidfile   ${nginx_rundir}/${name}.pid
53set nginx_all_confs {fastcgi.conf fastcgi_params mime.types nginx.conf scgi_params uwsgi_params}
54set auto_activate_confs {nginx.conf mime.types fastcgi_params}
55
56# portfile-scoped vars for variant routines to re-def and use in port-stages (post-extract, pre-patch, etc)
57set nginx_upload_mod_dirname   ""
58
59# for aforementioned re-defs of portfile-scoped vars in variant routines
60proc nginx_set_portfile_var {var_name new_value} {
61    upvar   $var_name   portfile_var
62    set portfile_var   $new_value
63}
64
65
66configure.args-append \
67                    --with-cc-opt=\"${configure.cppflags} ${configure.cflags}\" \
68                    --with-ld-opt=\"${configure.ldflags}\" \
69                    --conf-path=${nginx_confdir}/${name}.conf \
70                    --error-log-path=${nginx_logdir}/error.log \
71                    --http-log-path=${nginx_logdir}/access.log \
72                    --pid-path=${nginx_pidfile} \
73                    --lock-path=${nginx_rundir}/${name}.lock \
74                    --http-client-body-temp-path=${nginx_rundir}/client_body_temp \
75                    --http-proxy-temp-path=${nginx_rundir}/proxy_temp \
76                    --http-fastcgi-temp-path=${nginx_rundir}/fastcgi_temp \
77                    --http-uwsgi-temp-path=${nginx_rundir}/uwsgi_temp \
78                    --with-ipv6
79
80# remove --disable-dependency-tracking
81configure.universal_args-delete   --disable-dependency-tracking
82
83build.target        build
84destroot.keepdirs   ${destroot}${nginx_logdir} \
85                    ${destroot}${nginx_rundir}
86
87post-destroot {
88    xinstall -d -m 755 ${destroot}${nginx_share}
89    xinstall -d -m 755 ${destroot}${nginx_examples}
90
91    foreach conf ${nginx_all_confs} {
92        set conf_path "${destroot}${nginx_confdir}/${conf}"
93        if {[file exists ${conf_path}]} {
94            file delete ${conf_path}
95        }
96        if {[file exists ${conf_path}.default]} {
97            move ${conf_path}.default ${destroot}${nginx_examples}
98        }
99    }
100
101    file rename ${destroot}${prefix}/html ${destroot}${nginx_share}
102}
103
104post-activate {
105    foreach conf ${auto_activate_confs} {
106        if {![file exists ${nginx_confdir}/${conf}]} {
107            xinstall -m 644 ${nginx_examples}/${conf}.default ${nginx_confdir}/${conf}
108        }
109    }
110}
111
112startupitem.create      yes
113startupitem.pidfile     auto ${nginx_pidfile}
114startupitem.executable  ${prefix}/sbin/nginx
115
116notes "\
117    A set of sample configuration files has been installed in ${nginx_examples}.\n\n\
118    Additionally, the files [join ${auto_activate_confs} ", "] have been copied to ${nginx_confdir} if they didn't exist yet.\n\
119    Adjust these files to your needs before starting nginx."
120
121variant addition description {Append text to pages} {
122    configure.args-append   --with-http_addition_module
123}
124
125variant dav description {Add WebDAV support to server} {
126    configure.args-append   --with-http_dav_module
127}
128
129variant davext description {Add WebDAV (extended) support to server} {
130    set davext_filename     nginx-dav-ext-module
131    set davext_version      0.0.3
132    set davext_distname     ${davext_filename}-${davext_version}
133    distfiles-append        v${davext_version}.tar.gz:davext_module
134    checksums-append        v${davext_version}.tar.gz \
135                            rmd160  0d407e687bd59e81c2c9805ee8b39b8b85d43d08 \
136                            sha256  d428a0236c933779cb40ac8c91afb19d5c25a376dc3caab825bfd543e1ee530d
137    configure.args-append   --with-http_dav_module --add-module=${workpath}/${davext_distname}
138}
139
140variant debug description {Enable debug mode} {
141    configure.args-append   --with-debug
142}
143
144variant degradation description {Allow to return 204 or 444 code for some locations on low memory condition} {
145    configure.args-append   --with-http_degradation_module
146}
147
148variant flv description {Add FLV (Flash Video) streaming support to server} {
149    configure.args-append   --with-http_flv_module
150}
151
152variant geoip description {Enable Ngx http GeoIP module (http://wiki.nginx.org/HttpGeoIPModule)} {
153    configure.args-append   --with-http_geoip_module
154    depends_lib-append      port:libgeoip
155}
156
157variant google_perftools description {Enable Google Performance Tools profiling for workers} {
158    configure.args-append   --with-google_perftools_module
159    depends_lib-append      port:google-perftools
160
161    # If 'google_perftools' port doesn't find headers needed for the profiler lib, it just quietly skips it.
162    # Check if "-lprofiler" will fail -- if so, pre-empt configure-stage error with a more useful error msg.
163    pre-configure {
164        if {![file exists "${prefix}/lib/libprofiler.dylib"] && ![file exists "${prefix}/lib/libprofiler.a"]} {
165            ui_error "\
166                The 'google-perftools' port did not install a libprofiler library (libprofiler.dylib or\
167                libprofiler.a) on your version of OS X, but the +google_perftools variant will not work\
168                without this library. Disable the +google_perftools variant to continue installing ${name}"
169            error "Required libprofiler library missing from google-perftools port."
170        }
171    }
172}
173
174variant gzip_static description {Avoids compressing the same file each time it is requested} {
175    configure.args-append   --with-http_gzip_static_module
176}
177
178variant image_filter description {Transform images with libgd} {
179    configure.args-append   --with-http_image_filter_module
180    depends_lib-append      port:gd2
181}
182
183variant mail description {Add IMAP4/POP3 mail proxy support} {
184    configure.args-append   --with-mail
185    if {[variant_isset ssl]} {
186        configure.args-append   --with-mail_ssl_module
187    }
188}
189
190variant mp4 description {Enables mp4 streaming with seeking ability} {
191    configure.args-append   --with-http_mp4_module
192}
193
194variant perl5 description {Add perl support to the server directly within nginx and call perl via SSI} {
195    depends_lib-append      port:perl5.16
196    configure.args-append   --with-http_perl_module \
197                            --with-perl=${prefix}/bin/perl5.16
198}
199
200variant random_index description {Randomize directory indexes} {
201    configure.args-append   --with-http_random_index_module
202}
203
204variant realip description {For using nginx as backend} {
205    configure.args-append   --with-http_realip_module
206}
207
208variant secure_link description {Protect pages with a secret key} {
209    configure.args-append   --with-http_secure_link_module
210}
211
212variant ssl description {Add SSL (HTTPS) support to the server, and also to the mail proxy if that is enabled} {
213    configure.args-append   --with-http_ssl_module
214    depends_lib-append      port:openssl
215}
216
217variant spdy requires ssl description {Add SPDY support to the server} {
218    configure.args-append   --with-http_spdy_module
219}
220
221variant status description {Add /nginx_status support to the server} {
222    configure.args-append   --with-http_stub_status_module
223}
224
225variant substitution description {Replace text in pages} {
226    configure.args-append   --with-http_sub_module
227}
228
229variant upload description {Enable Valery Kholodkov's upload module (http://grid.net.ru/nginx/upload.en.html)} {
230    set upload_filename     nginx_upload_module
231    set upload_version      2.2.0
232    set upload_distname     ${upload_filename}-${upload_version}
233    distfiles-append        ${upload_distname}.tar.gz:upload_module
234    checksums-append        ${upload_distname}.tar.gz \
235                            rmd160  5734af837be3fe8ec444a7e5e7f6707118594098 \
236                            sha256  b1c26abe0427180602e257627b4ed21848c93cc20cefc33af084983767d65805
237    configure.args-append   --add-module=${workpath}/${upload_distname}
238
239    # v2.2.0 release references members of ngx_http_request_body_t that were renamed in later nginx versions.
240    # Patch nginx_upload_module.c with fixed version from https://github.com/TimothyKlim/nginx-upload-module.
241    patchfiles-append       patch-nginx_upload_module.tmp-ngx_http_upload_module.c.diff
242
243
244    nginx_set_portfile_var   nginx_upload_mod_dirname    "${upload_distname}"
245
246    # patch routine balks on file names with "../", but rel-paths in patchfiles start from $worksrcpath
247    pre-patch {
248        ln -s   "${workpath}/${nginx_upload_mod_dirname}" "${worksrcpath}/nginx_upload_module.tmp"
249    }
250    post-patch {
251        file delete   "${worksrcpath}/nginx_upload_module.tmp"
252    }
253}
254
255variant upload_progress description {Enable Brice Figureau's upload progress module (https://github.com/masterzen/nginx-upload-progress-module)} {
256    set uploadprg_filename  nginx_uploadprogress_module
257    set uploadprg_version   0.9.1
258    set uploadprg_distname  v${uploadprg_version}
259    distfiles-append        ${uploadprg_distname}.tar.gz:uploadprogress_module
260    checksums-append        ${uploadprg_distname}.tar.gz \
261                            rmd160  4810c8588d7fba9dc0130ec67ffe7e3ef27a2dd5 \
262                            sha256  99ec072cca35cd7791e77c40a8ded41a7a8c1111e057be26e55fba2fdf105f43
263    configure.args-append   --add-module=${workpath}/nginx-upload-progress-module-${uploadprg_version}
264}
265
266variant xslt description {Post-process pages with XSLT} {
267    configure.args-append   --with-http_xslt_module
268
269    depends_lib-append      port:libxslt
270}
271
272variant zip description {Enable Ngx zip download module \
273        (http://code.google.com/p/mod-zip/)} {
274
275    set zip_distname        mod_zip-1.1.6
276    distfiles-append        ${zip_distname}.tar.gz:zip_module
277    checksums-append        ${zip_distname}.tar.gz \
278                            rmd160  17a465d87b8e1ba71bdd6ad40e20d21cc7dcd434 \
279                            sha256  d30546b4be8308c721df0240ebc38c474c6b577381a110321eded6dbed5104b1
280    configure.args-append   --add-module=${workpath}/${zip_distname}
281}
282
283variant redis description {Enable Ngx HTTP Redis module} {
284    set redis_filename      ngx_http_redis
285    set redis_version       0.3.7
286    set redis_distname      ${redis_filename}-${redis_version}
287    distfiles-append        ${redis_distname}.tar.gz:redis_module
288    checksums-append        ${redis_distname}.tar.gz \
289                            rmd160  c63731371c547f67f4dd8a222ce0fad6ea67632f \
290                            sha256  9dfc14db81f431fdf3d69f3661a37daf110aef5f9479aa7c88cf362bb5d62604
291    configure.args-append   --add-module=${workpath}/${redis_distname}
292}
293
294variant rtmp description {Enable Ngx RTMP module (https://github.com/arut/nginx-rtmp-module)} {
295    set rtmp_filename       nginx-rtmp-module
296    # currently broken with 1.7.5
297    set rtmp_version        1.1.5
298    set rtmp_distname       ${rtmp_filename}-${rtmp_version}
299    distfiles-append        v${rtmp_version}.tar.gz:rtmp_module
300    checksums-append        v${rtmp_version}.tar.gz \
301                            rmd160  7ef95c413c86ffc84764cdc85c8c1a47182f866e \
302                            sha256  990467fed853b8eecd9b1b10050e2406071d705896be452539be8eced24adf4a
303    configure.args-append   --add-module=${workpath}/${rtmp_distname}
304}
305
306variant http_push description {Enable Ngx HTTP Push module (https://github.com/slact/nginx_http_push_module)} {
307    set http_push_filename  nginx_http_push_module
308    set http_push_version   0.73
309    set http_push_distname  ${http_push_filename}-${http_push_version}
310    distfiles-append        v${http_push_version}.tar.gz:http_push_module
311    checksums-append        v${http_push_version}.tar.gz \
312                            rmd160  4614b35edb7d1fe9e367d769f4c7e39589d3fae2 \
313                            sha256  a2a5b53a847493abef89c27360460997bea2b01d1394a7a612f1e13e4cfbb98a
314    configure.args-append   --add-module=${workpath}/${http_push_distname}
315}
316
317variant devel_kit description {Enable ngx_devel_kit module (https://github.com/simpl/ngx_devel_kit)} {
318    set devel_kit_filename    ngx_devel_kit
319    set devel_kit_version     0.2.19
320    set devel_kit_distname    ${devel_kit_filename}-${devel_kit_version}
321    distfiles-append          v${devel_kit_version}.tar.gz:devel_kit_module
322    checksums-append          v${devel_kit_version}.tar.gz \
323                              rmd160  64d3737bc4cc948c1363cce80d70e5260878811e \
324                              sha256  501f299abdb81b992a980bda182e5de5a4b2b3e275fbf72ee34dd7ae84c4b679
325
326    configure.args-append     --add-module=${workpath}/${devel_kit_distname}
327}
328
329variant lua requires devel_kit description {Enable Lua module (https://github.com/openresty/lua-nginx-module)} {
330    depends_lib-append      port:luajit
331    set ngx_lua_filename    lua-nginx-module
332    # currently broken with 1.7.5
333    set ngx_lua_version     0.9.12
334    set ngx_lua_distname    ${ngx_lua_filename}-${ngx_lua_version}
335    distfiles-append        v${ngx_lua_version}.tar.gz:lua_module
336    checksums-append        v${ngx_lua_version}.tar.gz \
337                            rmd160  5cbd0137e13efc9667069cd10856013a8c0155c9 \
338                            sha256  e85c1924ca4670d5708b58efcd6e77793c43f243317a9850a112964067f63150
339
340    configure.cflags        -I${prefix}/include/luajit-2.0/ ${configure.cflags}
341    configure.env           LUAJIT_INC=${prefix}/include/luajit-2.0/
342    configure.env           LUAJIT_LIB=${prefix}/lib
343    configure.args-append   --add-module=${workpath}/${ngx_lua_distname}
344}
345
346livecheck.type      regexm
347livecheck.url       ${homepage}
348livecheck.regex     {nginx-(\d+\.\d+\.\d+)</a>\s+mainline}
Note: See TracBrowser for help on using the repository browser.