File machinery.spec of Package machinery.293
#
# spec file for package machinery
#
# Copyright (c) 2013-2014 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: 1.2.0
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
BuildRoot: %{_tmppath}/%{name}-%{version}-build
BuildRequires: ruby-macros >= 5
# libxml2-devel and libxslt-devel are needed to install Nokogiri.
BuildRequires: libxml2-devel
BuildRequires: libxslt-devel
BuildRequires: fdupes
%if %suse_version > 1310
%define rb_build_versions %{rb_default_ruby}
BuildRequires: %{rubydevel}
BuildRequires: %{rubygem gem2rpm}
BuildRequires: %{rubygem bundler}
BuildRequires: %{rubygem cheetah >= 0.4.0}
BuildRequires: %{rubygem json >= 1.8.0}
BuildRequires: %{rubygem abstract_method >= 1.2.1}
BuildRequires: %{rubygem nokogiri >= 1.6.0}
BuildRequires: %{rubygem gli >= 2.11.0}
BuildRequires: %{rubygem gli <= 2.12}
BuildRequires: %{rubygem json-schema >= 2.2.4}
BuildRequires: %{rubygem json-schema <= 2.3}
BuildRequires: %{rubygem haml >= 4.0.5}
BuildRequires: %{rubygem haml <= 4.1}
BuildRequires: %{rubygem kramdown >= 1.3.3}
BuildRequires: %{rubygem kramdown <= 1.4}
BuildRequires: %{rubygem tilt >= 2.0}
%else
BuildRequires: ruby-devel
BuildRequires: rubygem(gem2rpm)
BuildRequires: rubygem(bundler)
BuildRequires: rubygem(cheetah) >= 0.4.0
BuildRequires: rubygem(json) >= 1.8.0
BuildRequires: rubygem(abstract_method) >= 1.2.1
BuildRequires: rubygem(nokogiri) >= 1.6.0
BuildRequires: rubygem(gli) >= 2.11.0
BuildRequires: rubygem(gli) <= 2.12
BuildRequires: rubygem(json-schema) >= 2.2.4
BuildRequires: rubygem(json-schema) <= 2.3
BuildRequires: rubygem(haml) >= 4.0.5
BuildRequires: rubygem(haml) <= 4.1
BuildRequires: rubygem(kramdown) >= 1.3.3
BuildRequires: rubygem(kramdown) <= 1.4
BuildRequires: rubygem(tilt) >= 2.0
%endif
# Disable autogenerating "Requires:" headers for bundled gems.
%define __requires_exclude ^rubygem
Requires: ruby >= 2.0
Requires: sudo
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
# 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.0"
gem "json-schema", "~> 2.2.4"
gem "haml", "~> 4.0.5"
gem "kramdown", "~> 1.3.3"
gem "tilt", ">= 2.0"
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 Nokogiri build logs 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
popd
# Adapt the binary
# 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}
# 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}/
%{_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