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