Project

General

Profile

Download (5.19 KB) Statistics
| Branch: | Tag: | Revision:
# FIXME:
# 1. Change scl_prefix to _ruby or _ror for Requires/BuildRequires that are
# in Ruby or Rails software collections (not Foreman's)
# 2. Edit foreman requirement(s) and specify minimum version
# 3. Delete these lines
#
# Generated from <%= package.spec.file_name %> by gem2rpm -*- rpm-spec -*-
%{?scl:%scl_package rubygem-%{gem_name}}
%{!?scl:%global pkg_name %{name}}

%global gem_name <%= spec.name %>
%global plugin_name <%= spec.name.sub(/\Aforeman_/, '') %>
<%
has_assets = spec.files.any? { |f| f.start_with?('app/assets/') }
has_apidoc = spec.files.any? { |f| f =~ %r{\Aapp/controllers/?.*/api/} }
has_db_migrations = spec.files.any? { |f| f.start_with?('db/migrate/') }
has_db_seeds = spec.files.any? { |f| f.start_with?('db/seeds.d/') }
has_compute = spec.runtime_dependencies.any? { |d| d.name.start_with?('fog-') }

precompile_flags = ''
precompile_flags << ' -a' if has_apidoc
precompile_flags << ' -s' if has_assets

config.rules[:doc] << /\/?CHANGES/
config.rules[:ignore] << /.tx(\/.*)?/
-%>

Name: %{?scl_prefix}rubygem-%{gem_name}
Version: <%= spec.version %>
Release: 1%{?foremandist}%{?dist}
Summary: <%= spec.summary.gsub(/\.$/, "") %>
Group: Applications/Systems
License: <%= spec.licenses.join(" and ") %>
<% if spec.homepage -%>
URL: <%= spec.homepage %>
<% end -%>
Source0: <%= download_path.sub('https:', 'http:') %>%{gem_name}-%{version}.gem
Requires: foreman >= FIXME
Requires: %{?scl_prefix_ruby}ruby(release)
<% for req in spec.required_ruby_version -%>
Requires: %{?scl_prefix_ruby}ruby <%= req %>
<% end -%>
<% for req in spec.required_rubygems_version -%>
Requires: %{?scl_prefix_ruby}ruby(rubygems) <%= req %>
<% end -%>
<% for d in spec.runtime_dependencies -%>
<% for req in d.requirement -%>
Requires: %{?scl_prefix}rubygem(<%= d.name %>) <%= req %>
<% end -%>
<% end -%>
<% if has_assets -%>
BuildRequires: foreman-assets
<% end -%>
BuildRequires: foreman-plugin >= FIXME
<% if has_assets || has_apidoc -%>
<% for d in spec.runtime_dependencies -%>
<% for req in d.requirement -%>
BuildRequires: %{?scl_prefix}rubygem(<%= d.name %>) <%= req %>
<% end -%>
<% end -%>
<% end -%>
BuildRequires: %{?scl_prefix_ruby}ruby(release)
<% for req in spec.required_ruby_version -%>
BuildRequires: %{?scl_prefix_ruby}ruby<%= "-devel" unless spec.extensions.empty? %> <%= req %>
<% end -%>
<% for req in spec.required_rubygems_version -%>
BuildRequires: %{?scl_prefix_ruby}rubygems-devel <%= req %>
<% end -%>
<% if spec.extensions.empty? -%>
BuildArch: noarch
<% end -%>
Provides: %{?scl_prefix}rubygem(%{gem_name}) = %{version}
Provides: foreman-plugin-%{plugin_name}
<% if has_compute -%>
Provides: foreman-%{plugin_name}
<% end -%>

%description
<%= spec.description %>

<% if doc_subpackage -%>
%package doc
Summary: Documentation for %{pkg_name}
Group: Documentation
Requires: %{?scl_prefix}%{pkg_name} = %{version}-%{release}
BuildArch: noarch

%description doc
Documentation for %{pkg_name}.
<% end # if doc_subpackage -%>

%prep
%{?scl:scl enable %{scl} - << \EOF}
gem unpack %{SOURCE0}
%{?scl:EOF}

%setup -q -D -T -n %{gem_name}-%{version}

%{?scl:scl enable %{scl} - << \EOF}
gem spec %{SOURCE0} -l --ruby > %{gem_name}.gemspec
%{?scl:EOF}

%build
# Create the gem as gem install only works on a gem file
%{?scl:scl enable %{scl} - << \EOF}
gem build %{gem_name}.gemspec
%{?scl:EOF}

# %%gem_install compiles any C extensions and installs the gem into ./%%gem_dir
# by default, so that we can move it into the buildroot in %%install
%{?scl:scl enable %{scl} - << \EOF}
%gem_install
%{?scl:EOF}

%install
mkdir -p %{buildroot}%{gem_dir}
cp -pa .%{gem_dir}/* \
%{buildroot}%{gem_dir}/

<% unless spec.extensions.empty? -%>
mkdir -p %{buildroot}%{gem_extdir_mri}
cp -a .%{gem_extdir_mri}/{gem.build_complete,*.so} %{buildroot}%{gem_extdir_mri}/

<% for ext in spec.extensions -%>
# Prevent dangling symlink in -debuginfo (rhbz#878863).
rm -rf %{buildroot}%{gem_instdir}/<%= ext.split(File::SEPARATOR).first %>/
<% end -%>

<% end -%>
<% unless spec.executables.nil? or spec.executables.empty? -%>
mkdir -p %{buildroot}%{_bindir}
cp -pa .%{_bindir}/* \
%{buildroot}%{_bindir}/
find %{buildroot}%{gem_instdir}/bin -type f | xargs chmod a+x

<% end -%>
%foreman_bundlerd_file
<% unless precompile_flags.strip.empty? -%>
%foreman_precompile_plugin <%= precompile_flags.strip %>
<% end -%>

%files
%dir %{gem_instdir}
<% unless spec.executables.nil? or spec.executables.empty? -%>
<% for f in spec.executables -%>
%{_bindir}/<%= f %>
<% end -%>
<% end -%>
<% unless spec.extensions.empty? -%>
%exclude %{gem_instdir}/ext
%{gem_extdir_mri}
<% end -%>
<%= main_file_entries(spec).gsub(/^%license/, '%doc') %>
<% unless doc_subpackage -%>
%doc %{gem_docdir}
<%= doc_file_entries(spec) %>
<% end -%>
%exclude %{gem_cache}
%{gem_spec}
%{foreman_bundlerd_plugin}
<% if has_apidoc -%>
%{foreman_apipie_cache_foreman}
%{foreman_apipie_cache_plugin}
<% end -%>
<% if has_assets -%>
%{foreman_assets_plugin}
<% end -%>

<% if doc_subpackage -%>
%files doc
%doc %{gem_docdir}
<%= doc_file_entries(spec) %>
<% end # if doc_subpackage -%>

%posttrans
<% if has_db_migrations -%>
%{foreman_db_migrate}
<% end -%>
<% if has_db_seeds -%>
%{foreman_db_seed}
<% end -%>
<% if has_apidoc -%>
%{foreman_apipie_cache}
<% end -%>
%{foreman_restart}
exit 0

%changelog
(1-1/5)