File redis.spec of Package redis
#
# spec file for package redis
#
# Copyright (c) 2017 SUSE LINUX 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/
#
%def_disable lto
%def_without ext_hiredis
%def_without ext_jemalloc
%def_without ext_lua
%def_with ext_linenoise
%define malloc jemalloc
%if 0%{?suse_version} >= 1230 || 0%{?centos_version} >= 700
%bcond_without systemd
%else
%bcond_with systemd
%endif
%define _data_dir %_localstatedir/lib/%name
%define _log_dir %_localstatedir/log/%name
%define _conf_dir %_sysconfdir/%name
Name: redis
Version: 3.2.11
Release: 1
Summary: Persistent key-value database
License: BSD-3-Clause
Group: Productivity/Databases/Servers
Url: http://redis.io/
Source: http://download.redis.io/releases/redis-3.2.11.tar.gz
Source1: redis.logrotate
Source2: redis.target
Source3: redis@.service
Source4: redis.tmpfiles.d
Source5: README.SUSE
Source6: %{name}.sysctl
#Patch: redis-3.2.9-git.patch
# PATCH-FIX-OPENSUSE -- openSUSE-style init script
Patch0: %{name}-initscript.patch
# PATCH-MISSING-TAG -- See http://wiki.opensuse.org/openSUSE:Packaging_Patches_guidelines
Patch1: redis-conf.patch
Patch2: redis-enable-bactrace-on-x86-and-ia64-only.patch
# PATCH-FIX-OPENSUSE -- openSUSE-style init script
Patch4: redis-initscript.patch
Patch5: redis-3.2.0-fix-prototype.patch
Requires(pre): shadow
BuildRequires: pkg-config
BuildRequires: procps
BuildRequires: tcl
%{?_with_ext_hiredis:BuildRequires: pkgconfig(hiredis)}
%{?_with_ext_linenoise:BuildRequires: linenoise-devel >= 1.0-1}
%{?_with_ext_lua:BuildRequires: lua51-devel}
%if "%{?malloc}" == jemalloc
%{?_with_ext_jemalloc:BuildRequires: jemalloc-devel}
%else
%if "%{?malloc}" == tcmalloc
BuildRequires: pkgconfig(libtcmalloc)
%else
%if "%{?malloc}" == tcmalloc_minimal
BuildRequires: pkgconfig(libtcmalloc_minimal)
%endif
%endif
%endif
%if %{with systemd}
BuildRequires: pkgconfig(systemd)
%{?systemd_requires}
%else
# FIXME: use proper Requires(pre/post/preun/...)
PreReq: %insserv_prereq %fillup_prereq
%endif
Requires: logrotate
Requires: sudo
%description
Redis 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
#patch -p1
%patch0
%patch1
%patch2
#patch4
%patch5 -p1
sed -i '/foreach diskless/s/ *yes//' tests/integration/replication-psync.tcl
sed -i '/cd jemalloc .* \.\/configure /s/$/ --without-export --disable-valgrind --disable-fill --disable-stats --disable-experimental/' deps/Makefile
%if_with ext_hiredis
sed -i \
-e '/DEPENDENCY_TARGETS/s/hiredis //' \
-e 's| -I\.\./deps/hiredis| %(pkg-config --cflags hiredis)|' \
-e 's|\.\./deps/hiredis/libhiredis\.a|%(pkg-config --libs hiredis)|' \
src/Makefile
%endif
%if_with ext_linenoise
sed -i \
-e '/DEPENDENCY_TARGETS/s/linenoise //' \
-e 's| -I\.\./deps/linenoise||' \
-e 's|\.\./deps/linenoise/linenoise\.o| -llinenoise|' \
src/Makefile
%endif
%if_with ext_jemalloc
sed -i \
-e '/DEPENDENCY_TARGETS.*jemalloc/d' \
-e 's| -I\.\./deps/jemalloc/include||' \
-e 's|\.\./deps/jemalloc/lib/lib\(jemalloc\)\.a|-l\1|' \
src/Makefile
%endif
%if_with ext_lua
sed -i \
-e '/DEPENDENCY_TARGETS/s/lua//' \
-e 's| -I\.\./deps/lua/src| %(pkg-config --cflags lua)|' \
-e 's|\.\./deps/lua/src/liblua\.a|$(wildcard lua/*.o) %(pkg-config --libs lua)|' \
src/Makefile
sed -i '/solarisfixes\.h/d' deps/lua/src/lua_cjson.c
sed -i '/-(cd lua /d' deps/Makefile
%endif
%build
%if_with ext_lua
install -d -m 0755 src/lua
cd src/lua
ln -sf ../../deps/lua/src/{fpconv,strbuf,lua_{bit,cmsgpack,cjson,struct}}.[ch] ./
%__cc %optflags -c *.c
cd -
%endif
%{?malloc:sed -i '/^MALLOC=/d;/^FINAL_CFLAGS+=/aMALLOC=%malloc' src/Makefile}
make %{?_smp_mflags} \
%if_enabled lto
CFLAGS="%optflags -flto" LDFLAGS="-O2 -flto -fwhole-program" \
%else
CFLAGS="%optflags" \
%endif
V=1
%if %{with systemd}
sed -i 's/\(daemonize \)yes/\1no/g' %name.conf
%endif
%install
install -d -m 0750 %buildroot{%_conf_dir,{%_log_dir,%_data_dir}/default}
install -d -m 0755 %buildroot{%_bindir,%_sbindir}
install -p -m 0755 src/%name-{benchmark,cli,check-{aof,rdb},trib.rb} %buildroot%_bindir/
install -p -m 0755 src/%name-server %buildroot%_sbindir/
ln -sf %_sbindir/%name-server %buildroot%_bindir/
install -p -m 0640 %name.conf %buildroot%_conf_dir/default.conf.example
# some sysctl stuff
install -pD -m 0644 %{S:6} %buildroot%_sysconfdir/sysctl.d/00-redis.conf
# init
%if %{with systemd}
install -d -m 0755 %buildroot%_unitdir
install -p -m 0644 %{S:2} %buildroot%_unitdir/%name.target
install -p -m 0644 %{S:3} %buildroot%_unitdir/%{name}@.service
install -pD -m 0644 %{S:4} %buildroot/usr/lib/tmpfiles.d/%name.conf
ln -sf %_sbindir/service %buildroot%_sbindir/rc%name
cp %{S:5} README.SUSE
%else
install -D -m 0755 utils/redis_init_script %buildroot%_initddir/%name
ln -s %_initddir/%name %buildroot%_sbindir/rc%name
%endif
# logrotate
install -pD -m 0644 %{S:1} %buildroot%_sysconfdir/logrotate.d/%name
%check
%ifnarch ppc ppc64
cat <<EOF
---------------------------------------------------
The test suite often fails to start a server, with
'child process exited abnormally' -- sometimes it works.
---------------------------------------------------
EOF
make test
%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 Redis key-value store" -d %_data_dir %name ||:
%if %{with systemd}
%{?service_add_pre:%service_add_pre %name.target}
%{?systemd_pre:%systemd_pre %name.target}
%endif
%post
%if %{with systemd}
systemd-tmpfiles --create /usr/lib/tmpfiles.d/%name.conf ||:
%{?service_add_post:%service_add_post %name.target}
%{?systemd_post:%systemd_post %name.target}
echo "See /usr/share/doc/packages/redis/README.SUSE to continue"
%else
cat <<__EOF__
To start the database server, create your configuration starting from
/etc/redis/default.conf.example, place it in /etc/redis and do:
sudo rcredis start; sudo chkconfig redis on
__EOF__
%endif
%preun
%if %{with systemd}
%{?service_del_preun:%service_del_preun %name.target}
%{?systemd_preun:%systemd_preun %name.target}
%else
%stop_on_removal %name
%endif
%postun
%if %{with systemd}
%{?service_del_postun:%service_del_postun %name.target}
%{?systemd_preun:%systemd_preun %name.target}
%else
%restart_on_update %name
%insserv_cleanup
%endif
%files
%defattr(-,root,root,-)
%doc 00-RELEASENOTES BUGS CONTRIBUTING COPYING README.md
%config(noreplace) %_sysconfdir/logrotate.d/%name
%config(noreplace) %_sysconfdir/sysctl.d/*
%_bindir/*
%_sbindir/*
%if %{with systemd}
/usr/lib/tmpfiles.d/*
%_unitdir/*
%doc README.SUSE
%else
%config(noreplace) %_initddir/*
%endif
%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
%changelog