|
| 1 | +# Generated from <%= spec.file_name %> by gem2rpm -*- rpm-spec -*- |
| 2 | +%global gem_name <%= spec.name %> |
| 3 | + |
| 4 | +Name: rubygem-%{gem_name} |
| 5 | +Version: <%= spec.version %> |
| 6 | +Release: 1%{?dist} |
| 7 | +Summary: <%= spec.summary.gsub(/\.$/, "") %> |
| 8 | +License: <%= spec.licenses.join(" and ") %> |
| 9 | +<% if spec.homepage -%> |
| 10 | +URL: <%= spec.homepage %> |
| 11 | +<% end -%> |
| 12 | +Source0: <%= download_path %>%{gem_name}-%{version}.gem |
| 13 | +BuildRequires: ruby(release) |
| 14 | +<% for req in spec.required_rubygems_version -%> |
| 15 | +BuildRequires: <%= requirement 'rubygems-devel', req %> |
| 16 | +<% end -%> |
| 17 | +<% for req in spec.required_ruby_version -%> |
| 18 | +BuildRequires: <%= requirement "ruby#{'-devel' unless spec.extensions.empty?}", req %> |
| 19 | +<% end -%> |
| 20 | +<% unless spec.extensions.empty? -%> |
| 21 | +# Compiler is required for build of gem binary extension. |
| 22 | +# https://fedoraproject.org/wiki/Packaging:C_and_C++#BuildRequires_and_Requires |
| 23 | +BuildRequires: gcc |
| 24 | +<% end -%> |
| 25 | +<%= development_dependencies.reject do |d| |
| 26 | + ["rdoc", "rake", "bundler"].include? d.name |
| 27 | +end.virtualize.with_requires.comment_out.to_rpm -%> |
| 28 | +<% if spec.extensions.empty? -%> |
| 29 | +BuildArch: noarch |
| 30 | +<% end -%> |
| 31 | + |
| 32 | +%description |
| 33 | +<%= spec.description %> |
| 34 | + |
| 35 | +<% if doc_subpackage -%> |
| 36 | +%package doc |
| 37 | +Summary: Documentation for %{name} |
| 38 | +Requires: %{name} = %{version}-%{release} |
| 39 | +BuildArch: noarch |
| 40 | + |
| 41 | +%description doc |
| 42 | +Documentation for %{name}. |
| 43 | +<% end # if doc_subpackage -%> |
| 44 | + |
| 45 | +%prep |
| 46 | +%setup -q -n %{gem_name}-%{version} |
| 47 | + |
| 48 | +%build |
| 49 | +# Create the gem as gem install only works on a gem file |
| 50 | +gem build ../%{gem_name}-%{version}.gemspec |
| 51 | + |
| 52 | +# %%gem_install compiles any C extensions and installs the gem into ./%%gem_dir |
| 53 | +# by default, so that we can move it into the buildroot in %%install |
| 54 | +%gem_install |
| 55 | + |
| 56 | +%install |
| 57 | +mkdir -p %{buildroot}%{gem_dir} |
| 58 | +cp -a .%{gem_dir}/* \ |
| 59 | + %{buildroot}%{gem_dir}/ |
| 60 | + |
| 61 | +<% unless spec.extensions.empty? -%> |
| 62 | +mkdir -p %{buildroot}%{gem_extdir_mri} |
| 63 | +cp -a .%{gem_extdir_mri}/{gem.build_complete,*.so} %{buildroot}%{gem_extdir_mri}/ |
| 64 | + |
| 65 | +<% for ext in spec.extensions -%> |
| 66 | +# Prevent dangling symlink in -debuginfo (rhbz#878863). |
| 67 | +rm -rf %{buildroot}%{gem_instdir}/<%= ext.split(File::SEPARATOR).first %>/ |
| 68 | +<% end -%> |
| 69 | +<% end -%> |
| 70 | + |
| 71 | +<% unless spec.executables.empty? -%> |
| 72 | +mkdir -p %{buildroot}%{_bindir} |
| 73 | +cp -a .%{_bindir}/* \ |
| 74 | + %{buildroot}%{_bindir}/ |
| 75 | + |
| 76 | +find %{buildroot}%{gem_instdir}/<%= spec.bindir %> -type f | xargs chmod a+x |
| 77 | +<% end -%> |
| 78 | + |
| 79 | +%check |
| 80 | +pushd .%{gem_instdir} |
| 81 | +<% if tests.entries.empty? -%> |
| 82 | +# Run the test suite. |
| 83 | +<% end -%> |
| 84 | +<% for t in tests -%> |
| 85 | +# <%= t.command %> |
| 86 | +<% end -%> |
| 87 | +popd |
| 88 | + |
| 89 | +%files |
| 90 | +%dir %{gem_instdir} |
| 91 | +<% for f in spec.executables -%> |
| 92 | +%{_bindir}/<%= f %> |
| 93 | +<% end -%> |
| 94 | +<% unless spec.extensions.empty? -%> |
| 95 | +%{gem_extdir_mri} |
| 96 | +<% end -%> |
| 97 | +<%= main_files.reject do |item| |
| 98 | + spec.extensions.detect { |extension| item =~ /^#{extension.split(File::SEPARATOR).first}$/} |
| 99 | +end.to_rpm %> |
| 100 | +<% unless doc_subpackage -%> |
| 101 | +%doc %{gem_docdir} |
| 102 | +<%= doc_files.to_rpm %> |
| 103 | +<% end -%> |
| 104 | +%exclude %{gem_cache} |
| 105 | +%{gem_spec} |
| 106 | + |
| 107 | +<% if doc_subpackage -%> |
| 108 | +%files doc |
| 109 | +%doc %{gem_docdir} |
| 110 | +<%= doc_files.to_rpm %> |
| 111 | +<% end # if doc_subpackage -%> |
| 112 | + |
| 113 | +%changelog |
| 114 | +* <%= Time.now.strftime("%a %b %d %Y") %> <%= packager %> - <%= spec.version %>-1 |
| 115 | +- Initial package |
0 commit comments