Skip to content

Instantly share code, notes, and snippets.

@liyanage
Created June 9, 2009 14:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save liyanage/126544 to your computer and use it in GitHub Desktop.
Save liyanage/126544 to your computer and use it in GitHub Desktop.
# An RPM spec file to build the Phusion Passenger Apache 2 module
# as a binary RPM for CentOS 5 / Red Hat Enterprise Linux 5.
#
# Written by Marc Liyanage for futureLAB AG
#
%define gem_name passenger
%define gem_description Phusion Passenger is a deployment system for Ruby on Rails applications on Apache, i.e. a 'mod_rails'
Summary: rubygem-%{gem_name} - %{gem_description}
Name: rubygem-%{gem_name}
Version: 2.2.2
Release: 3.fL
License: GPL
Group: Development/Libraries
BuildRoot: %{_tmppath}/%{name}-%{version}-root
BuildRequires: rubygems, rubygem-rake >= 0.8.1, ruby-devel, rubygem-fastthread >= 1.0.1
Requires: rubygem-fastthread >= 1.0.1
BuildArch: i386
URL: http://rubyforge.org/projects/%{gem_name}/
Prefix: %{_prefix}
Docdir: %{_docdir}
%define ruby_version %(ruby -e 'print RUBY_VERSION.gsub(/\\.\\d+$/, "")')
%define gems_dir %{_libdir}/ruby/gems/%{ruby_version}
%define gem_tmp_home /tmp/gem_tmp_home
%define apache_modules_dir %{_libdir}/httpd/modules
%description
%{gem_description}
%install
rm -rf %{buildroot} %{gem_tmp_home}
mkdir %{gem_tmp_home}
HOME=%{gem_tmp_home} gem install %{gem_name} --version %{version} --ignore-dependencies --no-rdoc --no-ri --install-dir %{buildroot}%{gems_dir} --bindir %{buildroot}%{_bindir}
rm -rf %{buildroot}%{gems_dir}/cache
# rpmbuild's python_burninversion.sh script does not handle spaces in filenames
# but some of passenger's docs files have them, so we replace all spaces with underscores
find %{buildroot}%{gems_dir}/gems/%{gem_name}-%{version}/doc -name '* *' -execdir sh -c 'mv "$0" $(echo $0 | tr " " _)' {} \;
# some of passenger's scripts refer to ruby as ruby1.8 and RPM picks those up as dependencies,
# but our ruby doesn't provide that so we have to change these references
find %{buildroot} -type f -exec grep -q ruby1.8 {} \; -exec sed -i -e 's/ruby1.8/ruby/' {} \;
# run passenger's actual Apache module build process
GEM_HOME=%{buildroot}/%{gems_dir} %{buildroot}/%{_bindir}/passenger-install-apache2-module --auto
# and place a symlink to the module into the regular apache modules directory
mkdir -p %{buildroot}/%{apache_modules_dir}
ln -s %{gems_dir}/gems/passenger-%{version}/ext/apache2/mod_passenger.so %{buildroot}/%{apache_modules_dir}
# create a stable 'current' symlink entry in the gems dir so that
# we don't have to change the apache config (PassengerRoot directive)
# every time the passenger version changes.
ln -s %{gems_dir}/gems/passenger-%{version} %{buildroot}/%{gems_dir}/gems/passenger-current
%clean
rm -rf %{buildroot}
%files
%defattr(-, root, root)
%{gems_dir}/gems/%{gem_name}-*
%{gems_dir}/specifications/%{gem_name}-*
%{_bindir}/%{gem_name}*
%{apache_modules_dir}/*
%changelog
* Fri Jun 08 2009 Marc Liyanage <mliyanage@futurelab.ch> - 2.2.2-1
- initial packaging
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment