File redis.spec of Package 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

%define _data_dir       %{_localstatedir}/lib/%{name}
%define _log_dir        %{_localstatedir}/log/%{name}
%define _conf_dir       %{_sysconfdir}/%{name}
%define redis_hashes_tree 6132305b4e7b98a88e6526d36190251960b6fc38

Name:           redis
Version:        6.0.4
Release:        0
Summary:        Persistent key-value database
License:        BSD-3-Clause
Source1:        %{name}.logrotate
Source2:        %{name}.target
Source3:        %{name}@.service
Source4:        %{name}.tmpfiles.d
Source5:        README.SUSE
Source6:        %{name}.sysctl
Source7:        %{name}-sentinel@.service
Source8:        %{name}
Source9:        %{name}-user.conf
Patch0:         %{name}-conf.patch
Patch1:         getMcontextEip-return-value.patch
Patch3:         reproducible.patch
Patch4:         ppc-atomic.patch
BuildRequires:  pkgconfig
BuildRequires:  sysuser-shadow
BuildRequires:  sysuser-tools
BuildRequires:  pkgconfig(libsystemd)
BuildRequires:  pkgconfig(systemd)
Recommends:     logrotate

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

echo "`grep -F %{name}-%{version}.tar.gz %{SOURCE10} | cut -d' ' -f4`  %{SOURCE0}" | sha256sum -c
%setup -q
%patch1 -p1
%patch3 -p1
%patch4 -p1

export HOST=OBS # for reproducible builds
%make_build CFLAGS="%{optflags}" BUILD_WITH_SYSTEMD=yes
%sysusers_generate_pre %{SOURCE9} redis

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

install -Dpm 0755 src/%{name}-benchmark  %{buildroot}%{_bindir}/%{name}-benchmark
install -Dpm 0755 src/%{name}-cli        %{buildroot}%{_bindir}/%{name}-cli

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

ln -sfv ../sbin/redis-server             %{buildroot}%{_bindir}/%{name}-check-aof
ln -sfv ../sbin/redis-server             %{buildroot}%{_bindir}/%{name}-check-rdb
ln -sfv ../sbin/redis-server             %{buildroot}%{_sbindir}/%{name}-check-aof
ln -sfv ../sbin/redis-server             %{buildroot}%{_sbindir}/%{name}-check-rdb
ln -sfv ../sbin/redis-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}/default.conf.example
install -Dm 0660 sentinel.conf           %{buildroot}%{_conf_dir}/sentinel.conf.example

# some sysctl stuff
install -Dm 0644 %{SOURCE6} %{buildroot}%{_sysconfdir}/sysctl.d/00-%{name}.conf
install -Dm 0644 %{SOURCE1} %{buildroot}%{_sysconfdir}/logrotate.d/%{name}
install -Dm 0644 %{SOURCE2} %{buildroot}%{_unitdir}/%{name}.target
install -Dm 0644 %{SOURCE3} %{buildroot}%{_unitdir}/%{name}@.service
install -Dm 0644 %{SOURCE4} %{buildroot}%{_tmpfilesdir}/%{name}.conf
install -Dm 0644 %{SOURCE7} %{buildroot}%{_unitdir}/%{name}-sentinel@.service
install -Dm 0644 %{SOURCE8} %{buildroot}%{_unitdir}/%{name}

ln -sf %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}

mkdir -p %{buildroot}%{_sysusersdir}
install -m 644 %{SOURCE9} %{buildroot}%{_sysusersdir}/

cat <<EOF
The test suite often fails to start a server, with
'child process exited abnormally' -- sometimes it works.
%make_build test || true

%pre -f redis.pre
%service_add_pre redis@.service redis-sentinel@.service

%tmpfiles_create %{_tmpfilesdir}/%{name}.conf
%service_add_post redis@.service redis-sentinel@.service
echo "See %{_docdir}/%{name}/README.SUSE to continue"

%service_del_preun redis@.service redis-sentinel@.service

%service_del_postun redis@.service redis-sentinel@.service

%license COPYING
%config(noreplace) %{_sysconfdir}/logrotate.d/%{name}
%config(noreplace) %{_sysconfdir}/sysctl.d/00-%{name}.conf
%config(noreplace) %attr(-,root,%{name}) %{_conf_dir}/
%dir %attr(0750,%{name},%{name}) %{_data_dir}
%dir %attr(0750,%{name},%{name}) %{_data_dir}/default
%dir %attr(0750,%{name},%{name}) %{_log_dir}

openSUSE Build Service is sponsored by