1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
5 USE_RUBY="ruby23 ruby24 ruby25 ruby26"
7 inherit apache-module flag-o-matic multilib ruby-ng toolchain-funcs
9 DESCRIPTION="Passenger makes deployment of Ruby on Rails applications a breeze"
10 HOMEPAGE="https://www.phusionpassenger.com/"
11 SRC_URI="https://s3.amazonaws.com/phusion-passenger/releases/${P}.tar.gz"
18 ruby_add_bdepend "dev-ruby/rake"
21 >=dev-ruby/rack-1.0.0:*
22 >=dev-ruby/rake-0.8.1"
24 # libev is bundled but with adapations that do not seem to be accepted
25 # upstream, so we must use the bundled version :-(
27 >=dev-libs/libuv-1.8.0
29 apache2? ( www-servers/apache[apache2_modules_unixd(+)] )"
31 RDEPEND="${RDEPEND} ${CDEPEND}"
32 DEPEND="${DEPEND} ${CDEPEND}"
34 APACHE2_MOD_CONF="30_mod_${PN}-5.0.0 30_mod_${PN}"
35 APACHE2_MOD_DEFINE="PASSENGER"
40 use debug && append-flags -DPASSENGER_DEBUG
41 depend.apache_pkg_setup
45 eapply "${FILESDIR}"/${PN}-5.1.11-gentoo.patch
46 eapply "${FILESDIR}"/${PN}-5.1.1-isnan.patch
48 # Change these with sed instead of a patch so that we can easily use
49 # the toolchain-funcs methods.
50 sed -i -e "/^CC/ s/=.*$/= '$(tc-getCC)'/" \
51 -e "/^CXX\s/ s/=.*$/= '$(tc-getCXX)'/" \
52 -e 's/PlatformInfo.debugging_cflags//' build/basics.rb || die
54 # Avoid fixed debugging CFLAGs.
55 sed -e '/debugging_cflags/areturn ""' -i src/ruby_supportlib/phusion_passenger/platform_info/compiler.rb || die
57 # Use sed here so that we can dynamically set the documentation directory.
58 sed -i -e "s:/usr/share/doc/passenger:/usr/share/doc/${P}:" \
59 -e "s:/usr/lib/phusion-passenger/agents:/usr/libexec/phusion-passenger/agents:" \
60 src/ruby_supportlib/phusion_passenger.rb || die
61 sed -i -e "s:/usr/lib/phusion-passenger/agents:/usr/libexec/phusion-passenger/agents:" src/cxx_supportlib/ResourceLocator.h || die
63 # Don't install a tool that won't work in our setup.
64 sed -i -e '/passenger-install-apache2-module/d' src/ruby_supportlib/phusion_passenger/packaging.rb || die
65 rm -f bin/passenger-install-apache2-module || die "Unable to remove unneeded install script."
67 # Make sure we use the system-provided version where possible
68 rm -rf src/cxx_supportlib/vendor-copy/libuv || die "Unable to remove vendored code."
70 # Avoid building documentation to avoid a dependency on mizuho.
71 #sed -i -e 's/, :doc//' build/packaging.rb || die
72 touch doc/*.html || die
74 # Fix hard-coded use of AR
75 sed -i -e "s/ar cru/"$(tc-getAR)" cru/" build/support/cplusplus.rb || die
77 # Make sure apache support is not attempted with -apache2
78 if ! use apache2 ; then
79 sed -i -e '/fakeroot/ s/:apache2, //' build/packaging.rb || die
85 V=1 EXTRA_LDFLAGS="${LDFLAGS}" \
87 HTTPD="${APACHE_BIN}" \
88 FS_LIBDIR='/usr/'$(get_libdir) \
89 USE_VENDORED_LIBUV="no" LIBUV_LIBS="-luv" \
90 ruby -S rake apache2 || die "rake failed"
95 append-flags -fno-strict-aliasing
97 V=1 EXTRA_LDFLAGS="${LDFLAGS}" \
99 HTTPD="${APACHE_BIN}" \
100 FS_LIBDIR='/usr/'$(get_libdir) \
101 USE_VENDORED_LIBUV="no" LIBUV_LIBS="-luv" \
102 ${RUBY} -S rake native_support || die "rake failed"
106 if use apache2 ; then
107 APACHE2_MOD_FILE="${S}/buildout/apache2/mod_${PN}.so"
108 apache-module_src_install
110 # Patch in the correct libdir
111 sed -i -e 's:/usr/lib/:/usr/'$(get_libdir)'/:' "${D}${APACHE_MODULES_CONFDIR}/30_mod_${PN}.conf" || die
114 dodoc CHANGELOG README.md
117 each_ruby_install() {
119 RUBYLIBDIR="$(ruby_rbconfig_value vendordir)" \
120 RUBYARCHDIR="$(ruby_rbconfig_value archdir)" \
122 HTTPD="${APACHE_BIN}" \
123 FS_LIBDIR='/usr/'$(get_libdir) \
124 EXTRA_LDFLAGS="${LDFLAGS}" \
125 USE_VENDORED_LIBUV="no" LIBUV_LIBS="-luv" \
126 ${RUBY} -S rake fakeroot || die "rake failed"