Skip to content

Instantly share code, notes, and snippets.

@rabbitt
Last active August 29, 2015 14:25
Show Gist options
  • Save rabbitt/9cd7d674f9f499d2f1e3 to your computer and use it in GitHub Desktop.
Save rabbitt/9cd7d674f9f499d2f1e3 to your computer and use it in GitHub Desktop.
nginx portfile adding +subs variant (which compiles in http://wiki.nginx.org/HttpSubsModule)
# -*- 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
# $Id: Portfile 135802 2015-05-03 21:53:49Z cal@macports.org $
PortSystem 1.0
name nginx
version 1.9.0
categories www mail
platforms darwin
license BSD
maintainers cal openmaintainer
description High-performance HTTP(S) server, HTTP(S) reverse proxy and IMAP/POP3 proxy server
long_description \
Nginx ("engine x") is a high-performance HTTP(S) server and reverse proxy, \
as well as an IMAP/POP3 proxy server. Nginx was written by Igor Sysoev for \
Rambler.ru, Russia's second-most visited website, where it has been running \
in production for over two and a half years. Igor has released the source \
code under a BSD-like license. Although still in beta, Nginx is known for \
its stability, rich feature set, simple configuration, and low resource \
consumption.
homepage http://nginx.org/
master_sites http://nginx.org/download:nginx \
http://www.grid.net.ru/nginx/download/:upload_module \
googlecode:mod-zip:zip_module \
http://people.freebsd.org/~osa/:redis_module \
https://github.com/masterzen/nginx-upload-progress-module/archive/:uploadprogress_module \
https://github.com/arut/nginx-dav-ext-module/archive/:davext_module \
https://github.com/arut/nginx-rtmp-module/archive/:rtmp_module \
https://github.com/slact/nginx_http_push_module/archive/:http_push_module \
https://github.com/simpl/ngx_devel_kit/archive/:devel_kit_module \
https://github.com/openresty/lua-nginx-module/archive/:lua_module \
https://github.com/yaoweibin/ngx_http_substitutions_filter_module/archive/:subs_module
distfiles ${name}-${version}${extract.suffix}:nginx
checksums ${name}-${version}${extract.suffix} \
rmd160 348d9d708e3988139808586b2027a492078e3dd2 \
sha256 e12aa1d5b701edde880ebcc7be47ca171c3fbeed8fa7c8c62054a6f19d27f248
depends_lib port:pcre \
port:zlib
patchfiles patch-auto__install.diff \
patch-conf__nginx.conf.diff
set nginx_share ${prefix}/share/${name}
set nginx_examples ${nginx_share}/examples
set nginx_confdir ${prefix}/etc/${name}
set nginx_logdir ${prefix}/var/log/${name}
set nginx_rundir ${prefix}/var/run/${name}
set nginx_pidfile ${nginx_rundir}/${name}.pid
set nginx_all_confs {fastcgi.conf fastcgi_params mime.types nginx.conf scgi_params uwsgi_params}
set auto_activate_confs {nginx.conf mime.types fastcgi_params}
# portfile-scoped vars for variant routines to re-def and use in port-stages (post-extract, pre-patch, etc)
set nginx_upload_mod_dirname ""
# for aforementioned re-defs of portfile-scoped vars in variant routines
proc nginx_set_portfile_var {var_name new_value} {
upvar $var_name portfile_var
set portfile_var $new_value
}
configure.args-append \
--with-cc-opt=\"${configure.cppflags} ${configure.cflags}\" \
--with-ld-opt=\"${configure.ldflags}\" \
--conf-path=${nginx_confdir}/${name}.conf \
--error-log-path=${nginx_logdir}/error.log \
--http-log-path=${nginx_logdir}/access.log \
--pid-path=${nginx_pidfile} \
--lock-path=${nginx_rundir}/${name}.lock \
--http-client-body-temp-path=${nginx_rundir}/client_body_temp \
--http-proxy-temp-path=${nginx_rundir}/proxy_temp \
--http-fastcgi-temp-path=${nginx_rundir}/fastcgi_temp \
--http-uwsgi-temp-path=${nginx_rundir}/uwsgi_temp \
--with-ipv6
# remove --disable-dependency-tracking
configure.universal_args-delete --disable-dependency-tracking
build.target build
destroot.keepdirs ${destroot}${nginx_logdir} \
${destroot}${nginx_rundir}
post-destroot {
xinstall -d -m 755 ${destroot}${nginx_share}
xinstall -d -m 755 ${destroot}${nginx_examples}
foreach conf ${nginx_all_confs} {
set conf_path "${destroot}${nginx_confdir}/${conf}"
if {[file exists ${conf_path}]} {
file delete ${conf_path}
}
if {[file exists ${conf_path}.default]} {
move ${conf_path}.default ${destroot}${nginx_examples}
}
}
file rename ${destroot}${prefix}/html ${destroot}${nginx_share}
}
post-activate {
foreach conf ${auto_activate_confs} {
if {![file exists ${nginx_confdir}/${conf}]} {
xinstall -m 644 ${nginx_examples}/${conf}.default ${nginx_confdir}/${conf}
}
}
}
startupitem.create yes
startupitem.pidfile auto ${nginx_pidfile}
startupitem.executable ${prefix}/sbin/nginx
notes "\
A set of sample configuration files has been installed in ${nginx_examples}.\n\n\
Additionally, the files [join ${auto_activate_confs} ", "] have been copied to ${nginx_confdir} if they didn't exist yet.\n\
Adjust these files to your needs before starting nginx."
default_variants +mp4 +flv +secure_link +ssl
variant addition description {Append text to pages} {
configure.args-append --with-http_addition_module
}
variant dav description {Add WebDAV support to server} {
configure.args-append --with-http_dav_module
}
variant davext description {Add WebDAV (extended) support to server} {
set davext_filename nginx-dav-ext-module
set davext_version 0.0.3
set davext_distname ${davext_filename}-${davext_version}
distfiles-append v${davext_version}.tar.gz:davext_module
checksums-append v${davext_version}.tar.gz \
rmd160 0d407e687bd59e81c2c9805ee8b39b8b85d43d08 \
sha256 d428a0236c933779cb40ac8c91afb19d5c25a376dc3caab825bfd543e1ee530d
configure.args-append --with-http_dav_module --add-module=${workpath}/${davext_distname}
}
variant debug description {Enable debug mode} {
configure.args-append --with-debug
}
variant degradation description {Allow to return 204 or 444 code for some locations on low memory condition} {
configure.args-append --with-http_degradation_module
}
variant flv description {Add FLV (Flash Video) streaming support to server} {
configure.args-append --with-http_flv_module
}
variant geoip description {Enable Ngx http GeoIP module (http://wiki.nginx.org/HttpGeoIPModule)} {
configure.args-append --with-http_geoip_module
depends_lib-append port:libgeoip
}
variant google_perftools description {Enable Google Performance Tools profiling for workers} {
configure.args-append --with-google_perftools_module
depends_lib-append port:google-perftools
# If 'google_perftools' port doesn't find headers needed for the profiler lib, it just quietly skips it.
# Check if "-lprofiler" will fail -- if so, pre-empt configure-stage error with a more useful error msg.
pre-configure {
if {![file exists "${prefix}/lib/libprofiler.dylib"] && ![file exists "${prefix}/lib/libprofiler.a"]} {
ui_error "\
The 'google-perftools' port did not install a libprofiler library (libprofiler.dylib or\
libprofiler.a) on your version of OS X, but the +google_perftools variant will not work\
without this library. Disable the +google_perftools variant to continue installing ${name}"
error "Required libprofiler library missing from google-perftools port."
}
}
}
variant gzip_static description {Avoids compressing the same file each time it is requested} {
configure.args-append --with-http_gzip_static_module
}
variant image_filter description {Transform images with libgd} {
configure.args-append --with-http_image_filter_module
depends_lib-append port:gd2
}
variant mail description {Add IMAP4/POP3 mail proxy support} {
configure.args-append --with-mail
if {[variant_isset ssl]} {
configure.args-append --with-mail_ssl_module
}
}
variant mp4 description {Enables mp4 streaming with seeking ability} {
configure.args-append --with-http_mp4_module
}
variant perl5 description {Add perl support to the server directly within nginx and call perl via SSI} {
depends_lib-append port:perl5.16
configure.args-append --with-http_perl_module \
--with-perl=${prefix}/bin/perl5.16
}
variant random_index description {Randomize directory indexes} {
configure.args-append --with-http_random_index_module
}
variant realip description {For using nginx as backend} {
configure.args-append --with-http_realip_module
}
variant secure_link description {Protect pages with a secret key} {
configure.args-append --with-http_secure_link_module
}
variant ssl description {Add SSL (HTTPS) support to the server, and also to the mail proxy if that is enabled} {
configure.args-append --with-http_ssl_module
depends_lib-append port:openssl
}
variant spdy requires ssl description {Add SPDY support to the server} {
configure.args-append --with-http_spdy_module
}
variant status description {Add /nginx_status support to the server} {
configure.args-append --with-http_stub_status_module
}
variant substitution description {Replace text in pages} {
configure.args-append --with-http_sub_module
}
variant stream description {Enable ngx_stream_core_module for generic TCP proxying and load balancing} {
configure.args-append --with-stream
}
variant upload description {Enable Valery Kholodkov's upload module (http://grid.net.ru/nginx/upload.en.html)} {
set upload_filename nginx_upload_module
set upload_version 2.2.0
set upload_distname ${upload_filename}-${upload_version}
distfiles-append ${upload_distname}.tar.gz:upload_module
checksums-append ${upload_distname}.tar.gz \
rmd160 5734af837be3fe8ec444a7e5e7f6707118594098 \
sha256 b1c26abe0427180602e257627b4ed21848c93cc20cefc33af084983767d65805
configure.args-append --add-module=${workpath}/${upload_distname}
# v2.2.0 release references members of ngx_http_request_body_t that were renamed in later nginx versions.
# Patch nginx_upload_module.c with fixed version from https://github.com/TimothyKlim/nginx-upload-module.
patchfiles-append patch-nginx_upload_module.tmp-ngx_http_upload_module.c.diff
nginx_set_portfile_var nginx_upload_mod_dirname "${upload_distname}"
pre-fetch {
ui_error "The +upload variant is currently broken, because the upload module is not compatible with nginx 1.9.0."
error "incompatible variant selection"
}
# patch routine balks on file names with "../", but rel-paths in patchfiles start from $worksrcpath
pre-patch {
ln -s "${workpath}/${nginx_upload_mod_dirname}" "${worksrcpath}/nginx_upload_module.tmp"
}
post-patch {
file delete "${worksrcpath}/nginx_upload_module.tmp"
}
}
variant upload_progress description {Enable Brice Figureau's upload progress module (https://github.com/masterzen/nginx-upload-progress-module)} {
set uploadprg_filename nginx_uploadprogress_module
set uploadprg_version 0.9.1
set uploadprg_distname v${uploadprg_version}
distfiles-append ${uploadprg_distname}.tar.gz:uploadprogress_module
checksums-append ${uploadprg_distname}.tar.gz \
rmd160 4810c8588d7fba9dc0130ec67ffe7e3ef27a2dd5 \
sha256 99ec072cca35cd7791e77c40a8ded41a7a8c1111e057be26e55fba2fdf105f43
configure.args-append --add-module=${workpath}/nginx-upload-progress-module-${uploadprg_version}
}
variant xslt description {Post-process pages with XSLT} {
configure.args-append --with-http_xslt_module
depends_lib-append port:libxslt
}
variant zip description {Enable Ngx zip download module \
(http://code.google.com/p/mod-zip/)} {
set zip_distname mod_zip-1.1.6
distfiles-append ${zip_distname}.tar.gz:zip_module
checksums-append ${zip_distname}.tar.gz \
rmd160 17a465d87b8e1ba71bdd6ad40e20d21cc7dcd434 \
sha256 d30546b4be8308c721df0240ebc38c474c6b577381a110321eded6dbed5104b1
configure.args-append --add-module=${workpath}/${zip_distname}
}
variant redis description {Enable Ngx HTTP Redis module} {
set redis_filename ngx_http_redis
set redis_version 0.3.7
set redis_distname ${redis_filename}-${redis_version}
distfiles-append ${redis_distname}.tar.gz:redis_module
checksums-append ${redis_distname}.tar.gz \
rmd160 c63731371c547f67f4dd8a222ce0fad6ea67632f \
sha256 9dfc14db81f431fdf3d69f3661a37daf110aef5f9479aa7c88cf362bb5d62604
configure.args-append --add-module=${workpath}/${redis_distname}
}
variant rtmp description {Enable Ngx RTMP module (https://github.com/arut/nginx-rtmp-module)} {
set rtmp_filename nginx-rtmp-module
set rtmp_version 1.1.7
set rtmp_distname ${rtmp_filename}-${rtmp_version}
distfiles-append v${rtmp_version}.tar.gz:rtmp_module
checksums-append v${rtmp_version}.tar.gz \
rmd160 3b7510fba6f6e572f0fb0b3676fe1eb4d4caecb1 \
sha256 7922b0e3d5f3d9c4b275e4908cfb8f5fb1bfb3ac2df77f4c262cda56df21aab3
configure.args-append --add-module=${workpath}/${rtmp_distname}
}
variant http_push description {Enable Ngx HTTP Push module (https://github.com/slact/nginx_http_push_module)} {
set http_push_filename nginx_http_push_module
set http_push_version 0.73
set http_push_distname ${http_push_filename}-${http_push_version}
distfiles-append v${http_push_version}.tar.gz:http_push_module
checksums-append v${http_push_version}.tar.gz \
rmd160 4614b35edb7d1fe9e367d769f4c7e39589d3fae2 \
sha256 a2a5b53a847493abef89c27360460997bea2b01d1394a7a612f1e13e4cfbb98a
configure.args-append --add-module=${workpath}/${http_push_distname}
}
variant devel_kit description {Enable ngx_devel_kit module (https://github.com/simpl/ngx_devel_kit)} {
set devel_kit_filename ngx_devel_kit
set devel_kit_version 0.2.19
set devel_kit_distname ${devel_kit_filename}-${devel_kit_version}
distfiles-append v${devel_kit_version}.tar.gz:devel_kit_module
checksums-append v${devel_kit_version}.tar.gz \
rmd160 64d3737bc4cc948c1363cce80d70e5260878811e \
sha256 501f299abdb81b992a980bda182e5de5a4b2b3e275fbf72ee34dd7ae84c4b679
configure.args-append --add-module=${workpath}/${devel_kit_distname}
}
variant lua requires devel_kit description {Enable Lua module (https://github.com/openresty/lua-nginx-module)} {
depends_lib-append port:luajit
set ngx_lua_filename lua-nginx-module
set ngx_lua_version 0.9.16rc1
set ngx_lua_distname ${ngx_lua_filename}-${ngx_lua_version}
distfiles-append v${ngx_lua_version}.tar.gz:lua_module
checksums-append v${ngx_lua_version}.tar.gz \
rmd160 b992137a8d9b6ada437ec9016cebae123e51c4ad \
sha256 edde780f227089c41f6feab56217803c6d8347d82b0ffe99b95fd2217828595b
configure.cflags -I${prefix}/include/luajit-2.0/ ${configure.cflags}
configure.env LUAJIT_INC=${prefix}/include/luajit-2.0/
configure.env LUAJIT_LIB=${prefix}/lib
configure.args-append --add-module=${workpath}/${ngx_lua_distname}
pre-fetch {
ui_error "The +lua variant is currently broken, because the lua module is not compatible with nginx 1.9.0."
error "incompatible variant selection"
}
}
variant subs description {Enable HttpSubsModule (http://wiki.nginx.org/HttpSubsModule)} {
set subs_filename ngx_http_substitutions_filter_module
set subs_version 131c030cbb284c7eb22a1c5184236d0983391441
set subs_distname ${subs_filename}-${subs_version}
distfiles-append ${subs_version}.tar.gz:subs_module
checksums-append ${subs_version}.tar.gz \
rmd160 02e976f6e58ef454b5e87a3f89025181f651d41d \
sha256 ed60c67318e9b726cfb227cab642820a6fc5070075a9b429a781d1c44f3f9a2e
configure.args-append --add-module=${workpath}/${subs_distname}
# pre-fetch {
# ui_error "The +lua variant is currently broken, because the lua module is not compatible with nginx 1.9.0."
# error "incompatible variant selection"
# }
}
livecheck.type regexm
livecheck.url ${homepage}
livecheck.regex {nginx-(\d+\.\d+\.\d+)</a>\s+mainline}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment