Ruby packaging policy

From Mandriva Community Wiki

(Redirected from Policies/Ruby)
Jump to: navigation, search
This page is a draft. It requires improvements.
If you want to contribute, simply click on the edit tab. View the other pages to improve and maintain.

Contents

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 ruby extension/library package must be of the form ruby-UPSTREAM. If the upstream name "UPSTREAM" 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.


Macros

The following macros are defined in /etc/rpm/macros.d/ruby.macros which is provided by ruby rpm, and use ruby themselves, so you always need to BuildRequire at least ruby.

  • %ruby_version %(ruby -rrbconfig -e 'print Config::CONFIG["ruby_version"]')
  • %ruby_archdir %(ruby -rrbconfig -e 'print Config::CONFIG["archdir"]')
  • %ruby_libdir %(ruby -rrbconfig -e 'print Config::CONFIG["rubylibdir"]')
  • %ruby_sitearchdir %(ruby -rrbconfig -e 'print Config::CONFIG["sitearchdir"]')
  • %ruby_sitelibdir %(ruby -rrbconfig -e 'print Config::CONFIG["sitelibdir"]')
  • %ruby_gemdir %(ruby -rrbconfig -e 'include Config; print CONFIG["rubylibdir"].sub(CONFIG["ruby_version"], "gems/#{CONFIG["ruby_version"]}")')
  • %ruby_ridir %(ruby -rrbconfig -e 'include Config; print File.join(CONFIG["datadir"], "ri", CONFIG["ruby_version"])')
  • %gem_build
  • %gem_install

Tags

  • Group should be Development/Ruby
  • BuildArch must be noarch for pure ruby packages

BuildRequires

  • In the case of gems, packages should require rubygems
  • Arch dependant packages should require (at least) ruby-devel.

Requires

  • Packages should require ruby(abi) = VERSION. VERSION might be optional if the module you plan to include is compatible with both ruby-1.8 and ruby-1.9 (ex: gitorious)
  • Gems must require rubygems (should be automatically added during build, you don’t have to add it yourself
  • Gems shouldn’t have other explicit requires as it is already added from the gemspec file. – 2010-14-12 note that this is a work-in-progress move, automatic requires are not already the rule in current specs

Provides

  • Packages shouldn’t have explicit provides, as it is automatically added in rpmbuild itself

Suggests

  • Rubygems may have two dependency types. Runtime dependencies (which are automatically added as the package is built) and development dependencies. The latter ones do not mean that the package is mandatory to build the package, but that these can be used to hack on these packages. Adding these as suggests might be a good option (needs to be discussed). – 2010-19-12 maybe these could be required to build the packages in the case we add a %check section that runs tests. That is not always the case at the moment, this needs to be discussed too.

– 2011-01-08 : Suggests might not be a good idea since by default suggests are activated, thus, an automated install would result in useless packages pulled. A preferred way would be to create a devel subpackage which will pull these dependencies only when needed. Support for this has to be implemented in rubygems.rb – 2011-01-21 Since these dependencies are used for testing the module, a -devel subpackage is not required, instead, add these dependencies as BuildRequires and add a %check section that will test the module

Samples

Generating rubygem packages with gem2rpm5 is highly recommended to follow a consistent layout and packaging policies as they develop.

# 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. The spec file is
adapted to first of all follow Mandriva Linux packaging guidelines, 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

%changelog
* Sat Mar 19 2011 Per Øyvind Karlsen <peroyvind@mandriva.org> 0.6.5-1
- Initial package generated by gem2rpm5

Policy in other distributions

Personal tools