# Copyright 1999-2010 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: $ EAPI="2" inherit eutils ssl-cert perl-module flag-o-matic DESCRIPTION="Robust, small and high performance http and reverse proxy server" HOMEPAGE="http://nginx.net/" SRC_URI="http://sysoev.ru/nginx/${P}.tar.gz" LICENSE="BSD" SLOT="0" KEYWORDS="amd64 ppc x86" IUSE="debug ipv6 +pcre perl ssl +zlib" MODULES_STD="charset gzip ssi userid access auth_basic autoindex geo map referer rewrite proxy fastcgi memcached limit_zone limit_req empty_gif browser upstream_ip_hash" MODULES_OPT="realip addition xslt image_filter geoip sub dav flv gzip_static random_index secure_link stub_status" MODULES_MAIL="imap pop3 smtp" MODULES_3RD="passenger" for module in ${MODULES_STD}; do IUSE="${IUSE} +nginx_modules_${module}" done for module in ${MODULES_OPT}; do IUSE="${IUSE} nginx_modules_${module}" done for module in ${MODULES_MAIL}; do IUSE="${IUSE} nginx_modules_${module}" done for module in ${MODULES_3RD}; do IUSE="${IUSE} nginx_modules_${module}" done MODULE_PASSENGER_P="passenger-2.2.9" SRC_URI="${SRC_URI} nginx_modules_passenger? ( mirror://rubyforge/passenger/${MODULE_PASSENGER_P}.tar.gz )" USE_RUBY="ruby18" DEPEND="ssl? ( dev-libs/openssl ) pcre? ( >=dev-libs/libpcre-4.2 ) zlib? ( sys-libs/zlib ) perl? ( >=dev-lang/perl-5.8 ) nginx_modules_passenger? ( >=dev-lang/ruby-1.8.5 >=dev-ruby/rubygems-0.9.0 >=dev-ruby/rake-0.8.1 >=dev-ruby/fastthread-1.0.1 >=dev-ruby/rack-1.0.0 )" RDEPEND="${DEPEND}" pkg_setup() { ebegin "Creating nginx user and group" enewgroup ${PN} enewuser ${PN} -1 -1 -1 ${PN} eend ${?} use nginx_modules_passenger && use debug && append-flags -DPASSENGER_DEBUG } src_unpack() { unpack ${A} sed -i 's/ make/ \\$(MAKE)/' "${S}"/auto/lib/perl/make || die use nginx_modules_passenger && { cd "${WORKDIR}/${MODULE_PASSENGER_P}" epatch "${FILESDIR}"/passenger-CFLAGS.patch } } src_configure() { local myconf use debug && myconf="${myconf} --with-debug" use ipv6 && myconf="${myconf} --with-ipv6" use pcre || myconf="${myconf} --without-pcre" use pcre && myconf="${myconf} --with-pcre" use perl && myconf="${myconf} --with-http_perl_module" use ssl && myconf="${myconf} --with-http_ssl_module" use nginx_modules_gzip && ! use zlib && die "nginx gzip module requires zlib" use nginx_modules_rewrite && ! use pcre && die "nginx rewrite module requires pcre" for module in ${MODULES_STD} ; do use "nginx_modules_${module}" || \ myconf="${myconf} --without-http_${module}_module" done for module in ${MODULES_OPT} ; do use "nginx_modules_${module}" && \ myconf="${myconf} --with-http_${module}_module" done for module in ${MODULES_MAIL} ; do use "nginx_modules_${module}" || \ myconf="${myconf} --without-mail_${module}_module" done if use nginx_modules_smtp || use nginx_modules_pop || use nginx_modules_imap; then myconf="${myconf} --with-mail" use ssl && myconf="${myconf} --with-mail_ssl_module" fi use nginx_modules_passenger && myconf="${myconf} --add-module=../${MODULE_PASSENGER_P}/ext/nginx" ./configure \ --prefix=/usr \ --with-cc-opt="-I${ROOT}/usr/include" \ --with-ld-opt="-L${ROOT}/usr/lib" \ --conf-path=/etc/${PN}/${PN}.conf \ --http-log-path=/var/log/${PN}/access.log \ --error-log-path=/var/log/${PN}/error.log \ --pid-path=/var/run/${PN}.pid \ --http-client-body-temp-path=/var/tmp/${PN}/client \ --http-proxy-temp-path=/var/tmp/${PN}/proxy \ --http-fastcgi-temp-path=/var/tmp/${PN}/fastcgi \ ${myconf} || die "configure failed" } src_compile() { emake || die "failed to compile nginx" use nginx_modules_passenger && { cd ${WORKDIR}/${MODULE_PASSENGER_P} ${USE_RUBY} $(type -p rake) native_support || die "failed to compile passenger" } } my_doruby() { ( insinto $(${USE_RUBY} -r rbconfig -e 'print Config::CONFIG["sitelibdir"]') insopts -m 0644 doins "$@" ) || die "failed to install $@" } src_install() { keepdir /var/log/${PN} /var/tmp/${PN}/{client,proxy,fastcgi} dosbin objs/nginx newinitd "${FILESDIR}"/nginx.init nginx || die "failed to install init script" cp "${FILESDIR}"/nginx.conf conf/nginx.conf dodir /etc/${PN} insinto /etc/${PN} doins conf/* dodoc CHANGES{,.ru} README insinto /etc/logrotate.d newins "${FILESDIR}"/nginx.logrotate nginx || die "failed to install logrotate script" use perl && { cd "${S}"/objs/src/http/modules/perl/ einstall DESTDIR="${D}" INSTALLDIRS=vendor || die "failed to install perl stuff" fixlocalpod } use nginx_modules_passenger && { insinto $(${USE_RUBY} -r rbconfig -e 'print Config::CONFIG["sitelibdir"], "/", Config::CONFIG["arch"], "/phusion_passenger"') insopts -m 0755 doins "${WORKDIR}/${MODULE_PASSENGER_P}/ext/phusion_passenger/native_support.so" || die "failed to install native_support.so" cd "${WORKDIR}/${MODULE_PASSENGER_P}/lib/" my_doruby -r * exeinto /usr/bin cd "${WORKDIR}/${MODULE_PASSENGER_P}/bin" doexe passenger-memory-stats passenger-status exeinto /usr/libexec/passenger/bin doexe "${WORKDIR}/${MODULE_PASSENGER_P}/bin/passenger-spawn-server" exeinto /usr/libexec/passenger/ext/nginx doexe ${WORKDIR}/${MODULE_PASSENGER_P}/ext/nginx/HelperServer || die "failed to install HelperServer" } } pkg_postinst() { use ssl && { if [ ! -f "${ROOT}"/etc/${PN}/ssl/default.key ]; then install_cert /etc/${PN}/ssl/default chown ${PN}:${PN} "${ROOT}"/etc/${PN}/ssl/default.{crt,csr,key,pem} fi } }