| 1 |
# Copyright 1999-2012 Gentoo Foundation
|
| 2 |
# Distributed under the terms of the GNU General Public License v2
|
| 3 |
# $Header: /var/cvsroot/gentoo-x86/www-servers/nginx/nginx-1.2.1.ebuild,v 1.5 2012/07/30 06:29:23 hollow Exp $
|
| 4 |
|
| 5 |
EAPI="4"
|
| 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 |
# http_uploadprogress (https://github.com/masterzen/nginx-upload-progress-module, BSD-2 license)
|
| 21 |
HTTP_UPLOAD_PROGRESS_MODULE_PV="0.9.0"
|
| 22 |
HTTP_UPLOAD_PROGRESS_MODULE_P="ngx_upload_progress-${HTTP_UPLOAD_PROGRESS_MODULE_PV}"
|
| 23 |
HTTP_UPLOAD_PROGRESS_MODULE_SHA1="a788dea"
|
| 24 |
HTTP_UPLOAD_PROGRESS_MODULE_URI="http://github.com/masterzen/nginx-upload-progress-module/tarball/v${HTTP_UPLOAD_PROGRESS_MODULE_PV}"
|
| 25 |
|
| 26 |
# http_headers_more (http://github.com/agentzh/headers-more-nginx-module, BSD license)
|
| 27 |
HTTP_HEADERS_MORE_MODULE_PV="0.17rc1"
|
| 28 |
HTTP_HEADERS_MORE_MODULE_P="ngx_http_headers_more-${HTTP_HEADERS_MORE_MODULE_PV}"
|
| 29 |
HTTP_HEADERS_MORE_MODULE_SHA1="3580526"
|
| 30 |
HTTP_HEADERS_MORE_MODULE_URI="http://github.com/agentzh/headers-more-nginx-module/tarball/v${HTTP_HEADERS_MORE_MODULE_PV}"
|
| 31 |
|
| 32 |
# http_push (http://pushmodule.slact.net/, MIT license)
|
| 33 |
HTTP_PUSH_MODULE_PV="0.692"
|
| 34 |
HTTP_PUSH_MODULE_P="nginx_http_push_module-${HTTP_PUSH_MODULE_PV}"
|
| 35 |
HTTP_PUSH_MODULE_URI="http://pushmodule.slact.net/downloads/${HTTP_PUSH_MODULE_P}.tar.gz"
|
| 36 |
|
| 37 |
# http_cache_purge (http://labs.frickle.com/nginx_ngx_cache_purge/, BSD-2 license)
|
| 38 |
HTTP_CACHE_PURGE_MODULE_PV="1.5"
|
| 39 |
HTTP_CACHE_PURGE_MODULE_P="ngx_cache_purge-${HTTP_CACHE_PURGE_MODULE_PV}"
|
| 40 |
HTTP_CACHE_PURGE_MODULE_URI="http://labs.frickle.com/files/${HTTP_CACHE_PURGE_MODULE_P}.tar.gz"
|
| 41 |
|
| 42 |
# HTTP Upload module from Valery Kholodkov
|
| 43 |
# (http://www.grid.net.ru/nginx/upload.en.html, BSD license)
|
| 44 |
HTTP_UPLOAD_MODULE_PV="2.2.0"
|
| 45 |
HTTP_UPLOAD_MODULE_P="nginx_upload_module-${HTTP_UPLOAD_MODULE_PV}"
|
| 46 |
HTTP_UPLOAD_MODULE_URI="http://www.grid.net.ru/nginx/download/${HTTP_UPLOAD_MODULE_P}.tar.gz"
|
| 47 |
|
| 48 |
# http_slowfs_cache (http://labs.frickle.com/nginx_ngx_slowfs_cache/, BSD-2 license)
|
| 49 |
HTTP_SLOWFS_CACHE_MODULE_PV="1.8"
|
| 50 |
HTTP_SLOWFS_CACHE_MODULE_P="ngx_slowfs_cache-${HTTP_SLOWFS_CACHE_MODULE_PV}"
|
| 51 |
HTTP_SLOWFS_CACHE_MODULE_URI="http://labs.frickle.com/files/${HTTP_SLOWFS_CACHE_MODULE_P}.tar.gz"
|
| 52 |
|
| 53 |
# http_fancyindex_module (http://wiki.nginx.org/NgxFancyIndex, BSD license)
|
| 54 |
HTTP_FANCYINDEX_MODULE_PV="0.3.1"
|
| 55 |
HTTP_FANCYINDEX_MODULE_PN="ngx-fancyindex"
|
| 56 |
# gitorious names the tarbell oddly, hence PNPN
|
| 57 |
HTTP_FANCYINDEX_MODULE_PNPN="ngx-fancyindex-ngx-fancyindex"
|
| 58 |
HTTP_FANCYINDEX_MODULE_P="${HTTP_FANCYINDEX_MODULE_PN}-${HTTP_FANCYINDEX_MODULE_PV}"
|
| 59 |
HTTP_FANCYINDEX_MODULE_URI="http://gitorious.org/${HTTP_FANCYINDEX_MODULE_PN}/${HTTP_FANCYINDEX_MODULE_PN}/archive-tarball/v${HTTP_FANCYINDEX_MODULE_PV}"
|
| 60 |
|
| 61 |
inherit eutils ssl-cert toolchain-funcs perl-module flag-o-matic user
|
| 62 |
|
| 63 |
DESCRIPTION="Robust, small and high performance http and reverse proxy server"
|
| 64 |
HOMEPAGE="http://nginx.org"
|
| 65 |
SRC_URI="http://nginx.org/download/${P}.tar.gz
|
| 66 |
nginx_modules_http_upload_progress? ( ${HTTP_UPLOAD_PROGRESS_MODULE_URI} -> ${HTTP_UPLOAD_PROGRESS_MODULE_P}.tar.gz )
|
| 67 |
nginx_modules_http_headers_more? ( ${HTTP_HEADERS_MORE_MODULE_URI} -> ${HTTP_HEADERS_MORE_MODULE_P}.tar.gz )
|
| 68 |
nginx_modules_http_push? ( ${HTTP_PUSH_MODULE_URI} )
|
| 69 |
nginx_modules_http_cache_purge? ( ${HTTP_CACHE_PURGE_MODULE_URI} )
|
| 70 |
nginx_modules_http_upload? ( ${HTTP_UPLOAD_MODULE_URI} )
|
| 71 |
nginx_modules_http_slowfs_cache? ( ${HTTP_SLOWFS_CACHE_MODULE_URI} )
|
| 72 |
nginx_modules_http_fancyindex? ( ${HTTP_FANCYINDEX_MODULE_URI} -> ${HTTP_FANCYINDEX_MODULE_P}.tar.gz )"
|
| 73 |
|
| 74 |
LICENSE="as-is BSD BSD-2 GPL-2 MIT"
|
| 75 |
SLOT="0"
|
| 76 |
KEYWORDS="amd64 ~ppc x86 ~x86-fbsd ~amd64-linux ~x86-linux"
|
| 77 |
|
| 78 |
NGINX_MODULES_STD="access auth_basic autoindex browser charset empty_gif fastcgi
|
| 79 |
geo gzip limit_req limit_zone map memcached proxy referer rewrite scgi ssi
|
| 80 |
split_clients upstream_ip_hash userid uwsgi"
|
| 81 |
NGINX_MODULES_OPT="addition dav degradation flv geoip gzip_static image_filter
|
| 82 |
mp4 perl random_index realip secure_link stub_status sub xslt"
|
| 83 |
NGINX_MODULES_MAIL="imap pop3 smtp"
|
| 84 |
NGINX_MODULES_3RD="
|
| 85 |
http_upload_progress
|
| 86 |
http_headers_more
|
| 87 |
http_passenger
|
| 88 |
http_push
|
| 89 |
http_cache_purge
|
| 90 |
http_upload
|
| 91 |
http_slowfs_cache
|
| 92 |
http_fancyindex"
|
| 93 |
|
| 94 |
IUSE="aio debug +http +http-cache ipv6 libatomic +pcre pcre-jit selinux ssl vim-syntax"
|
| 95 |
|
| 96 |
for mod in $NGINX_MODULES_STD; do
|
| 97 |
IUSE="${IUSE} +nginx_modules_http_${mod}"
|
| 98 |
done
|
| 99 |
|
| 100 |
for mod in $NGINX_MODULES_OPT; do
|
| 101 |
IUSE="${IUSE} nginx_modules_http_${mod}"
|
| 102 |
done
|
| 103 |
|
| 104 |
for mod in $NGINX_MODULES_MAIL; do
|
| 105 |
IUSE="${IUSE} nginx_modules_mail_${mod}"
|
| 106 |
done
|
| 107 |
|
| 108 |
for mod in $NGINX_MODULES_3RD; do
|
| 109 |
IUSE="${IUSE} nginx_modules_${mod}"
|
| 110 |
done
|
| 111 |
|
| 112 |
CDEPEND="
|
| 113 |
pcre? ( >=dev-libs/libpcre-4.2 )
|
| 114 |
pcre-jit? ( >=dev-libs/libpcre-8.20[jit] )
|
| 115 |
selinux? ( sec-policy/selinux-nginx )
|
| 116 |
ssl? ( dev-libs/openssl )
|
| 117 |
http-cache? ( userland_GNU? ( dev-libs/openssl ) )
|
| 118 |
nginx_modules_http_geo? ( dev-libs/geoip )
|
| 119 |
nginx_modules_http_gzip? ( sys-libs/zlib )
|
| 120 |
nginx_modules_http_gzip_static? ( sys-libs/zlib )
|
| 121 |
nginx_modules_http_image_filter? ( media-libs/gd[jpeg,png] )
|
| 122 |
nginx_modules_http_perl? ( >=dev-lang/perl-5.8 )
|
| 123 |
nginx_modules_http_rewrite? ( >=dev-libs/libpcre-4.2 )
|
| 124 |
nginx_modules_http_secure_link? ( userland_GNU? ( dev-libs/openssl ) )
|
| 125 |
nginx_modules_http_xslt? ( dev-libs/libxml2 dev-libs/libxslt )"
|
| 126 |
RDEPEND="${CDEPEND}"
|
| 127 |
DEPEND="${CDEPEND}
|
| 128 |
arm? ( dev-libs/libatomic_ops )
|
| 129 |
libatomic? ( dev-libs/libatomic_ops )"
|
| 130 |
PDEPEND="vim-syntax? ( app-vim/nginx-syntax )"
|
| 131 |
REQUIRED_USE="pcre-jit? ( pcre )"
|
| 132 |
|
| 133 |
pkg_setup() {
|
| 134 |
if use nginx_modules_http_passenger; then
|
| 135 |
einfo
|
| 136 |
einfo "Passenger support has been removed from the nginx ebuild to"
|
| 137 |
einfo "get rid of file collisions, its broken build system and"
|
| 138 |
einfo "incompatibilities between passenger 2 and 3."
|
| 139 |
einfo
|
| 140 |
einfo "Please switch to passenger-3 standalone or use the"
|
| 141 |
einfo "unicorn gem which provides a sane nginx-like architecture"
|
| 142 |
einfo "out of the box."
|
| 143 |
einfo
|
| 144 |
einfo "For more information on sane ruby deployments with"
|
| 145 |
einfo "passenger-3/unicorn go to:"
|
| 146 |
einfo
|
| 147 |
einfo "https://rvm.beginrescueend.com"
|
| 148 |
einfo
|
| 149 |
die "nginx_modules_http_passenger still in IUSE"
|
| 150 |
fi
|
| 151 |
|
| 152 |
ebegin "Creating nginx user and group"
|
| 153 |
enewgroup ${PN}
|
| 154 |
enewuser ${PN} -1 -1 -1 ${PN}
|
| 155 |
eend $?
|
| 156 |
|
| 157 |
if use libatomic; then
|
| 158 |
ewarn "GCC 4.1+ features built-in atomic operations."
|
| 159 |
ewarn "Using libatomic_ops is only needed if using"
|
| 160 |
ewarn "a different compiler or a GCC prior to 4.1"
|
| 161 |
fi
|
| 162 |
|
| 163 |
if [[ -n $NGINX_ADD_MODULES ]]; then
|
| 164 |
ewarn "You are building custom modules via \$NGINX_ADD_MODULES!"
|
| 165 |
ewarn "This nginx installation is not supported!"
|
| 166 |
ewarn "Make sure you can reproduce the bug without those modules"
|
| 167 |
ewarn "_before_ reporting bugs."
|
| 168 |
fi
|
| 169 |
|
| 170 |
if use !http; then
|
| 171 |
ewarn "To actually disable all http-functionality you also have to disable"
|
| 172 |
ewarn "all nginx http modules."
|
| 173 |
fi
|
| 174 |
}
|
| 175 |
|
| 176 |
src_prepare() {
|
| 177 |
find auto/ -type f -print0 | xargs -0 sed -i 's:\&\& make:\&\& \\$(MAKE):' || die
|
| 178 |
# We have config protection, don't rename etc files
|
| 179 |
sed -i 's:.default::' auto/install || die
|
| 180 |
# remove useless files
|
| 181 |
sed -i -e '/koi-/d' -e '/win-/d' auto/install || die
|
| 182 |
}
|
| 183 |
|
| 184 |
src_configure() {
|
| 185 |
local myconf= http_enabled= mail_enabled=
|
| 186 |
|
| 187 |
use aio && myconf+=" --with-file-aio --with-aio_module"
|
| 188 |
use debug && myconf+=" --with-debug"
|
| 189 |
use ipv6 && myconf+=" --with-ipv6"
|
| 190 |
use libatomic && myconf+=" --with-libatomic"
|
| 191 |
use pcre && myconf+=" --with-pcre"
|
| 192 |
use pcre-jit && myconf+=" --with-pcre-jit"
|
| 193 |
|
| 194 |
# HTTP modules
|
| 195 |
for mod in $NGINX_MODULES_STD; do
|
| 196 |
if use nginx_modules_http_${mod}; then
|
| 197 |
http_enabled=1
|
| 198 |
else
|
| 199 |
myconf+=" --without-http_${mod}_module"
|
| 200 |
fi
|
| 201 |
done
|
| 202 |
|
| 203 |
for mod in $NGINX_MODULES_OPT; do
|
| 204 |
if use nginx_modules_http_${mod}; then
|
| 205 |
http_enabled=1
|
| 206 |
myconf+=" --with-http_${mod}_module"
|
| 207 |
fi
|
| 208 |
done
|
| 209 |
|
| 210 |
if use nginx_modules_http_fastcgi; then
|
| 211 |
myconf+=" --with-http_realip_module"
|
| 212 |
fi
|
| 213 |
|
| 214 |
# third-party modules
|
| 215 |
if use nginx_modules_http_upload_progress; then
|
| 216 |
http_enabled=1
|
| 217 |
myconf+=" --add-module=${WORKDIR}/masterzen-nginx-upload-progress-module-${HTTP_UPLOAD_PROGRESS_MODULE_SHA1}"
|
| 218 |
fi
|
| 219 |
|
| 220 |
if use nginx_modules_http_headers_more; then
|
| 221 |
http_enabled=1
|
| 222 |
myconf+=" --add-module=${WORKDIR}/agentzh-headers-more-nginx-module-${HTTP_HEADERS_MORE_MODULE_SHA1}"
|
| 223 |
fi
|
| 224 |
|
| 225 |
if use nginx_modules_http_push; then
|
| 226 |
http_enabled=1
|
| 227 |
myconf+=" --add-module=${WORKDIR}/${HTTP_PUSH_MODULE_P}"
|
| 228 |
fi
|
| 229 |
|
| 230 |
if use nginx_modules_http_cache_purge; then
|
| 231 |
http_enabled=1
|
| 232 |
myconf+=" --add-module=${WORKDIR}/${HTTP_CACHE_PURGE_MODULE_P}"
|
| 233 |
fi
|
| 234 |
|
| 235 |
if use nginx_modules_http_upload; then
|
| 236 |
http_enabled=1
|
| 237 |
myconf+=" --add-module=${WORKDIR}/${HTTP_UPLOAD_MODULE_P}"
|
| 238 |
fi
|
| 239 |
|
| 240 |
if use nginx_modules_http_slowfs_cache; then
|
| 241 |
http_enabled=1
|
| 242 |
myconf+=" --add-module=${WORKDIR}/${HTTP_SLOWFS_CACHE_MODULE_P}"
|
| 243 |
fi
|
| 244 |
|
| 245 |
if use nginx_modules_http_fancyindex; then
|
| 246 |
http_enabled=1
|
| 247 |
myconf+=" --add-module=${WORKDIR}/${HTTP_FANCYINDEX_MODULE_PNPN}"
|
| 248 |
fi
|
| 249 |
|
| 250 |
if use http || use http-cache; then
|
| 251 |
http_enabled=1
|
| 252 |
fi
|
| 253 |
|
| 254 |
if [ $http_enabled ]; then
|
| 255 |
use http-cache || myconf+=" --without-http-cache"
|
| 256 |
use ssl && myconf+=" --with-http_ssl_module"
|
| 257 |
else
|
| 258 |
myconf+=" --without-http --without-http-cache"
|
| 259 |
fi
|
| 260 |
|
| 261 |
# MAIL modules
|
| 262 |
for mod in $NGINX_MODULES_MAIL; do
|
| 263 |
if use nginx_modules_mail_${mod}; then
|
| 264 |
mail_enabled=1
|
| 265 |
else
|
| 266 |
myconf+=" --without-mail_${mod}_module"
|
| 267 |
fi
|
| 268 |
done
|
| 269 |
|
| 270 |
if [ $mail_enabled ]; then
|
| 271 |
myconf+=" --with-mail"
|
| 272 |
use ssl && myconf+=" --with-mail_ssl_module"
|
| 273 |
fi
|
| 274 |
|
| 275 |
# custom modules
|
| 276 |
for mod in $NGINX_ADD_MODULES; do
|
| 277 |
myconf+=" --add-module=${mod}"
|
| 278 |
done
|
| 279 |
|
| 280 |
# https://bugs.gentoo.org/286772
|
| 281 |
export LANG=C LC_ALL=C
|
| 282 |
tc-export CC
|
| 283 |
|
| 284 |
if ! use prefix; then
|
| 285 |
myconf+=" --user=${PN} --group=${PN}"
|
| 286 |
fi
|
| 287 |
|
| 288 |
./configure \
|
| 289 |
--prefix="${EPREFIX}"/usr \
|
| 290 |
--conf-path="${EPREFIX}"/etc/${PN}/${PN}.conf \
|
| 291 |
--error-log-path="${EPREFIX}"/var/log/${PN}/error_log \
|
| 292 |
--pid-path="${EPREFIX}"/var/run/${PN}.pid \
|
| 293 |
--lock-path="${EPREFIX}"/var/lock/nginx.lock \
|
| 294 |
--with-cc-opt="-I${EROOT}usr/include" \
|
| 295 |
--with-ld-opt="-L${EROOT}usr/lib" \
|
| 296 |
--http-log-path="${EPREFIX}"/var/log/${PN}/access_log \
|
| 297 |
--http-client-body-temp-path="${EPREFIX}"/var/tmp/${PN}/client \
|
| 298 |
--http-proxy-temp-path="${EPREFIX}"/var/tmp/${PN}/proxy \
|
| 299 |
--http-fastcgi-temp-path="${EPREFIX}"/var/tmp/${PN}/fastcgi \
|
| 300 |
--http-scgi-temp-path="${EPREFIX}"/var/tmp/${PN}/scgi \
|
| 301 |
--http-uwsgi-temp-path="${EPREFIX}"/var/tmp/${PN}/uwsgi \
|
| 302 |
${myconf} || die "configure failed"
|
| 303 |
}
|
| 304 |
|
| 305 |
src_compile() {
|
| 306 |
# https://bugs.gentoo.org/286772
|
| 307 |
export LANG=C LC_ALL=C
|
| 308 |
emake LINK="${CC} ${LDFLAGS}" OTHERLDFLAGS="${LDFLAGS}"
|
| 309 |
}
|
| 310 |
|
| 311 |
src_install() {
|
| 312 |
emake DESTDIR="${D}" install
|
| 313 |
cp "${FILESDIR}"/nginx.conf "${ED}"/etc/nginx/nginx.conf || die
|
| 314 |
newinitd "${FILESDIR}"/nginx.initd nginx
|
| 315 |
doman man/nginx.8
|
| 316 |
dodoc CHANGES* README
|
| 317 |
|
| 318 |
# Keepdir because these are hardcoded above
|
| 319 |
keepdir /var/log/${PN} /var/tmp/${PN}/{client,proxy,fastcgi,scgi,uwsgi}
|
| 320 |
keepdir /var/www/localhost/htdocs
|
| 321 |
mv "${ED}"/usr/html "${ED}"/var/www/localhost/htdocs || die
|
| 322 |
|
| 323 |
# logrotate
|
| 324 |
insinto /etc/logrotate.d
|
| 325 |
newins "${FILESDIR}"/nginx.logrotate nginx
|
| 326 |
|
| 327 |
if use nginx_modules_http_perl; then
|
| 328 |
cd "${S}"/objs/src/http/modules/perl/
|
| 329 |
einstall DESTDIR="${D}" INSTALLDIRS=vendor
|
| 330 |
fixlocalpod
|
| 331 |
fi
|
| 332 |
|
| 333 |
if use nginx_modules_http_push; then
|
| 334 |
docinto ${HTTP_PUSH_MODULE_P}
|
| 335 |
dodoc "${WORKDIR}"/${HTTP_PUSH_MODULE_P}/{changelog.txt,protocol.txt,README}
|
| 336 |
fi
|
| 337 |
|
| 338 |
if use nginx_modules_http_cache_purge; then
|
| 339 |
docinto ${HTTP_CACHE_PURGE_MODULE_P}
|
| 340 |
dodoc "${WORKDIR}"/${HTTP_CACHE_PURGE_MODULE_P}/{CHANGES,README.md,TODO.md}
|
| 341 |
fi
|
| 342 |
|
| 343 |
if use nginx_modules_http_upload; then
|
| 344 |
docinto ${HTTP_UPLOAD_MODULE_P}
|
| 345 |
dodoc "${WORKDIR}"/${HTTP_UPLOAD_MODULE_P}/{Changelog,README}
|
| 346 |
fi
|
| 347 |
|
| 348 |
if use nginx_modules_http_slowfs_cache; then
|
| 349 |
docinto ${HTTP_SLOWFS_CACHE_MODULE_P}
|
| 350 |
dodoc "${WORKDIR}"/${HTTP_SLOWFS_CACHE_MODULE_P}/{CHANGES,README.md}
|
| 351 |
fi
|
| 352 |
|
| 353 |
if use nginx_modules_http_fancyindex; then
|
| 354 |
docinto ${HTTP_FANCYINDEX_MODULE_P}
|
| 355 |
dodoc "${WORKDIR}"/${HTTP_FANCYINDEX_MODULE_PNPN}/README.rst
|
| 356 |
fi
|
| 357 |
}
|
| 358 |
|
| 359 |
pkg_postinst() {
|
| 360 |
if use ssl; then
|
| 361 |
if [ ! -f "${EROOT}"/etc/ssl/${PN}/${PN}.key ]; then
|
| 362 |
install_cert /etc/ssl/${PN}/${PN}
|
| 363 |
use prefix || chown ${PN}:${PN} "${EROOT}"/etc/ssl/${PN}/${PN}.{crt,csr,key,pem}
|
| 364 |
fi
|
| 365 |
fi
|
| 366 |
}
|