File rubygem-eventmachine-le.spec.template of Package rubygem-eventmachine-le

# gem2rpm -t rubygem-eventmachine-le.spec.template eventmachine-le-*.gem -o rubygem-eventmachine-le.spec
#
# spec file for package rubygem-<%= spec.name %>
#
# Copyright (c) <%= Time.now.year %> SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#


Name:           rubygem-<%= spec.name %>
Version:        <%= spec.version %>
Release:        0
%define mod_name <%= spec.name %>
%define mod_full_name %{mod_name}-%{version}
<% unless spec.executables.empty? 
   versions=spec.version.to_s.split('.')
   begin v1=Integer(versions[0]) rescue v1=1 end
   begin v2=Integer(versions[1]) rescue v2=0 end
   begin v3=Integer(versions[2]) rescue v3=0 end 
   weight=v1*10000+v2*100+v3
   -%>
%define mod_branch -%{version}
%define mod_weight <%= weight %>
<% end -%>

BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildRequires:  ruby-macros >= 3
<% for req in spec.required_ruby_version -%>
<% unless req.empty? -%>
Requires:       ruby <%= req %>
BuildRequires:  ruby <%= req %>
<% end -%>
<% end -%>
<% unless spec.extensions.empty? -%>
BuildRequires:  ruby-devel
<% end -%>
<% for d in spec.runtime_dependencies -%>
<% if ['rdoc'].include? d.name.to_s -%>
# <%= d.name %> <%= d.__getobj__().requirement %>
<% for req in d.requirement -%>
BuildRequires:  rubygem(<%= d.name %>) <%= req  %>
<% end -%>
<% end -%>
<% end -%>
<% unless spec.rdoc_options.empty? -%>
BuildRequires:  rubygem(rdoc) > 3.10
<% end -%>
<% unless spec.executables.empty? -%>
BuildRequires:  update-alternatives
<% end -%>
BuildRequires:  gcc-c++
<% unless spec.homepage.nil? || spec.homepage.empty? -%>
Url:            <%= spec.homepage %>
<% end -%>
Source:         http://rubygems.org/gems/%{mod_full_name}.gem
Summary:        <%= spec.summary %>
<% unless spec.licenses.empty? -%>
License:        <%= spec.licenses.join(" and ") %>
<% else -%>
License:        CHECK(Ruby)
<% end -%>
Group:          Development/Languages/Ruby
<% unless spec.executables.empty? -%>
PreReq:         update-alternatives
<% end -%>

%description
<%= spec.description -%>

<% if spec.has_rdoc -%>
%package doc
Summary:        RDoc documentation for %{mod_name}
Group:          Development/Languages/Ruby
Requires:       %{name} = %{version}

%description doc
Documentation generated at gem installation time.
Usually in RDoc and RI formats.

<% end -%>
<% test_frameworks = Hash.new
   docdirfiles = []
   format.file_entries.each do |entry|
     # new rubygems version has it different
     if entry.kind_of?(Array)
       path=entry[0]['path']
     else
       path=entry
     end
     path.gsub!(%r{^\./}, '')
     %w(test spec).each { |framework|
       test_frameworks[framework] = 1 if path.index(framework + "/") == 0
     }
     %w(changes copying history legal license mit-license changelog readme).each { |file|
      bpath = path.downcase.gsub(%r{\.rdoc$}, '').gsub(%r{\.txt$}, '').gsub(%r{\.md$}, '')
      #$stderr.puts "PATH #{path} #{bpath} #{file}"
      docdirfiles << path if bpath == file
     }
   end
   
   test_frameworks = test_frameworks.keys.sort
-%>
<% unless test_frameworks.empty? -%>
%package testsuite
Summary:        Test suite for %{mod_name}
Group:          Development/Languages/Ruby
Requires:       %{name} = %{version}

%description testsuite
Test::Unit or RSpec files, useful for developers.

<% end -%>
%prep
#gem_unpack
#if you need patches, apply them here and replace the # with a % sign in the surrounding lines
#gem_build

%build

%install
%gem_install -f --no-rdoc
<% unless spec.extensions.empty? -%>
%gem_cleanup
<% end -%>
<% unless spec.executables.empty? -%>
mkdir -p %{buildroot}%{_sysconfdir}/alternatives
<% end -%>
<% spec.executables.each do |executable| -%>
mv %{buildroot}%{_bindir}/<%= executable %>{,%{mod_branch}}
touch %{buildroot}%{_sysconfdir}/alternatives/<%= executable %>
ln -s %{_sysconfdir}/alternatives/<%= executable %> %{buildroot}%{_bindir}/<%= executable %>

<% end -%>
<% unless docdirfiles.empty? -%>
mkdir -p %{buildroot}%{_docdir}/%{name}
<% docdirfiles.each do |file| -%>
ln -s %{gem_base}/gems/%{mod_full_name}/<%= file %> %buildroot/%{_docdir}/%{name}/<%= file %>
<% end -%>
<% end -%>
find %{buildroot}%{gem_base}/gems/%{mod_full_name}/ext -name \*.c -o -name \*.cpp -o -name \*.h | xargs rm -f
<% unless spec.executables.empty? -%>

%post
<% spec.executables.each do |executable| -%>
/usr/sbin/update-alternatives --install \
    %{_bindir}/<%= executable %> <%= executable %> %{_bindir}/<%= executable %>%{mod_branch} %{mod_weight}
<% end -%>

%preun
<% spec.executables.each do |executable| -%>
if [ "$1" = 0 ] ; then
    /usr/sbin/update-alternatives --remove <%= executable %> %{_bindir}/<%= executable %>%{mod_branch}
fi
<% end -%>
<% end -%>

%files
%defattr(-,root,root,-)
<% unless docdirfiles.empty? -%>
%{_docdir}/%{name}
<% end -%>
<% spec.executables.each do |executable| -%>
%{_bindir}/<%= executable %>%{mod_branch}
%{_bindir}/<%= executable %>
%ghost %{_sysconfdir}/alternatives/<%= executable %>
<% end -%>
%{gem_base}/cache/%{mod_full_name}.gem
%{gem_base}/gems/%{mod_full_name}/
<% unless spec.extensions.empty? -%>
%{gem_extensions}/%{mod_full_name}
<% end -%>
<% test_frameworks.each do |framework| -%>
%exclude %{gem_base}/gems/%{mod_full_name}/<%= framework %>
<% end -%>
%{gem_base}/specifications/%{mod_full_name}.gemspec

<% if spec.has_rdoc -%>
%files doc
%defattr(-,root,root,-)
%doc %{gem_base}/doc

<% end -%>
<% unless test_frameworks.empty? -%>
%files testsuite
%defattr(-,root,root,-)
<%   test_frameworks.each do |framework| -%>
%{gem_base}/gems/%{mod_full_name}/<%= framework %>
<%   end -%>

<% end -%>
%changelog
openSUSE Build Service is sponsored by