| 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/uwsgi/uwsgi-1.2.3-r3.ebuild,v 1.3 2012/07/11 09:57:46 ultrabug Exp $
|
| 4 |
|
| 5 |
EAPI="4"
|
| 6 |
PYTHON_DEPEND="python? *"
|
| 7 |
PYTHON_MODNAME="uwsgidecorators"
|
| 8 |
SUPPORT_PYTHON_ABIS="1"
|
| 9 |
RESTRICT_PYTHON_ABIS="*-jython 2.7-pypy-*"
|
| 10 |
USE_RUBY="ruby18 ree18 ruby19"
|
| 11 |
RUBY_OPTIONAL="yes"
|
| 12 |
PHP_EXT_NAME="dummy"
|
| 13 |
PHP_EXT_INI="no"
|
| 14 |
USE_PHP="php5-3 php5-4" # deps must be registered separately below
|
| 15 |
PHP_EXT_OPTIONAL_USE="php"
|
| 16 |
|
| 17 |
MY_P="${P/_/-}"
|
| 18 |
|
| 19 |
inherit apache-module eutils python multilib pax-utils php-ext-source-r2 ruby-ng
|
| 20 |
|
| 21 |
DESCRIPTION="uWSGI server for Python web applications"
|
| 22 |
HOMEPAGE="http://projects.unbit.it/uwsgi/"
|
| 23 |
SRC_URI="http://projects.unbit.it/downloads/${MY_P}.tar.gz"
|
| 24 |
|
| 25 |
LICENSE="GPL-2"
|
| 26 |
SLOT="0"
|
| 27 |
KEYWORDS="~amd64 ~x86"
|
| 28 |
IUSE="apache2 +caps +carbon cgi debug erlang gevent graylog2 json ldap lua +nagios perl +pcre php +python rrdtool rsyslog ruby spooler sqlite syslog +xml yaml zeromq"
|
| 29 |
REQUIRED_USE="|| ( cgi erlang lua perl php python ruby )"
|
| 30 |
|
| 31 |
# util-linux is required for libuuid when requesting zeromq support
|
| 32 |
CDEPEND="caps? ( sys-libs/libcap )
|
| 33 |
json? ( dev-libs/jansson )
|
| 34 |
erlang? ( dev-lang/erlang )
|
| 35 |
gevent? ( >=dev-python/gevent-1.0_beta2 )
|
| 36 |
graylog2? ( sys-libs/zlib )
|
| 37 |
ldap? ( net-nds/openldap )
|
| 38 |
lua? ( dev-lang/lua )
|
| 39 |
pcre? ( dev-libs/libpcre )
|
| 40 |
perl? ( dev-lang/perl )
|
| 41 |
php? (
|
| 42 |
php_targets_php5-3? ( dev-lang/php:5.3[embed] )
|
| 43 |
php_targets_php5-4? ( dev-lang/php:5.4[embed] )
|
| 44 |
)
|
| 45 |
ruby? ( $(ruby_implementations_depend) )
|
| 46 |
sqlite? ( dev-db/sqlite:3 )
|
| 47 |
rsyslog? ( app-admin/rsyslog )
|
| 48 |
xml? ( dev-libs/libxml2 )
|
| 49 |
yaml? ( dev-libs/libyaml )
|
| 50 |
zeromq? ( net-libs/zeromq sys-apps/util-linux )"
|
| 51 |
DEPEND="${CDEPEND}
|
| 52 |
virtual/pkgconfig"
|
| 53 |
RDEPEND="${CDEPEND}
|
| 54 |
rrdtool? ( net-analyzer/rrdtool )"
|
| 55 |
|
| 56 |
S="${WORKDIR}/${MY_P}"
|
| 57 |
APXS2_S="${S}/apache2"
|
| 58 |
APACHE2_MOD_CONF="42_mod_uwsgi-r1 42_mod_uwsgi"
|
| 59 |
|
| 60 |
want_apache2_2
|
| 61 |
|
| 62 |
use_true_false() {
|
| 63 |
if use $1 ; then
|
| 64 |
echo "true"
|
| 65 |
else
|
| 66 |
echo "false"
|
| 67 |
fi
|
| 68 |
}
|
| 69 |
|
| 70 |
src_unpack() {
|
| 71 |
default
|
| 72 |
}
|
| 73 |
|
| 74 |
pkg_setup() {
|
| 75 |
depend.apache_pkg_setup
|
| 76 |
python_pkg_setup
|
| 77 |
}
|
| 78 |
|
| 79 |
src_prepare() {
|
| 80 |
epatch \
|
| 81 |
"${FILESDIR}/1.1.2-threaded-php.patch" \
|
| 82 |
"${FILESDIR}/${PV}-pyerl.patch"
|
| 83 |
|
| 84 |
sed -i \
|
| 85 |
-e "s|'-O2', ||" \
|
| 86 |
-e "s|'-Werror', ||" \
|
| 87 |
-e "s|uc.get('plugin_dir')|uc.get('plugin_build_dir')|" \
|
| 88 |
uwsgiconfig.py || die "sed failed"
|
| 89 |
|
| 90 |
sed -i \
|
| 91 |
-e 's|python\([0-9].[0-9]\)-config|python-config-\1|' \
|
| 92 |
plugins/python/uwsgiplugin.py || die "sed failed"
|
| 93 |
|
| 94 |
sed -i \
|
| 95 |
-e "s|/lib|/$(get_libdir)|" \
|
| 96 |
plugins/php/uwsgiplugin.py || die "sed failed"
|
| 97 |
}
|
| 98 |
|
| 99 |
src_configure() {
|
| 100 |
local plugins=""
|
| 101 |
use carbon && plugins+=", carbon"
|
| 102 |
use graylog2 && plugins+=", graylog2"
|
| 103 |
use nagios && plugins+=", nagios"
|
| 104 |
use rrdtool && plugins+=", rrdtool"
|
| 105 |
use rsyslog && plugins+=", rsyslog"
|
| 106 |
use syslog && plugins+=", syslog"
|
| 107 |
|
| 108 |
cat > "buildconf/gentoo.ini" << EOF
|
| 109 |
[uwsgi]
|
| 110 |
xml = $(use_true_false xml)
|
| 111 |
ini = true
|
| 112 |
yaml = $(use_true_false yaml)
|
| 113 |
json = $(use_true_false json)
|
| 114 |
sqlite3 = $(use_true_false sqlite)
|
| 115 |
zeromq = $(use_true_false zeromq)
|
| 116 |
snmp = true
|
| 117 |
sctp = false
|
| 118 |
spooler = true
|
| 119 |
embedded = true
|
| 120 |
udp = true
|
| 121 |
multicast = true
|
| 122 |
threading = true
|
| 123 |
sendfile = true
|
| 124 |
minterpreters = true
|
| 125 |
async = true
|
| 126 |
evdis = false
|
| 127 |
ldap = $(use_true_false ldap)
|
| 128 |
pcre = $(use_true_false pcre)
|
| 129 |
debug = $(use_true_false debug)
|
| 130 |
unbit = false
|
| 131 |
xml_implementation = libxml2
|
| 132 |
yaml_implementation = libyaml
|
| 133 |
malloc_implementation = libc
|
| 134 |
plugins =
|
| 135 |
bin_name = uwsgi
|
| 136 |
append_version =
|
| 137 |
plugin_dir = /usr/$(get_libdir)/uwsgi
|
| 138 |
plugin_build_dir = ${T}/plugins
|
| 139 |
embedded_plugins = ping, cache, rpc, fastrouter, http, ugreen, signal, logsocket, router_uwsgi, router_redirect, router_basicauth, zergpool, redislog ${plugins}
|
| 140 |
as_shared_library = false
|
| 141 |
|
| 142 |
locking = auto
|
| 143 |
event = auto
|
| 144 |
timer = auto
|
| 145 |
filemonitor = auto
|
| 146 |
|
| 147 |
embed_files =
|
| 148 |
|
| 149 |
embed_config =
|
| 150 |
[python]
|
| 151 |
paste = true
|
| 152 |
web3 = true
|
| 153 |
EOF
|
| 154 |
use caps || sed -i -e 's|sys/capability.h|DISABLED|' uwsgiconfig.py || die "sed failed"
|
| 155 |
use zeromq || sed -i -e 's|uuid/uuid.h|DISABLED|' uwsgiconfig.py || die "sed failed"
|
| 156 |
}
|
| 157 |
|
| 158 |
each_ruby_compile() {
|
| 159 |
cd "${WORKDIR}/${MY_P}"
|
| 160 |
|
| 161 |
UWSGICONFIG_RUBYPATH="${RUBY}" python uwsgiconfig.py --plugin plugins/rack gentoo rack_${RUBY##*/} || die "building plugin for ${RUBY} failed"
|
| 162 |
|
| 163 |
if [[ "${RUBY}" == *ruby19 ]] ; then
|
| 164 |
UWSGICONFIG_RUBYPATH="${RUBY}" python uwsgiconfig.py --plugin plugins/fiber gentoo || die "building fiber plugin for ${RUBY} failed"
|
| 165 |
fi
|
| 166 |
}
|
| 167 |
|
| 168 |
install_python_lib() {
|
| 169 |
insinto $(python_get_sitedir)
|
| 170 |
doins uwsgidecorators.py
|
| 171 |
}
|
| 172 |
|
| 173 |
src_compile() {
|
| 174 |
python uwsgiconfig.py --build gentoo || die "building uwsgi failed"
|
| 175 |
|
| 176 |
mkdir -p "${T}/plugins"
|
| 177 |
|
| 178 |
if use erlang ; then
|
| 179 |
python uwsgiconfig.py --plugin plugins/erlang gentoo || die "building plugin for erlang failed"
|
| 180 |
fi
|
| 181 |
|
| 182 |
if use lua ; then
|
| 183 |
python uwsgiconfig.py --plugin plugins/lua gentoo || die "building plugin for lua failed"
|
| 184 |
fi
|
| 185 |
|
| 186 |
if use perl ; then
|
| 187 |
python uwsgiconfig.py --plugin plugins/psgi gentoo || die "building plugin for perl failed"
|
| 188 |
fi
|
| 189 |
|
| 190 |
if use php ; then
|
| 191 |
for s in $(php_get_slots); do
|
| 192 |
UWSGICONFIG_PHPDIR="/usr/$(get_libdir)/${s}" python uwsgiconfig.py --plugin plugins/php gentoo ${s/.} || die "building plugin for ${s} failed"
|
| 193 |
done
|
| 194 |
fi
|
| 195 |
|
| 196 |
if use python ; then
|
| 197 |
for a in ${PYTHON_ABIS} ; do
|
| 198 |
python${a} uwsgiconfig.py --plugin plugins/python gentoo python${a/.} || die "building plugin for python-${a} failed"
|
| 199 |
|
| 200 |
if use gevent ; then
|
| 201 |
python${a} uwsgiconfig.py --plugin plugins/gevent gentoo gevent${a/.} || die "building plugin for gevent-support in python-${a} failed"
|
| 202 |
fi
|
| 203 |
if use erlang ; then
|
| 204 |
python${a} uwsgiconfig.py --plugin plugins/pyerl gentoo pyerl${a/.} || die "building plugin for erlang-support in python failed"
|
| 205 |
fi
|
| 206 |
done
|
| 207 |
fi
|
| 208 |
|
| 209 |
if use ruby ; then
|
| 210 |
ruby-ng_src_compile
|
| 211 |
fi
|
| 212 |
|
| 213 |
if use spooler ; then
|
| 214 |
python uwsgiconfig.py --plugin plugins/spooler gentoo || die "building plugin for spooler failed"
|
| 215 |
fi
|
| 216 |
|
| 217 |
if use cgi ; then
|
| 218 |
python uwsgiconfig.py --plugin plugins/cgi gentoo || die "building plugin for cgi failed"
|
| 219 |
fi
|
| 220 |
|
| 221 |
if use apache2 ; then
|
| 222 |
for m in proxy_uwsgi Ruwsgi uwsgi ; do
|
| 223 |
APXS2_ARGS="-c mod_${m}.c"
|
| 224 |
apache-module_src_compile
|
| 225 |
done
|
| 226 |
fi
|
| 227 |
}
|
| 228 |
|
| 229 |
src_install() {
|
| 230 |
dobin uwsgi
|
| 231 |
pax-mark m "${D}"/usr/bin/uwsgi
|
| 232 |
|
| 233 |
insinto /usr/$(get_libdir)/uwsgi
|
| 234 |
doins "${T}/plugins"/*.so
|
| 235 |
|
| 236 |
use cgi && dosym uwsgi /usr/bin/uwsgi_cgi
|
| 237 |
use erlang && dosym uwsgi /usr/bin/uwsgi_erlang
|
| 238 |
use lua && dosym uwsgi /usr/bin/uwsgi_lua
|
| 239 |
use perl && dosym uwsgi /usr/bin/uwsgi_psgi
|
| 240 |
|
| 241 |
if use php ; then
|
| 242 |
for s in $(php_get_slots); do
|
| 243 |
dosym uwsgi /usr/bin/uwsgi_${s/.}
|
| 244 |
done
|
| 245 |
fi
|
| 246 |
|
| 247 |
if use python ; then
|
| 248 |
python_execute_function install_python_lib
|
| 249 |
for a in ${PYTHON_ABIS} ; do
|
| 250 |
dosym uwsgi /usr/bin/uwsgi_python${a/.}
|
| 251 |
done
|
| 252 |
fi
|
| 253 |
|
| 254 |
if use apache2; then
|
| 255 |
for m in proxy_uwsgi Ruwsgi uwsgi ; do
|
| 256 |
APACHE2_MOD_FILE="${APXS2_S}/.libs/mod_${m}.so"
|
| 257 |
apache-module_src_install
|
| 258 |
done
|
| 259 |
fi
|
| 260 |
|
| 261 |
newinitd "${FILESDIR}"/uwsgi.initd-r1 uwsgi
|
| 262 |
newconfd "${FILESDIR}"/uwsgi.confd-r1 uwsgi
|
| 263 |
keepdir /etc/"${PN}".d
|
| 264 |
use spooler && keepdir /var/spool/"${PN}"
|
| 265 |
}
|
| 266 |
|
| 267 |
pkg_postinst() {
|
| 268 |
if use apache2 ; then
|
| 269 |
elog "Three Apache modules have been installed: mod_proxy_uwsgi, mod_uwsgi and mod_Ruwsgi."
|
| 270 |
elog "You can enable them with -D PROXY_UWSGI, -DUWSGI or -DRUWSGI in /etc/conf.d/apache2."
|
| 271 |
elog "mod_uwsgi and mod_Ruwsgi have the same configuration interface and define the same symbols."
|
| 272 |
elog "Therefore you can enable only one of them at a time."
|
| 273 |
elog "mod_uwsgi is commercially supported by Unbit and stable but a bit hacky."
|
| 274 |
elog "mod_Ruwsgi is newer and more Apache-API friendly but not commercially supported."
|
| 275 |
elog "mod_proxy_uwsgi is the newest and not considered ready for production yet."
|
| 276 |
fi
|
| 277 |
|
| 278 |
elog "Append the following options to the uwsgi call to load the respective language plugin:"
|
| 279 |
use cgi && elog " '--plugins cgi' for cgi"
|
| 280 |
use erlang && elog " '--plugins erlang' for erlang"
|
| 281 |
use lua && elog " '--plugins lua' for lua"
|
| 282 |
use perl && elog " '--plugins psgi' for perl"
|
| 283 |
|
| 284 |
if use php ; then
|
| 285 |
for s in $(php_get_slots); do
|
| 286 |
elog " '--plugins ${s/.}' for ${s}"
|
| 287 |
done
|
| 288 |
fi
|
| 289 |
|
| 290 |
if use python ; then
|
| 291 |
for a in ${PYTHON_ABIS} ; do
|
| 292 |
elog " '--plugins python${a/.}' for python-${a}"
|
| 293 |
use gevent && elog " '--plugins python${a/.},gevent${a/.}' for gevent support in python-${a}"
|
| 294 |
use erlang && elog " '--plugins python${a/.},erlang,pyerl${a/.}' for erlang support in python-${a}"
|
| 295 |
done
|
| 296 |
fi
|
| 297 |
|
| 298 |
if use ruby ; then
|
| 299 |
for ruby in $USE_RUBY; do
|
| 300 |
use ruby_targets_${ruby} && elog " '--plugins rack_${ruby/.}' for ${ruby}"
|
| 301 |
if [[ "${ruby}" == *ruby19 ]] ; then
|
| 302 |
elog " '--plugins fibre' for ruby-1.9 fibres"
|
| 303 |
fi
|
| 304 |
done
|
| 305 |
fi
|
| 306 |
}
|