You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

297 lines
11 KiB

%undefine _package_note_file
%global doc_commit e50ea1872e4efaf2a7174700050b7ce1c47dc2a8
%global short_doc_commit %(c=%{doc_commit}; echo ${c:0:7})
%global macrosdir %(d=%{_rpmconfigdir}/macros.d; [ -d $d ] || d=%{_sysconfdir}/rpm; echo $d)
%global redis_port 6380
Name: icingadb-redis
Version: 7.0.5
Release: 1%{?dist}
Summary: A persistent key-value database
License: BSD and MIT
URL: https://redis.io
Source0: https://download.redis.io/releases/redis-%{version}.tar.gz
Source1: icingadb-redis.logrotate
Source2: icingadb-redis-sentinel.service
Source3: icingadb-redis.service
Source6: icingadb-redis-shutdown
Source7: icingadb-redis-limit-systemd
Source9: macros.icingadb-redis
Source10: https://github.com/redis/redis-doc/archive/%{doc_commit}/redis-doc-%{short_doc_commit}.tar.gz
# To refresh patches:
# tar xf redis-xxx.tar.gz && cd redis-xxx && git init && git add . && git commit -m "%%{version} baseline"
# git am %%{patches}
# Then refresh your patches
# git format-patch HEAD~<number of expected patches>
# Update configuration for Fedora
# https://github.com/redis/redis/pull/3491 - man pages
Patch0001: 0001-1st-man-pageis-for-redis-cli-redis-benchmark-redis-c.patch
# Update default port from 6370 to 6380
Patch0901: icinga-conf.patch
Patch0902: icinga-deps.patch
Patch0903: icinga-src.patch
Patch0904: icinga-utils.patch
BuildRequires: make
BuildRequires: gcc
%if %{with tests}
BuildRequires: procps-ng
BuildRequires: tcl
%endif
BuildRequires: pkgconfig(libsystemd)
BuildRequires: systemd-devel
#BuildRequires: systemd-rpm-macros
BuildRequires: openssl-devel
Obsoletes: redis-trib < 5
Requires: /bin/awk
Requires: logrotate
Requires(pre): shadow-utils
Requires(post): systemd
Requires(preun): systemd
Requires(postun): systemd
# from deps/hiredis/hiredis.h
Provides: bundled(hiredis) = 0.14.0
# from deps/jemalloc/VERSION
Provides: bundled(jemalloc) = 5.2.1
# from deps/lua/src/lua.h
Provides: bundled(lua-libs) = 5.1.5
# from deps/linenoise/linenoise.h
Provides: bundled(linenoise) = 1.0
Provides: bundled(lzf)
# from deps/hdr_histogram/README.md
Provides: bundled(hdr_histogram) = 0.11.0
%global redis_modules_abi 1
%global redis_modules_dir %{_libdir}/%{name}/modules
Provides: redis(modules_abi)%{?_isa} = %{redis_modules_abi}
Conflicts: icinga-redis
%description
Redis is an advanced key-value store. It is often referred to as a data
structure server since keys can contain strings, hashes, lists, sets and
sorted sets.
You can run atomic operations on these types, like appending to a string;
incrementing the value in a hash; pushing to a list; computing set
intersection, union and difference; or getting the member with highest
ranking in a sorted set.
In order to achieve its outstanding performance, Redis works with an
in-memory dataset. Depending on your use case, you can persist it either
by dumping the dataset to disk every once in a while, or by appending
each command to a log.
Redis also supports trivial-to-setup master-slave replication, with very
fast non-blocking first synchronization, auto-reconnection on net split
and so forth.
Other features include Transactions, Pub/Sub, Lua scripting, Keys with a
limited time-to-live, and configuration settings to make Redis behave like
a cache.
You can use Redis from most programming languages also.
%package devel
Summary: Development header for Redis module development
Provides: icingadb-redis-static = %{version}-%{release}
%description devel
Header file required for building loadable Redis modules. Detailed
API documentation is available in the redis-doc package.
%package doc
Summary: Documentation for Redis including man pages
License: CC-BY-SA
BuildArch: noarch
Conflicts: redis < 4.0
%description doc
Manual pages and detailed documentation for many aspects of Redis use,
administration and development.
%prep
%setup -q -b 10 -n redis-%{version}
%setup -q -n redis-%{version}
mv ../redis-doc-%{doc_commit} doc
%patch0001 -p1
%patch0901 -p1
%patch0902 -p1
%patch0903 -p1
%patch0904 -p1
mv deps/lua/COPYRIGHT COPYRIGHT-lua
mv deps/jemalloc/COPYING COPYING-jemalloc
mv deps/hiredis/COPYING COPYING-hiredis
mv deps/hdr_histogram/LICENSE.txt LICENSE-hdrhistogram
mv deps/hdr_histogram/COPYING.txt COPYING-hdrhistogram
# Configuration file changes
sed -i -e 's|^logfile .*$|logfile /var/log/%{name}/redis.log|g' redis.conf
sed -i -e 's|^logfile .*$|logfile /var/log/%{name}/sentinel.log|g' sentinel.conf
sed -i -e 's|^dir .*$|dir /var/lib/%{name}|g' redis.conf
# Update redis port in config
sed -i -e 's|^port .*$|port %{redis_port}|'g redis.conf
sed -i -e 's|^port .*$|port 2%{redis_port}|'g sentinel.conf
# Update PID file in config
sed -i -e 's|^pidfile .*$|pidfile /var/run/%{name}/redis.pid|g' redis.conf
sed -i -e 's|^pidfile .*$|pidfile /var/run/%{name}/redis-sentinel.pid|g' sentinel.conf
# Module API version safety check
api=`sed -n -e 's/#define REDISMODULE_APIVER_[0-9][0-9]* //p' src/redismodule.h`
if test "$api" != "%{redis_modules_abi}"; then
: Error: Upstream API version is now ${api}, expecting %%{redis_modules_abi}.
: Update the redis_modules_abi macro, the rpmmacros file, and rebuild.
exit 1
fi
%global make_flags DEBUG="" V="echo" LDFLAGS="%{?__global_ldflags}" CFLAGS+="%{optflags} -fPIC" INSTALL="install -p" PREFIX=%{buildroot}%{_prefix} BUILD_WITH_SYSTEMD=yes BUILD_TLS=yes
%build
%make_build %{make_flags} all
%install
make %{make_flags} install
# Filesystem.
install -d %{buildroot}%{_sharedstatedir}/%{name}
install -d %{buildroot}%{_localstatedir}/log/%{name}
install -d %{buildroot}%{_localstatedir}/run/%{name}
install -d %{buildroot}%{redis_modules_dir}
# Install logrotate file.
install -pDm644 %{S:1} %{buildroot}%{_sysconfdir}/logrotate.d/%{name}
# Install configuration files.
#newicingaline1
install -pd %{buildroot}%{_sysconfdir}/%{name}
install -pDm640 redis.conf %{buildroot}%{_sysconfdir}/%{name}/%{name}.conf
install -pDm640 sentinel.conf %{buildroot}%{_sysconfdir}/%{name}/%{?pkg_prefix}sentinel.conf
# Install systemd unit files.
mkdir -p %{buildroot}%{_unitdir}
install -pm644 %{S:3} %{buildroot}%{_unitdir}/%{name}.service
install -pm644 %{S:2} %{buildroot}%{_unitdir}/%{name}-sentinel.service
# Install systemd limit files (requires systemd >= 204)
install -p -D -m 644 %{S:7} %{buildroot}%{_sysconfdir}/systemd/system/%{name}.service.d/limit.conf
install -p -D -m 644 %{S:7} %{buildroot}%{_sysconfdir}/systemd/system/%{name}-sentinel.service.d/limit.conf
# Fix non-standard-executable-perm error.
#newicingaline5
for bin in $(cd %{buildroot}%{_bindir}; ls redis*); do
# Rename bin file and add prefix if set
[ -z %{?pkg_prefix} ] || mv %{buildroot}%{_bindir}/${bin} %{buildroot}%{_bindir}/%{?pkg_prefix}${bin}
chmod 755 %{buildroot}%{_bindir}/%{?pkg_prefix}${bin}
done
# Fix symlinks for checks
#newicingaline4
if [ -n %{?pkg_prefix} ]; then
ln -svf %{name}-server %{buildroot}%{_bindir}/%{name}-check-aof
ln -svf %{name}-server %{buildroot}%{_bindir}/%{name}-check-rdb
fi
# Install redis-shutdown
install -pDm755 %{S:6} %{buildroot}%{_libexecdir}/%{name}-shutdown
# Install redis module header
install -pDm644 src/redismodule.h %{buildroot}%{_includedir}/%{name}module.h
# Install man pages
man=$(dirname %{buildroot}%{_mandir})
for page in man/man?/*; do
#newicingaline3
dir=$(dirname $page)
file=$(basename $page)
install -Dpm644 $page $man/$dir/icingadb-$file
done
ln -s redis-server.1 %{buildroot}%{_mandir}/man1/icingadb-redis-sentinel.1
ln -s redis.conf.5 %{buildroot}%{_mandir}/man5/icingadb-redis-sentinel.conf.5
# Install documentation and html pages
doc=$(echo %{buildroot}/%{_docdir}/%{name})
for page in 00-RELEASENOTES BUGS MANIFESTO *.md; do
install -Dpm644 $page $doc/$page
done
for page in $(find doc -name \*.md | sed -e 's|.md$||g'); do
base=$(echo $page | sed -e 's|doc/||g')
install -Dpm644 $page.md $doc/$base.md
done
# Install rpm macros for redis modules
mkdir -p %{buildroot}%{macrosdir}
install -pDm644 %{S:9} %{buildroot}%{macrosdir}/macros.%{name}
%check
%if %{with tests}
# https://github.com/redis/redis/issues/1417 (for "taskset -c 1")
taskset -c 1 make %{make_flags} test
make %{make_flags} test-sentinel
%endif
%pre
getent group %{name} &> /dev/null || \
groupadd -r %{name} &> /dev/null
getent passwd %{name} &> /dev/null || \
useradd -r -g %{name} -d %{_sharedstatedir}/%{name} -s /sbin/nologin \
-c 'Redis Database Server' %{name} &> /dev/null
exit 0
%post
if [ -f %{_sysconfdir}/%{name}.conf -a ! -L %{_sysconfdir}/%{name}.conf ]; then
if [ -f %{_sysconfdir}/%{name}/%{name}.conf.rpmnew ]; then
rm %{_sysconfdir}/%{name}/%{name}.conf.rpmnew
fi
if [ -f %{_sysconfdir}/%{name}/%{name}.conf ]; then
mv %{_sysconfdir}/%{name}/%{name}.conf %{_sysconfdir}/%{name}/%{name}.conf.rpmnew
fi
mv %{_sysconfdir}/%{name}.conf %{_sysconfdir}/%{name}/%{name}.conf
echo -e "\nWarning: %{name} configuration is now in %{_sysconfdir}/%{name} directory\n"
fi
if [ -f %{_sysconfdir}/%{name}-sentinel.conf -a ! -L %{_sysconfdir}/%{name}-sentinel.conf ]; then
if [ -f %{_sysconfdir}/%{name}/%{?pkg_prefix}sentinel.conf.rpmnew ]; then
rm %{_sysconfdir}/%{name}/%{?pkg_prefix}sentinel.conf.rpmnew
fi
if [ -f %{_sysconfdir}/%{name}/%{?pkg_prefix}sentinel.conf ]; then
mv %{_sysconfdir}/%{name}/%{?pkg_prefix}sentinel.conf %{_sysconfdir}/%{name}/%{?pkg_prefix}sentinel.conf.rpmnew
fi
mv %{_sysconfdir}/%{name}-sentinel.conf %{_sysconfdir}/%{name}/%{?pkg_prefix}sentinel.conf
fi
%systemd_post %{name}.service
%systemd_post %{name}-sentinel.service
%preun
%systemd_preun %{name}.service
%systemd_preun %{name}-sentinel.service
%postun
%systemd_postun_with_restart %{name}.service
%systemd_postun_with_restart %{name}-sentinel.service
%files
%{!?_licensedir:%global license %%doc}
%license COPYING
%license COPYRIGHT-lua
%license COPYING-jemalloc
%license COPYING-hiredis
%license LICENSE-hdrhistogram
%license COPYING-hdrhistogram
%config(noreplace) %{_sysconfdir}/logrotate.d/%{name}
%attr(0750, %{name}, root) %dir %{_sysconfdir}/%{name}
%attr(0640, %{name}, root) %config(noreplace) %{_sysconfdir}/%{name}/%{name}.conf
%attr(0640, %{name}, root) %config(noreplace) %{_sysconfdir}/%{name}/%{?pkg_prefix}sentinel.conf
%dir %attr(0750, %{name}, %{name}) %{_libdir}/%{name}
%dir %attr(0750, %{name}, %{name}) %{redis_modules_dir}
%dir %attr(0750, %{name}, %{name}) %{_sharedstatedir}/%{name}
%dir %attr(0750, %{name}, %{name}) %{_localstatedir}/log/%{name}
%exclude %{macrosdir}
%exclude %{_includedir}
%exclude %{_docdir}/%{name}/*
%{_bindir}/%{name}-*
%{_libexecdir}/%{name}-*
%{_mandir}/man1/%{name}*
%{_mandir}/man5/%{name}*
%{_unitdir}/%{name}.service
%{_unitdir}/%{name}-sentinel.service
%dir %{_sysconfdir}/systemd/system/%{name}.service.d
%config(noreplace) %{_sysconfdir}/systemd/system/%{name}.service.d/limit.conf
%dir %{_sysconfdir}/systemd/system/%{name}-sentinel.service.d
%config(noreplace) %{_sysconfdir}/systemd/system/%{name}-sentinel.service.d/limit.conf
%dir %attr(0755, %{name}, %{name}) %ghost %{_localstatedir}/run/%{name}
%files devel
# main package is not required
%license COPYING
%{_includedir}/%{name}module.h
%{macrosdir}/*
%files doc
# specific for documentation (CC-BY-SA)
%license doc/LICENSE
%docdir %{_docdir}/%{name}
%{_docdir}/%{name}
%changelog