Ruby policy

Материал из Rosalab Wiki
Перейти к: навигация, поиск



It is highly recommended to generate rubygem packages using gem2rpm5 (available as a separate package) to follow a consistent layout and packaging policies as they develop.

If you succeed with gem2rpm5, you already has a package conforming to ROSA policy (and the rest of this document is just for your interest then).



These naming guidelines only apply to ruby packages whose main purpose is providing a Ruby library; packages that mainly provide user-level tools that happen to be written in Ruby do not need to follow these naming guidelines.

The name of a package containing ruby extension/library 'foo' must be of the form ruby-foo. If the upstream name 'foo' already contains "ruby", that should be dropped from the name. For example, the SQLite database driver for ruby is called sqlite3-ruby, the corresponding package should be called ruby-sqlite3, and not ruby-sqlite3-ruby.

Rpm Macros

The macros listed below are available for Ruby packagers. %ruby_foo macro is usually invocation of ruby -rrbconfig -e 'print Config::CONFIG["foo"]

Macro Description
%ruby_version Ruby version
%ruby_archdir A folder where Ruby extension modules should be installed
%ruby_libdir Location of the Ruby standard libraries
%ruby_sitearchdir A folder where arch-specific third party extensions (compiled *so files) should be installed
%ruby_sitelibdir Install destination for third party extensions
%ruby_gemdir A folder where gems are installed
%gem_build Launch gem_helper to build a gem
%gem_install Launch gem_helper to install a gem into build root


  • For Ruby extensions, group should be set to 'Development/Ruby'
  • BuildArch must be noarch for pure Ruby packages


  • In case of gems, packages should require 'rubygems'. Otherwise, 'ruby' should be required.
  • Arch dependent packages should require (at least) 'ruby-devel'.


  • Mandatory requirement ruby(abi) = VERSION is added automatically
  • 'rubygems' requirement for gems is added automatically, as well
  • Gems should not have other explicit requires as it is already added from the gemspec file


  • Packages should not have explicit provides, as they are automatically added by rpmbuild itself


It is highly recommended to follow the style of the spec generated by gem2rpm5:

# Generated from gem2rpm5-0.6.5.gem by gem2rpm5 0.6.5 -*- rpm-spec -*-
%define rbname  gem2rpm5

Summary:        Generate rpm .spec files from gems
Name:           rubygem-%{rbname}

Version:        0.6.5
Release:        1
Group:          Development/Ruby
License:        GPLv2+ or Ruby
BuildRequires:  rubygems 
BuildArch:      noarch

Generate source rpms and rpm spec files from a Ruby Gem using rpm5's
gem_helper, while following the gem as much as necessary  to  remain
compatible without the bloat.

%package        doc
Summary:        Documentation for %{name}
Group:          Books/Computer books
Requires:       %{name} = %{EVRD}

%description    doc
Documents, RDoc & RI documentation for %{name}.

%setup -q


rake test


%dir %{ruby_gemdir}/gems/%{rbname}-%{version}
%dir %{ruby_gemdir}/gems/%{rbname}-%{version}/bin
%dir %{ruby_gemdir}/gems/%{rbname}-%{version}/lib

%files doc
%dir %{ruby_gemdir}/gems/%{rbname}-%{version}/test

Policy in other distributions