File rubygem-chef.spec of Package rubygem-chef

#
# spec file for package rubygem-chef
#
# Copyright (c) 2013 SUSE LINUX Products 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/
#


%global with_systemd 0%{?suse_version} >= 1230

Name:           rubygem-chef
Version:        11.6.0
Release:        0
%define mod_name chef
%define mod_full_name %{mod_name}-%{version}

BuildRoot:      %{_tmppath}/%{name}-%{version}-build
%if %{with_systemd}
BuildRequires:  systemd
%{systemd_requires}
%endif
BuildRequires:  ruby-macros >= 1
Requires(pre):  pwdutils
Url:            http://wiki.opscode.com/display/chef
Source:         %{mod_full_name}.gem
Source1:        chef.rb
Source2:        chef-client.init
Source3:        chef-client.service
Summary:        A systems integration framework, built to bring the benefits of
License:        Apache-2.0
Group:          Development/Languages/Ruby

%description
A systems integration framework, built to bring the benefits of configuration
management to your entire infrastructure.

%package doc
Summary:        RDoc documentation for %{mod_name}
Group:          Development/Languages/Ruby
Requires:       %{name} = %{version}

%description doc
Documentation generated at gem installation time.
Usually in RDoc and RI formats.

%package testsuite
Summary:        Test suite for %{mod_name}
Group:          Development/Languages/Ruby
Requires:       %{name} = %{version}

%description testsuite
Test::Unit or RSpec files, useful for developers.

%prep
%gem_unpack
%gem_build

%build

%install
%gem_install -f

mkdir -p %{buildroot}/etc/chef
mkdir -p %{buildroot}%{_sbindir}
install -m 0640 %{S:1} %{buildroot}/etc/chef/client.rb
%if %{with_systemd}
mkdir -p %{buildroot}%{_unitdir}
cp %{S:3} %{buildroot}%{_unitdir}
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rcchef-client
%else
mkdir -p %{buildroot}/etc/init.d/
install -m 0755 %{S:2} %{buildroot}%{_sysconfdir}/init.d/chef-client
ln -s %{_sysconfdir}/init.d/chef-client %{buildroot}%{_sbindir}/rcchef-client
%endif
mkdir -p %{buildroot}%{_localstatedir}/log/chef
mkdir -p %{buildroot}%{_localstatedir}/lib/chef
mkdir -p %{buildroot}%{_localstatedir}/cache/chef
mkdir -p %{buildroot}%{_localstatedir}/run/chef
mkdir -p %{buildroot}%{_mandir}/man1
mkdir -p %{buildroot}%{_mandir}/man8
cp chef-%{version}/distro/common/man/man1/* %{buildroot}%{_mandir}/man1/
cp chef-%{version}/distro/common/man/man8/* %{buildroot}%{_mandir}/man8/
rm -rf %{buildroot}%{_libdir}/ruby/gems/%{rb_ver}/gems/%{mod_full_name}/distro

%pre
getent group chef  >/dev/null || groupadd -r chef
getent passwd chef >/dev/null || useradd  -r -g chef -d %{_localstatedir}/lib/chef -s /sbin/nologin -c "Opscode Chef Daemon" chef
%if %{with_systemd}
%service_add_pre chef-client.service
%endif
exit 0

%post
%if %{with_systemd}
%fillup_only
%service_add_post chef-client.service
%else
%fillup_and_insserv chef-client
%endif

%preun
if [ -f /etc/init.d/chef-client ]; then
%stop_on_removal chef-client
fi
%if %{with_systemd}
%service_del_preun chef-client.service
%endif

%postun
%if %{with_systemd}
%service_del_postun chef-client.service
%else
%restart_on_update chef-client
%insserv_cleanup
%endif

%files
%defattr(-,root,root,-)
%config(noreplace) %attr(0640, root, chef) /etc/chef/client.rb
%{_bindir}/chef-client
%{_bindir}/chef-solo
%{_bindir}/knife
%{_bindir}/chef-shell
%{_bindir}/shef
%{_bindir}/chef-apply
%{_bindir}/chef-service-manager
%{_libdir}/ruby/gems/%{rb_ver}/cache/%{mod_full_name}.gem
%{_libdir}/ruby/gems/%{rb_ver}/gems/%{mod_full_name}/
%exclude %{_libdir}/ruby/gems/%{rb_ver}/gems/%{mod_full_name}/spec
%{_libdir}/ruby/gems/%{rb_ver}/specifications/%{mod_full_name}.gemspec
%dir %attr(0750, root, chef) %{_sysconfdir}/chef
%dir %attr(0750, chef, chef) %{_localstatedir}/log/chef
%dir %attr(0750, chef, chef) %{_localstatedir}/lib/chef
%dir %attr(0750, chef, chef) %{_localstatedir}/cache/chef
%ghost %attr(0750, chef, chef) %{_localstatedir}/run/chef
%if %{with_systemd}
%{_unitdir}/chef-client.service
%else
%{_sysconfdir}/init.d/chef-*
%endif
%{_sbindir}/rcchef-client
%doc %{_mandir}/man1/*
%doc %{_mandir}/man8/*

%files doc
%defattr(-,root,root,-)
%doc %{_libdir}/ruby/gems/%{rb_ver}/doc/%{mod_full_name}/

%files testsuite
%defattr(-,root,root,-)
%{_libdir}/ruby/gems/%{rb_ver}/gems/%{mod_full_name}/spec

%changelog
openSUSE Build Service is sponsored by