File redis.spec of Package icinga-redis

#
# spec file for package redis
#
# Copyright (c) 2020 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 https://bugs.opensuse.org/
#


%define _data_dir       %{_localstatedir}/lib/%{name}
%define _log_dir        %{_localstatedir}/log/%{name}
%define _conf_dir       %{_sysconfdir}/%{name}
%global pkg_prefix	icinga-
%global src_name	redis
Name:           %{?pkg_prefix}%{src_name}
Version:        5.0.9
Release:        0
Summary:        Persistent key-value database
License:        BSD-3-Clause
Group:          Productivity/Databases/Servers
URL:            https://redis.io
Source0:        http://download.redis.io/releases/redis-%{version}.tar.gz
Source1:        %{src_name}.logrotate
Source4:        %{src_name}.tmpfiles.d
Source5:        README.SUSE
# PATCH-FIX-OPENSUSE -- openSUSE-style init script
Patch0:         %{src_name}-initscript.patch
# PATCH-MISSING-TAG -- See https://wiki.opensuse.org/openSUSE:Packaging_Patches_guidelines
Patch1:         %{src_name}-conf.patch
Patch2:         %{src_name}-enable-bactrace-on-x86-ia64-and_arm32_only.patch
Patch3:         %{src_name}-disable_integration_logging.patch
Patch4:         reproducible.patch
Patch5:         icinga-server-port.patch
BuildRequires:  pkgconfig
BuildRequires:  procps
BuildRequires:  tcl
Requires:       logrotate
Requires:       sudo
Requires(pre):  shadow

%description
%{name} is an advanced key-value store. It is similar to memcached but the dataset
is not volatile, and values can be strings, exactly like in memcached,
but also lists, sets, and ordered sets. All this data types can be manipulated
with atomic operations to push/pop elements, add/remove elements, perform server
side union, intersection, difference between sets, and so forth. Redis supports
different kind of sorting abilities.

%prep
%setup -q -n %{src_name}-%{version}
%patch -P 0
%patch -P 1
%patch -P 2
%ifnarch %{ix86} x86_64 ia64 %{arm}
# We have no backtrace, so disable logging test
%patch -P 3
%endif
#%%patch -P 4 -p1
%patch -P 5 -p1
# rpmlint
find . -type f -name *.rb -exec sed -i -e 's|\/usr\/bin\/env ruby|\/usr\/bin\/ruby|g' /usr/bin/icinga-redis-trib.rb {} \;

%build
export HOST=OBS # for reproducible builds
%make_build CFLAGS="%{optflags}"

%install
install -m 0750 -d \
  %{buildroot}%{_sbindir} \
  %{buildroot}%{_log_dir} \
  %{buildroot}%{_data_dir} \
  %{buildroot}%{_conf_dir} \
  %{buildroot}%{_log_dir} \
  %{buildroot}%{_data_dir}

install -Dpm 0755 src/%{src_name}-benchmark  %{buildroot}%{_bindir}/%{name}-benchmark
install -Dpm 0755 src/%{src_name}-cli        %{buildroot}%{_bindir}/%{name}-cli
install -Dpm 0755 src/%{src_name}-trib.rb    %{buildroot}%{_bindir}/%{name}-trib.rb

install -Dpm 0755 src/%{src_name}-server     %{buildroot}%{_sbindir}/%{name}-server

ln -sfv ../sbin/%{name}-server               %{buildroot}%{_bindir}/%{name}-check-aof
ln -sfv ../sbin/%{name}-server               %{buildroot}%{_bindir}/%{name}-check-rdb
ln -sfv ../sbin/%{name}-server               %{buildroot}%{_sbindir}/%{name}-check-aof
ln -sfv ../sbin/%{name}-server               %{buildroot}%{_sbindir}/%{name}-check-rdb
ln -sfv ../sbin/%{name}-server               %{buildroot}%{_sbindir}/%{name}-sentinel

perl -p -i -e 's|daemonize yes|daemonize no|g' %{name}.conf
install -Dm 0640 redis.conf              %{buildroot}%{_conf_dir}/redis.conf

cp %{SOURCE5} README.SUSE

%check
%ifnarch ppc ppc64
cat <<EOF
---------------------------------------------------
The test suite often fails to start a server, with
'child process exited abnormally' -- sometimes it works.
---------------------------------------------------
EOF
%endif

%pre
getent group %{name} >/dev/null || %{_sbindir}/groupadd -r %{name} || :
getent passwd %{name} >/dev/null || \
	%{_sbindir}/useradd -g %{name} -s /bin/false -r \
	-c "User for %{name} key-value store" -d %{_data_dir} %{name} || :

%post
echo "See %{_docdir}/%{name}/README.SUSE to continue"

%preun
%postun

%files
%license COPYING
%doc 00-RELEASENOTES BUGS CONTRIBUTING README.md
%{_bindir}/%{name}-*
%{_sbindir}/%{name}-*
%doc README.SUSE
%config(noreplace) %attr(-,root,%{name}) %{_conf_dir}/
%dir %attr(0750,%{name},%{name}) %{_data_dir}
%dir %attr(0750,%{name},%{name}) %{_log_dir}

%changelog

openSUSE Build Service is sponsored by