File rubygem-fluentd.spec of Package rubygem-fluentd

#
# spec file for package rubygem-fluentd
#
# Copyright (c) 2015 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/
#


Name:           rubygem-fluentd
Version:        0.12.18
Release:        0
%define mod_name fluentd
%define mod_full_name %{mod_name}-%{version}
%define mod_branch -%{version}
%define mod_weight 1218

BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildRequires:  ruby-macros >= 3
Requires:       ruby >= 1.9.3
BuildRequires:  ruby >= 1.9.3
BuildRequires:  update-alternatives
Url:            http://fluentd.org/
Source:         http://rubygems.org/gems/%{mod_full_name}.gem
Summary:        Fluentd event collector
License:        Apache-2.0
Group:          Development/Languages/Ruby
PreReq:         update-alternatives

%description
Fluentd is an open source data collector designed to scale and simplify log
management. It can collect, process and ship many kinds of data in near
real-time.

%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
#if you need patches, apply them here and replace the # with a % sign in the surrounding lines
#gem_build

%build

%install
%gem_install -f
mkdir -p %{buildroot}%{_sysconfdir}/alternatives
mv %{buildroot}%{_bindir}/fluent-cat{,%{mod_branch}}
touch %{buildroot}%{_sysconfdir}/alternatives/fluent-cat
ln -s %{_sysconfdir}/alternatives/fluent-cat %{buildroot}%{_bindir}/fluent-cat

mv %{buildroot}%{_bindir}/fluent-debug{,%{mod_branch}}
touch %{buildroot}%{_sysconfdir}/alternatives/fluent-debug
ln -s %{_sysconfdir}/alternatives/fluent-debug %{buildroot}%{_bindir}/fluent-debug

mv %{buildroot}%{_bindir}/fluent-gem{,%{mod_branch}}
touch %{buildroot}%{_sysconfdir}/alternatives/fluent-gem
ln -s %{_sysconfdir}/alternatives/fluent-gem %{buildroot}%{_bindir}/fluent-gem

mv %{buildroot}%{_bindir}/fluentd{,%{mod_branch}}
touch %{buildroot}%{_sysconfdir}/alternatives/fluentd
ln -s %{_sysconfdir}/alternatives/fluentd %{buildroot}%{_bindir}/fluentd

mkdir -p %{buildroot}%{_docdir}/%{name}
ln -s %{gem_base}/gems/%{mod_full_name}/COPYING %buildroot/%{_docdir}/%{name}/COPYING
ln -s %{gem_base}/gems/%{mod_full_name}/ChangeLog %buildroot/%{_docdir}/%{name}/ChangeLog
ln -s %{gem_base}/gems/%{mod_full_name}/README.md %buildroot/%{_docdir}/%{name}/README.md

%post
/usr/sbin/update-alternatives --install \
    %{_bindir}/fluent-cat fluent-cat %{_bindir}/fluent-cat%{mod_branch} %{mod_weight}
/usr/sbin/update-alternatives --install \
    %{_bindir}/fluent-debug fluent-debug %{_bindir}/fluent-debug%{mod_branch} %{mod_weight}
/usr/sbin/update-alternatives --install \
    %{_bindir}/fluent-gem fluent-gem %{_bindir}/fluent-gem%{mod_branch} %{mod_weight}
/usr/sbin/update-alternatives --install \
    %{_bindir}/fluentd fluentd %{_bindir}/fluentd%{mod_branch} %{mod_weight}

%preun
if [ "$1" = 0 ] ; then
    /usr/sbin/update-alternatives --remove fluent-cat %{_bindir}/fluent-cat%{mod_branch}
fi
if [ "$1" = 0 ] ; then
    /usr/sbin/update-alternatives --remove fluent-debug %{_bindir}/fluent-debug%{mod_branch}
fi
if [ "$1" = 0 ] ; then
    /usr/sbin/update-alternatives --remove fluent-gem %{_bindir}/fluent-gem%{mod_branch}
fi
if [ "$1" = 0 ] ; then
    /usr/sbin/update-alternatives --remove fluentd %{_bindir}/fluentd%{mod_branch}
fi

%files
%defattr(-,root,root,-)
%{_docdir}/%{name}
%{_bindir}/fluent-cat%{mod_branch}
%{_bindir}/fluent-cat
%ghost %{_sysconfdir}/alternatives/fluent-cat
%{_bindir}/fluent-debug%{mod_branch}
%{_bindir}/fluent-debug
%ghost %{_sysconfdir}/alternatives/fluent-debug
%{_bindir}/fluent-gem%{mod_branch}
%{_bindir}/fluent-gem
%ghost %{_sysconfdir}/alternatives/fluent-gem
%{_bindir}/fluentd%{mod_branch}
%{_bindir}/fluentd
%ghost %{_sysconfdir}/alternatives/fluentd
%{gem_base}/cache/%{mod_full_name}.gem
%{gem_base}/gems/%{mod_full_name}/
%exclude %{gem_base}/gems/%{mod_full_name}/test
%{gem_base}/specifications/%{mod_full_name}.gemspec

%files doc
%defattr(-,root,root,-)
%doc %{gem_base}/doc

%files testsuite
%defattr(-,root,root,-)
%{gem_base}/gems/%{mod_full_name}/test

%changelog