File machinery.spec of Package machinery.1436
#
# spec file for package machinery
#
# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany.
#
# 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: 1.16.1
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
%if %suse_version > 1320
# openSUSE Factory
%define bundlegems 0
%else
# SLES12, openSUSE 13.1/13.2/Leap
# LEAP has the suse_Version 1315
%define bundlegems 1
%endif
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%ifarch x86_64
BuildRequires: go
%endif
BuildRequires: ruby-macros >= 5
# libxml2-devel and libxslt-devel are needed to install Nokogiri.
BuildRequires: fdupes
BuildRequires: libxml2-devel
BuildRequires: libxslt-devel
%if %suse_version > 1310
%define rb_build_versions %{rb_default_ruby}
BuildRequires: %{rubydevel}
BuildRequires: %{rubygem bundler}
BuildRequires: %{rubygem gem2rpm}
%if 0%{?bundlegems}
BuildRequires: %{rubygem abstract_method <= 1.3}
BuildRequires: %{rubygem abstract_method >= 1.2.1}
BuildRequires: %{rubygem cheetah <= 0.5}
BuildRequires: %{rubygem cheetah >= 0.4.0}
BuildRequires: %{rubygem diffy <= 3.1}
BuildRequires: %{rubygem diffy >= 3.0.7}
BuildRequires: %{rubygem gli <= 3}
BuildRequires: %{rubygem gli >= 2.11}
BuildRequires: %{rubygem haml <= 4.1}
BuildRequires: %{rubygem haml >= 4.0.5}
BuildRequires: %{rubygem json <= 1.9}
BuildRequires: %{rubygem json >= 1.8.0}
BuildRequires: %{rubygem json-schema <= 2.3}
BuildRequires: %{rubygem json-schema >= 2.2.4}
BuildRequires: %{rubygem kramdown <= 2}
BuildRequires: %{rubygem kramdown >= 1.3}
BuildRequires: %{rubygem mimemagic <= 0.4}
BuildRequires: %{rubygem mimemagic >= 0.3.0}
BuildRequires: %{rubygem nokogiri <= 1.7}
BuildRequires: %{rubygem nokogiri >= 1.6.0}
BuildRequires: %{rubygem sinatra <= 1.5}
BuildRequires: %{rubygem sinatra >= 1.4.6}
BuildRequires: %{rubygem tilt <= 3}
BuildRequires: %{rubygem tilt >= 2.0}
%else
Requires: %{rubygem abstract_method <= 1.3}
Requires: %{rubygem abstract_method >= 1.2.1}
Requires: %{rubygem cheetah <= 0.5}
Requires: %{rubygem cheetah >= 0.4.0}
Requires: %{rubygem diffy <= 3.1}
Requires: %{rubygem diffy >= 3.0.7}
Requires: %{rubygem gli <= 3}
Requires: %{rubygem gli >= 2.11}
Requires: %{rubygem haml <= 4.1}
Requires: %{rubygem haml >= 4.0.5}
Requires: %{rubygem json <= 1.9}
Requires: %{rubygem json >= 1.8.0}
Requires: %{rubygem json-schema <= 2.3}
Requires: %{rubygem json-schema >= 2.2.4}
Requires: %{rubygem kramdown <= 2}
Requires: %{rubygem kramdown >= 1.3}
Requires: %{rubygem mimemagic <= 0.4}
Requires: %{rubygem mimemagic >= 0.3.0}
Requires: %{rubygem nokogiri <= 1.7}
Requires: %{rubygem nokogiri >= 1.6.0}
Requires: %{rubygem sinatra <= 1.5}
Requires: %{rubygem sinatra >= 1.4.6}
Requires: %{rubygem tilt <= 3}
Requires: %{rubygem tilt >= 2.0}
%endif
%else
BuildRequires: ruby-devel
BuildRequires: rubygem(abstract_method) <= 1.3
BuildRequires: rubygem(abstract_method) >= 1.2.1
BuildRequires: rubygem(bundler)
BuildRequires: rubygem(cheetah) <= 0.5
BuildRequires: rubygem(cheetah) >= 0.4.0
BuildRequires: rubygem(diffy) <= 3.1
BuildRequires: rubygem(diffy) >= 3.0.7
BuildRequires: rubygem(gem2rpm)
BuildRequires: rubygem(gli) <= 3
BuildRequires: rubygem(gli) >= 2.11
BuildRequires: rubygem(haml) <= 4.1
BuildRequires: rubygem(haml) >= 4.0.5
BuildRequires: rubygem(json) <= 1.9
BuildRequires: rubygem(json) >= 1.8.0
BuildRequires: rubygem(json-schema) <= 2.3
BuildRequires: rubygem(json-schema) >= 2.2.4
BuildRequires: rubygem(kramdown) <= 2
BuildRequires: rubygem(kramdown) >= 1.3
BuildRequires: rubygem(mimemagic) <= 0.4
BuildRequires: rubygem(mimemagic) >= 0.3.0
BuildRequires: rubygem(nokogiri) <= 1.7
BuildRequires: rubygem(nokogiri) >= 1.6.0
BuildRequires: rubygem(sinatra) <= 1.5
BuildRequires: rubygem(sinatra) >= 1.4.6
BuildRequires: rubygem(tilt) <= 3
BuildRequires: rubygem(tilt) >= 2.0
%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
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
gem "cheetah", "~> 0.4.0"
%if %suse_version <= 1310
gem "json", "~> 1.8.0"
%endif
gem "abstract_method", "~> 1.2.1"
gem "nokogiri", "~> 1.6.0"
gem "gli", "~> 2.11"
gem "json-schema", "~> 2.2.4"
gem "haml", "~> 4.0.5"
gem "kramdown", "~> 1.3"
gem "tilt", "~> 2.0"
gem "sinatra", "~> 1.4.6"
gem "mimemagic", "~> 0.3.0"
gem "diffy", "~> 3.0.7"
EOT
mkdir -p vendor/cache
cp %{_libdir}/ruby/gems/%{rb_ver}/cache/*.gem vendor/cache
# Normally, Nokogiri builds its own version of libexslt, libxslt and libxml2 and
# links nokogiri.so against them. The problem is that the linked library path
# contains the build root and would not work when the package is installed. The
# work around is to force Nokogiri to use system libraries.
export NOKOGIRI_USE_SYSTEM_LIBRARIES=1
bundle install --standalone --local
rm -rf vendor .bundle Gemfile Gemfile.lock
# Remove references to the build directory to prevent the following RPMLint error:
# E: file-contains-buildroot (Badness: 10000)
rm -rf bundle/ruby/%{rb_ver}/extensions/*/%{rb_ver}/nokogiri-*/mkmf.log
rm -rf bundle/ruby/%{rb_ver}/extensions/*/%{rb_ver}/nokogiri-*/gem_make.out
# The nokogiri gem is mentioned twice in the setup.rb in Tumbleweed (once with
# a relative and once with an absolute path) so we remove the absolute one
sed -i '\|%{buildroot}|d' bundle/bundler/setup.rb
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
%fdupes -s %{buildroot}
%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}/
# check that the machinery-helper is there on x86_64
%ifarch x86_64
%{_libdir}/ruby/gems/%{rb_ver}/gems/%{mod_full_name}/machinery-helper/machinery-helper
%endif
%if %suse_version > 1310
%{_libdir}/ruby/gems/%{rb_ver}/extensions/
%endif
%{_libdir}/ruby/gems/%{rb_ver}/specifications/%{mod_full_name}.gemspec
%{_mandir}/man1/*.1.gz
%doc COPYING NEWS
%files doc
%defattr(-,root,root,-)
%doc %{_libdir}/ruby/gems/%{rb_ver}/doc/%{mod_full_name}/
%changelog