#
-# TODO:
-# - separate -devel with ExtUtils::Embed and friends?
-
-%define apxs /usr/sbin/apxs
-%define mod_name rails
-%define apacheconfdir %(%{apxs} -q SYSCONFDIR 2>/dev/null)/conf.d
-%define apachelibdir %(%{apxs} -q LIBEXECDIR 2>/dev/null)
-%define apacheprefix %(%{apxs} -q PREFIX 2>/dev/null)
-%define apachelibdir2 %(%{apxs} -q LIBEXECDIR 2>/dev/null | %{__sed} 's|%{apacheprefix}||')
+# Conditional build:
+%bcond_with tests # build without tests
%define gem_name passenger
Summary: A module to bridge Ruby on Rails to Apache
Name: apache-mod_rails
Version: 3.0.19
-Release: 0.1
+Release: 1
# Passenger code uses MIT license.
# Bundled(Boost) uses Boost Software License
# BCrypt and Blowfish files use BSD license.
License: Boost and BSD and BSD with advertising and MIT and zlib
Group: Networking/Daemons/HTTP
Source0: https://github.com/FooBarWidget/passenger/archive/release-%{version}.tar.gz
+# Source0-md5: de848f42cb4f83e19d6c8a41a187a4db
Source1: %{name}.conf
Patch0: %{name}-nogems.patch
Patch1: %{name}-alias+public.patch
Patch2: passenger_apache_fix_autofoo.patch
-URL: http://www.modrails.com
-BuildRequires: apache-base >= 2.0.55-1
+Patch3: progs.patch
+URL: http://www.modrails.com/
BuildRequires: apache-devel >= 2.0.55-1
-BuildRequires: apache-tools >= 2.0.55-1
BuildRequires: apr-devel >= 1:1.0.0
BuildRequires: apr-util-devel >= 1:1.0.0
#BuildRequires: asciidoc
BuildRequires: curl-devel
+BuildRequires: libev-devel
BuildRequires: libstdc++-devel
BuildRequires: openssl-devel
-BuildRequires: pkgconfig
BuildRequires: rpm-pythonprov
BuildRequires: rpmbuild(macros) >= 1.559
BuildRequires: ruby-devel
BuildRequires: ruby-rake >= 0.8.0
+BuildRequires: ruby-rdoc
BuildRequires: sed >= 4.0
BuildRequires: zlib-devel
-%requires_ge_to ruby ruby-devel
+Requires: apache(modules-api) = %apache_modules_api
Provides: apache(mod_rails)
Obsoletes: apache-mod_rails-rdoc
BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
+%define apxs /usr/sbin/apxs
+%define _pkglibdir %(%{apxs} -q LIBEXECDIR 2>/dev/null)
+%define _sysconfdir %(%{apxs} -q SYSCONFDIR 2>/dev/null)/conf.d
+
%description
Phusion Passenger — a.k.a. mod_rails — makes deployment of
applications built on the revolutionary Ruby on Rails web framework a
%patch0 -p1
%patch1 -p0
%patch2 -p0
+%patch3 -p1
-%build
-(cd ext/libev; %{__autoconf})
+mv test/config.yml{.example,}
-cat > fake-httpd <<EOF
-#!/bin/sh
-echo Apache/$(rpm -q apache-devel --qf '%{V}')
-EOF
-chmod a+rx fake-httpd
+# Don't use bundled libev
+rm -r ext/libev
-cc="%{__cc}"; cc=${cc#ccache }
-cxx="%{__cxx}"; cxx=${cxx#ccache }
-rake apache2 \
+%build
+export USE_VENDORED_LIBEV=false
+export CC="%{__cc}"
+export CXX="%{__cxx}"
+export CFLAGS="%{rpmcflags}"
+export CXXFLAGS="%{rpmcxxflags}"
+export APACHECTL=%{_sbindir}/apachectl
+export HTTPD_VERSION=$(rpm -q apache-devel --qf '%{V}')
+
+rake apache2 V=1 \
RELEASE=yes \
OPTIMIZE=yes \
- HTTPD=${PWD:-$(pwd)/fake-httpd} \
- APXS2=%{apxs} \
- CXXFLAGS="%{rpmcxxflags}" \
- CFLAGS="%{rpmcflags}" \
- CXX="$cxx" \
- CC="$cc"
+ HTTPD=false
+
+%if %{with tests}
+# Run the tests, capture the output, but don't fail the build if the tests fail
+#
+# This will make the test failure non-critical, but it should be examined
+# anyway.
+sed -i 's|sh "cd test && \./cxx/CxxTestMain"|& rescue true|' build/cxx_tests.rb
+
+# adjust for rspec 2 while the test suite seems to require RSpec 1.
+sed -i \
+ "s|return locate_ruby_tool('spec')|return locate_ruby_tool('rspec')|" \
+ lib/phusion_passenger/platform_info/ruby.rb
+
+rake test --trace
+%endif
rdoc --ri --op ri lib ext/ruby
%{__rm} -r ri/{ConditionVariable,Exception,GC,IO,Object,Process,Signal}
%install
rm -rf $RPM_BUILD_ROOT
-install -d $RPM_BUILD_ROOT{%{apachelibdir},%{apacheconfdir},%{_mandir}/man{1,8}} \
- $RPM_BUILD_ROOT{%{ruby_rubylibdir},%{ruby_archdir},%{ruby_ridir}} \
+install -d $RPM_BUILD_ROOT{%{_pkglibdir},%{_sysconfdir},%{_mandir}/man{1,8}} \
+ $RPM_BUILD_ROOT{%{ruby_vendorlibdir},%{ruby_vendorarchdir},%{ruby_ridir}} \
$RPM_BUILD_ROOT%{_bindir} \
$RPM_BUILD_ROOT%{_libdir}/phusion-passenger/agents/apache2 \
$RPM_BUILD_ROOT%{_datadir}/phusion-passenger/helper-scripts
-install ext/apache2/mod_passenger.so $RPM_BUILD_ROOT%{apachelibdir}
-
-install ext/ruby/ruby-*/passenger_native_support.so $RPM_BUILD_ROOT%{ruby_archdir}
-
-install bin/passenger-{config,memory-stats,status} bin/passenger \
- $RPM_BUILD_ROOT%{_bindir}
-
-install agents/PassengerLoggingAgent agents/PassengerWatchdog $RPM_BUILD_ROOT%{_libdir}/phusion-passenger/agents
-install agents/apache2/PassengerHelperAgent $RPM_BUILD_ROOT%{_libdir}/phusion-passenger/agents/apache2
-
-install helper-scripts/* $RPM_BUILD_ROOT%{_datadir}/phusion-passenger/helper-scripts
-
-cp -a lib/* $RPM_BUILD_ROOT%{ruby_rubylibdir}
-install man/*.1 $RPM_BUILD_ROOT%{_mandir}/man1
-install man/*.8 $RPM_BUILD_ROOT%{_mandir}/man8
-
+install -p ext/apache2/mod_passenger.so $RPM_BUILD_ROOT%{_pkglibdir}
+install -p ext/ruby/ruby-*/passenger_native_support.so $RPM_BUILD_ROOT%{ruby_vendorarchdir}
+install -p bin/passenger-{config,memory-stats,status} bin/passenger $RPM_BUILD_ROOT%{_bindir}
+install -p agents/PassengerLoggingAgent agents/PassengerWatchdog $RPM_BUILD_ROOT%{_libdir}/phusion-passenger/agents
+install -p agents/apache2/PassengerHelperAgent $RPM_BUILD_ROOT%{_libdir}/phusion-passenger/agents/apache2
+install -p helper-scripts/* $RPM_BUILD_ROOT%{_datadir}/phusion-passenger/helper-scripts
+cp -a lib/* $RPM_BUILD_ROOT%{ruby_vendorlibdir}
+cp -p man/*.1 $RPM_BUILD_ROOT%{_mandir}/man1
+cp -p man/*.8 $RPM_BUILD_ROOT%{_mandir}/man8
cp -a ri/* $RPM_BUILD_ROOT%{ruby_ridir}
-
-install %{SOURCE1} $RPM_BUILD_ROOT%{apacheconfdir}/75_mod_rails.conf
+cp -p %{SOURCE1} $RPM_BUILD_ROOT%{_sysconfdir}/75_mod_rails.conf
%{__sed} -i -e 's|#!/usr/bin/env ruby|#!%{_bindir}/ruby|' \
$RPM_BUILD_ROOT%{_bindir}/passenger \
$RPM_BUILD_ROOT%{_datadir}/phusion-passenger/helper-scripts/*
%{__sed} -i -e 's|#!/usr/bin/env python|#!%{_bindir}/python|' \
- $RPM_BUILD_ROOT%{ruby_rubylibdir}/phusion_passenger/wsgi/request_handler.py
+ $RPM_BUILD_ROOT%{ruby_vendorlibdir}/phusion_passenger/wsgi/request_handler.py
%clean
rm -rf $RPM_BUILD_ROOT
%doc INSTALL README
#%doc doc/{A*.txt,Security*.txt,*Apache.txt}
#%doc doc/{A*.html,Security*.html,*Apache.html,images}
-%attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{apacheconfdir}/*.conf
-%attr(755,root,root) %{apachelibdir}/*
+%attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/*_mod_rails.conf
+%attr(755,root,root) %{_pkglibdir}/mod_passenger.so
%attr(755,root,root) %{_bindir}/passenger
-%attr(755,root,root) %{_bindir}/passenger-*
-%attr(755,root,root) %{ruby_archdir}/*.so
+%attr(755,root,root) %{_bindir}/passenger-config
+%attr(755,root,root) %{_bindir}/passenger-memory-stats
+%attr(755,root,root) %{_bindir}/passenger-status
+%{_mandir}/man1/passenger-config.1*
+%{_mandir}/man1/passenger-stress-test.1*
+%{_mandir}/man8/passenger-memory-stats.8*
+%{_mandir}/man8/passenger-status.8*
+
+%attr(755,root,root) %{ruby_vendorarchdir}/passenger_native_support.so
+%{ruby_vendorlibdir}/phusion_passenger.rb
+%{ruby_vendorlibdir}/phusion_passenger
+
%dir %{_libdir}/phusion-passenger
%dir %{_libdir}/phusion-passenger/agents
-%attr(755,root,root) %{_libdir}/phusion-passenger/agents/Passenger*
+%attr(755,root,root) %{_libdir}/phusion-passenger/agents/PassengerLoggingAgent
+%attr(755,root,root) %{_libdir}/phusion-passenger/agents/PassengerWatchdog
%dir %{_libdir}/phusion-passenger/agents/apache2
%attr(755,root,root) %{_libdir}/phusion-passenger/agents/apache2/Passenger*
-%{ruby_rubylibdir}/phusion_passenger
-%{ruby_rubylibdir}/phusion_passenger.rb
%dir %{_datadir}/phusion-passenger
%dir %{_datadir}/phusion-passenger/helper-scripts
%attr(755,root,root) %{_datadir}/phusion-passenger/helper-scripts/*
-%{_mandir}/man1/*
-%{_mandir}/man8/*
%files ri
%defattr(644,root,root,755)