Ruby policy
Contents
Tools
gem2rpm5
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).
Rules
Naming
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 or rubygem-foo for the case when package is built from a gem. 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 "pkg|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 |
Tags
- For Ruby extensions, group should be set to 'Development/Ruby'
- BuildArch must be noarch for pure Ruby packages
BuildRequires
- In case of gems, packages should require 'rubygems'. Otherwise, 'ruby' should be required.
- Arch dependent packages should require (at least) 'ruby-devel'.
Requires
- 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
Provides
- Packages should not have explicit provides, as they are automatically added by rpmbuild itself
Samples
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 URL: http://gitorious.org/rpm5distro/gem2rpm5 Source0: http://gems.rubyforge.org/gems/%{rbname}-%{version}.gem BuildRequires: rubygems BuildArch: noarch %description 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}. %prep %setup -q %build %gem_build %check rake test %install %gem_install %files %{_bindir}/gem2rpm5 %dir %{ruby_gemdir}/gems/%{rbname}-%{version} %dir %{ruby_gemdir}/gems/%{rbname}-%{version}/bin %{ruby_gemdir}/gems/%{rbname}-%{version}/bin/gem2rpm5 %dir %{ruby_gemdir}/gems/%{rbname}-%{version}/lib %{ruby_gemdir}/gems/%{rbname}-%{version}/lib/*.rb %{ruby_gemdir}/specifications/%{rbname}-%{version}.gemspec %files doc %{ruby_gemdir}/doc/%{rbname}-%{version} %{ruby_gemdir}/gems/%{rbname}-%{version}/AUTHORS %{ruby_gemdir}/gems/%{rbname}-%{version}/LICENSE %{ruby_gemdir}/gems/%{rbname}-%{version}/README %dir %{ruby_gemdir}/gems/%{rbname}-%{version}/test %{ruby_gemdir}/gems/%{rbname}-%{version}/test/*.rb