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

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}
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
# Disable autogenerating "Requires:" headers for bundled gems.
%define __requires_exclude ^rubygem
Requires:       ruby >= 2.0
Requires:       sudo
Source1:        %{binary_name}-rpmlintrc
Summary:        Systems management toolkit
License:        GPL-3.0
Group:          Development/Languages/Ruby

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.




# 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"
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"

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 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.

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


# 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 \

' %{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 doc
%doc %{_libdir}/ruby/gems/%{rb_ver}/doc/%{mod_full_name}/