forked from SUSE/machinery
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmachinery.spec.erb
167 lines (137 loc) · 4.88 KB
/
machinery.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
#
# spec file for package machinery
#
# Copyright (c) 2013-2017 SUSE LLC
#
# 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: machinery
Version: <%= @version %>
Release: 0
%define binary_name machinery
%define mod_name machinery-tool
%define mod_full_name %{mod_name}-%{version}
%define mod_branch -%{version}
%define mod_weight 1
# Bundle gems for SUSE Linux Enterprise only because there they are not available
# outside of the build repos
%if !0%{?is_opensuse} || 0%{?is_backports}
%define bundlegems 1
%else
%define bundlegems 0
%endif
BuildRoot: %{_tmppath}/%{name}-%{version}-build
# Require on SLES12 our Go version with s390x support
%if 0%{?suse_version} == 1315 && 0%{?is_opensuse} != 1
BuildRequires: go-s390x
%else
BuildRequires: go
%endif
BuildRequires: ruby-macros >= 5
BuildRequires: fdupes
%define rb_build_versions %{rb_default_ruby}
BuildRequires: %{rubydevel}
BuildRequires: %{rubygem gem2rpm}
BuildRequires: %{rubygem bundler}
%if 0%{?bundlegems}
<% build_requires.each do |require| -%>
BuildRequires: %{rubygem <%= require[:name] %> <%= require[:operator] %> <%= require[:version] %>}
<% end -%>
%else
<% build_requires.each do |require| -%>
Requires: %{rubygem <%= require[:name] %> <%= require[:operator] %> <%= require[:version] %>}
<% end -%>
%endif
# Disable autogenerating "Requires:" headers for bundled gems.
%define __requires_exclude ^rubygem
Requires: ruby >= 2.0
Requires: sudo
Requires: which
Url: http://suse.com
Source0: http://rubygems.org/gems/%{mod_full_name}.gem
Source1: %{binary_name}-rpmlintrc
Summary: Systems management toolkit
License: GPL-3.0-only
Group: Development/Languages/Ruby
%description
Machinery is a systems management toolkit for Linux. It supports configuration
discovery, system validation, and service migration. It's based on the idea of a
universal system description.
%package doc
Summary: RDoc and RI documentation for Machinery
Group: Development/Languages/Ruby
Requires: %{name} = %{version}
%description doc
RDoc and RI documentation for Machinery. Machinery is a systems management
toolkit for Linux.
%prep
%build
%install
# Install the gem itself
%gem_install -f
%if %{?bundlegems}
# Bundle dependencies
pushd %{buildroot}%{_libdir}/ruby/gems/%{rb_ver}/gems/%{mod_full_name}
cat > Gemfile <<EOT
<% @dependencies.each do |dependency| -%>
<% dependency.requirement.requirements.map do |operator, version| -%>
gem "<%= dependency.name %>", "<%= operator %> <%= version %>"
<% end -%>
<% end -%>
EOT
mkdir -p vendor/cache
cp %{_libdir}/ruby/gems/%{rb_ver}/cache/*.gem vendor/cache
bundle install --standalone --local
popd
%endif
# Adapt the binary
# Remove the ruby version suffix from the machinery executable
if [ ! -f "%{buildroot}%{_bindir}/%{binary_name}" ]; then
mv "%{buildroot}%{_bindir}/%{binary_name}"* "%{buildroot}%{_bindir}/%{binary_name}"
fi
%if %{?bundlegems}
# Here we do a surgery on the binary to actually load the bundled gems. This is
# a hack, but it can't be done anywhere else because the binary is generated
# during gem install.
sed -i '/gem /i \
Gem.path.unshift("%{_libdir}/ruby/gems/%{rb_ver}/gems/%{mod_full_name}/bundle/ruby/%{rb_ver}")
' %{buildroot}%{_bindir}/%{binary_name}
%endif
# Clean up obsolete extension doc
rm -rf %{buildroot}%{_libdir}/ruby/gems/%{rb_ver}/doc/extensions
# Man page & additional files
mkdir -p %{buildroot}%{_mandir}/man1
ln -s %{_libdir}/ruby/gems/%{rb_ver}/gems/%{mod_full_name}/man/generated/%{binary_name}.1.gz %{buildroot}%{_mandir}/man1/
ln -s %{_libdir}/ruby/gems/%{rb_ver}/gems/%{mod_full_name}/COPYING
ln -s %{_libdir}/ruby/gems/%{rb_ver}/gems/%{mod_full_name}/NEWS
# Convert duplicate files to symlinks
# create symlinks for man pages
%fdupes -s %{buildroot}/%{_mandir}
# create hardlinks for the rest
%fdupes %{buildroot}/%{_prefix}
%files
%defattr(-,root,root,-)
%{_bindir}/%{binary_name}
%{_libdir}/ruby/gems/%{rb_ver}/cache/%{mod_full_name}.gem
%{_libdir}/ruby/gems/%{rb_ver}/gems/%{mod_full_name}/
%{_libdir}/ruby/gems/%{rb_ver}/extensions/
%{_libdir}/ruby/gems/%{rb_ver}/specifications/%{mod_full_name}.gemspec
%{_mandir}/man1/*.1.gz
%if 0%{?suse_version} < 1500
%doc COPYING NEWS
%else
%license COPYING
%doc NEWS
%endif
%files doc
%defattr(-,root,root,-)
%doc %{_libdir}/ruby/gems/%{rb_ver}/doc/%{mod_full_name}/
%changelog