Ruby SIG:Draft Package Guidelines/Example Ruby Lib Spec

From FedoraProject

Jump to: navigation, search

A .spec could look like:

%global ruby_libname packagingtest
# In case you choose some of the system wide macros
%global ruby_versions 1.8.6 1.8.7 1.9.1

Name:           ruby-%{ruby_libname}
Version:        0.1
Release:        1%{?dist}
Summary:        Packaging test for Ruby

Group:          Development/Tools
License:        GPLv2+
URL:            http://www.example.org
BuildRoot:      %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
Source0:        packagingtest.txt.tar.gz

# Either execute some custom sequence similar to the following:
%(for ruby_version in 1.8.6 1.8.7 1.9.1; do echo "

%package -n ruby-${ruby_version}-%{ruby_libname}
BuildRequires:  ruby-${ruby_version}
# or,
BuildRequires:  ruby(abi) = ${ruby_version}
Requires:       ruby(abi) = ${ruby_version}
Summary:        Ruby ${ruby_version} version of this package

%description -n ruby-${ruby_version}-%{ruby_libname}
Some description for the Ruby ${ruby_version} version of this
package

"; done)

# or, use a system wide macro:
%ruby_multiver_package
%description
Some description for the Ruby library

%prep
# Again, either execute some custom sequence similar to the following:
%(for ruby_version in 1.8.6 1.8.7 1.9.1; do echo "

%setup -q -c -n ruby-${ruby_version}-%{ruby_libname}

"; done)

# or use a system wide macro:
%ruby_multiver_setup

%build
cd %{_builddir}

# This function needs to be in the .spec as expansion results in
# things going FUBAR.
function buildit() {
%configure --with-ruby=ruby-$1
}

# Again either use something customizable
%(for ruby_version in 1.8.6 1.8.7 1.9.1; do echo "
pushd ruby-${ruby_version}-%{ruby_libname}
buildit ${ruby_version}
make %{?_smp_mflags}
popd

"; done)

# or use a system wide macro:
%ruby_multiver_build

%install
rm -rf %{buildroot}
%(for ruby_version in 1.8.6 1.8.7 1.9.1; do echo "

pushd ./${ruby_version}
make install DESTDIR=%{buildroot}

"; done)

%clean
rm -rf $RPM_BUILD_ROOT

%files
%defattr(-,root,root,-)
%doc

%changelog
* Sun Jul 27 2010 Jeroen van Meeuwen <kanarip@fedoraproject.org> - 0.1-1
- Do some foo