-
Notifications
You must be signed in to change notification settings - Fork 145
/
smart_proxy_plugin.spec.erb
176 lines (154 loc) · 5.77 KB
/
smart_proxy_plugin.spec.erb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
# template: smart_proxy_plugin
<%-
require 'json'
root = `git rev-parse --show-toplevel`.strip
SCL_PREFIXES = JSON.load(File.read(File.join(root, 'scl_prefixes.json')))
LICENSES = JSON.load(File.read(File.join(root, 'licenses.json')))
has_cronjob = spec.files.any? { |f| f =~ %r{\Aextra/.*\.cron\z }
-%>
%{?scl:%scl_package rubygem-%{gem_name}}
%{!?scl:%global pkg_name %{name}}
%{!?_root_bindir:%global _root_bindir %{_bindir}}
%{!?_root_datadir:%global _root_datadir %{_datadir}}
%{!?_root_localstatedir:%global _root_localstatedir %{_localstatedir}}
%{!?_root_sysconfdir:%global _root_sysconfdir %{_sysconfdir}}
%global gem_name <%= spec.name %>
%global plugin_name <%= spec.name.sub(/\Asmart_proxy_/, '') %>
%global foreman_proxy_min_version 1.24
%global foreman_proxy_dir %{_root_datadir}/foreman-proxy
%global foreman_proxy_statedir %{_root_localstatedir}/foreman-proxy
%global foreman_proxy_bundlerd_dir %{foreman_proxy_dir}/bundler.d
%global foreman_proxy_settingsd_dir %{_root_sysconfdir}/foreman-proxy/settings.d
%global smart_proxy_dynflow_bundlerd_dir %{!?scl:/opt/theforeman/tfm/root}%{_datadir}/smart_proxy_dynflow_core/bundler.d
Name: %{?scl_prefix}rubygem-%{gem_name}
Version: <%= spec.version %>
Release: 1%{?foremandist}%{?dist}
Summary: <%= spec.summary.gsub(/\.$/, "") %>
Group: Applications/Internet
License: <%= spec.licenses.empty? ? 'FIXME' : spec.licenses.map { |l| LICENSES.fetch(l, l) }.join(" and ") %>
<% if spec.homepage -%>
URL: <%= spec.homepage %>
<% end -%>
Source0: <%= download_path %>%{gem_name}-%{version}.gem
# start specfile generated dependencies
Requires: foreman-proxy >= %{foreman_proxy_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 -%>
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-proxy-plugin-%{plugin_name} = %{version}
# end specfile generated dependencies
%description
<%= spec.description %>
<% if doc_subpackage -%>
%package doc
Summary: Documentation for %{name}
Group: Documentation
Requires: %{name} = %{version}-%{release}
BuildArch: noarch
%description doc
Documentation for %{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 -a .%{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 -a .%{_bindir}/* \
%{buildroot}%{_bindir}/
find %{buildroot}%{gem_instdir}/<%= spec.bindir %> -type f | xargs chmod a+x
<% end -%>
# bundler file
mkdir -p %{buildroot}%{foreman_proxy_bundlerd_dir}
mv %{buildroot}%{gem_instdir}/bundler.d/%{plugin_name}.rb \
%{buildroot}%{foreman_proxy_bundlerd_dir}
# sample config
mkdir -p %{buildroot}%{foreman_proxy_settingsd_dir}
<% config_file_paths = spec.files.select { |f| f.start_with?('config/') } +
spec.files.select { |f| f.start_with?('settings.d/') } -%>
<% config_file_paths.each do |config_file_path| -%>
<% config_file = config_file_path.split('/').last -%>
mv %{buildroot}%{gem_instdir}/<%= config_file_path %> \
%{buildroot}%{foreman_proxy_settingsd_dir}/<%= config_file.chomp('.example') %>
<% if has_cronjob -%>
mkdir -p %{buildroot}%{_root_sysconfdir}/cron.d/
mv %{buildroot}%{gem_instdir}/extra/*.cron %{buildroot}%{_root_sysconfdir}/cron.d/%{gem_name}
<% end -%>
<% 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? -%>
%{gem_extdir_mri}
<% end -%>
<% config_file_paths = config_file_paths.map { |path| path.split('/').last.chomp('.example') } -%>
<% config_file_paths.each do |config_file_path| -%>
%config(noreplace) %attr(0640, root, foreman-proxy) %{foreman_proxy_settingsd_dir}/<%= config_file_path %>
<% if has_cronjob -%>
%config(noreplace) %{_root_sysconfdir}/cron.d/%{gem_name}
<% end -%>
<% end -%>
<%= main_file_entries(spec) %>
<% unless doc_subpackage -%>
%doc %{gem_docdir}
<%= doc_file_entries(spec) -%>
<% end -%>
%{foreman_proxy_bundlerd_dir}/%{plugin_name}.rb
%exclude %{gem_cache}
%{gem_spec}
<% if doc_subpackage -%>
%files doc
%doc %{gem_docdir}
<%= doc_file_entries(spec) %>
<% end # if doc_subpackage -%>
%changelog