Ruby Packaging

Ruby Custom and Fast Track Repositories

Ergo Project has a variety of Ruby repositories available. If we go over them branch by branch, then for Enterprise Linux 5, we have the following repositories available:

  • custom
    The custom ruby repository for Enterprise Linux 5 systems includes packages that are not available (yet) through regular distribution channels. Regular distribution channels include Red Hat Network (basic subscription), CentOS repositories (addon, extras) as well as Extra Packages for Enterprise Linux repositories by the Fedora Project. Such packages include, for example, rubygem-passenger (a.k.a. mod_rails or mod_rack).
  • feature-ruby-1.8.6
    This is an Enterprise Linux 5 Ruby 1.8.6 Fast-Track channel.
  • feature-ruby-1.8.7
    This is an Enterprise Linux 5 Ruby 1.8.7 Fast-Track channel.
  • feature-ruby-1.9.1
    This is an Enterprise Linux 5 Ruby 1.9.1 Fast-Track channel.

Since a stock installation of an Enterprise Linux 5 generation ships ruby 1.8.5, the feature* repositories mentioned here are considered Fast-Tracks, as they override the packages available in the distribution itself. The custom repository however is not supposed to override any packages, but instead add to the Enterprise Linux basic software channels.

To package just one package for these repositories, one may need a little help from the system as well as the build system. For example, maintaining 2 versions of a single spec file just because one repository forces you to use "Requires: ruby(abi) = 1.8" while the other forces you to use "Requires: ruby(abi) = 1.9" is rather inefficient. Instead, we let the buildroot tell the binary package build process what ruby(abi) version the binary package is to require. This way, a package maintainer can use one single version of the spec file across all repositories.

/etc/rpm/macros.ruby

The ruby package provides the /etc/rpm/macros.ruby file. This file contains macros to ease the packaging of ruby libraries and gems.

The contents are, in order:

Ruby ABI/API Macros

The %{rubyabi} and %{rubyapi} macros define the version of Ruby. When used in a package .spec file, it looks like:

Requires: ruby(abi) = %{rubyabi}

The package spec is now truly portable between different versions of Ruby (1.8.5, 1.8.6, 1.8.7, 1.9.1, 1.9.2) and no longer requires a certain mainstream Ruby API/ABI to build. However, on the installed system, the package would still require ruby(api) = 1.8.6, for example.

This both prevents the system from using Ruby 1.8.7 module packages such as libraries and gems without also installing a package providing the 1.8.7 API or ABI, as well as prevents unintentional teeny upgrades on a system.

Ruby Filesystem Locations

For everything that is local, or not packaged, /usr/local/ is used. /etc/rpm/macros.ruby provides the following shortcuts to these local (site) directories. There's two variants; architecture specific, en architecture independent.

%ruby_sitearch      => %{_prefix}/local/%{_lib}/ruby/
%ruby_sitelib => %{_prefix}/local/share/ruby/

These directories though are in /usr/local/ (site specific and not upstream or unmanaged). The directories you should be looking for when packaging ruby extensions or gems, are:

%ruby_vendorarch  => %{_libdir}/ruby/
%ruby_vendorlib => %{_datadir}/ruby/

Package Guideline Changes

Compared to former packaging guidelines, here's a list of changes:

  1. %{gemdir} points to /usr/share/ruby/ through %{vendorlib}
  2. gem installations go to %{buildroot}/%{gemdir}
  3. %{geminstdir} is now %{gemdir}/gems/%{gemname}-%{version}