|
# FIXME:
|
|
# 1. Edit foreman requirement(s) and specify minimum version
|
|
# 2. Delete these lines
|
|
#
|
|
# Generated from <%= package.spec.file_name %> by gem2rpm -*- rpm-spec -*-
|
|
# template: foreman_plugin
|
|
<%-
|
|
require 'json'
|
|
SCL_PREFIXES = JSON.load(File.read(File.join(`git rev-parse --show-toplevel`.strip, 'scl_prefixes.json')))
|
|
-%>
|
|
%{?scl:%scl_package rubygem-%{gem_name}}
|
|
%{!?scl:%global pkg_name %{name}}
|
|
|
|
%global gem_name <%= spec.name %>
|
|
%global plugin_name <%= spec.name.sub(/\Aforeman_/, '') %>
|
|
%global foreman_min_version FIXME
|
|
<%
|
|
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-') }
|
|
has_webpack = spec.files.any? { |f| f.start_with?('webpack/') }
|
|
|
|
precompile_flags = ''
|
|
precompile_flags << ' -a' if has_apidoc
|
|
precompile_flags << ' -s' if has_assets || has_webpack
|
|
|
|
config.rules[:doc] << /\/?CHANGES/
|
|
config.rules[:ignore] << '.hound.yml'
|
|
config.rules[:ignore] << '.rubocop_todo.yml'
|
|
config.rules[:ignore] << 'package.json'
|
|
config.rules[:ignore] << /.eslint(rc|ignore)/
|
|
config.rules[:ignore] << /.tx(\/.*)?/
|
|
config.rules[:ignore] << /webpack(\/.*)?/
|
|
-%>
|
|
|
|
Name: %{?scl_prefix}rubygem-%{gem_name}
|
|
Version: <%= spec.version %>
|
|
Release: 1%{?foremandist}%{?dist}
|
|
Summary: <%= spec.summary.gsub(/\.$/, "") %>
|
|
Group: Applications/Systems
|
|
License: <%= spec.licenses.empty? ? 'FIXME' : spec.licenses.join(" and ") %>
|
|
<% if spec.homepage -%>
|
|
URL: <%= spec.homepage %>
|
|
<% end -%>
|
|
Source0: <%= download_path %>%{gem_name}-%{version}.gem
|
|
|
|
# start generated dependencies
|
|
Requires: foreman >= %{foreman_min_version}
|
|
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<%= SCL_PREFIXES[d.name] %>}rubygem(<%= d.name %>) <%= req %>
|
|
<% end -%>
|
|
<% end -%>
|
|
<% if has_assets || has_webpack -%>
|
|
BuildRequires: foreman-assets >= %{foreman_min_version}
|
|
<% end -%>
|
|
BuildRequires: foreman-plugin >= %{foreman_min_version}
|
|
<% if has_assets || has_webpack || has_apidoc -%>
|
|
<% for d in spec.runtime_dependencies -%>
|
|
<% for req in d.requirement -%>
|
|
BuildRequires: %{?scl_prefix<%= SCL_PREFIXES[d.name] %>}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 -%>
|
|
# end generated dependencies
|
|
|
|
%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) %>
|
|
<% 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 has_webpack -%>
|
|
%{foreman_webpack_plugin}
|
|
%{foreman_webpack_foreman}
|
|
<% 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
|