Redis v4 modules packaging preparation

Add spec file macros to create a default location for
Redis modules, and to allow module packages to depend
on a specific redis module ABI.  A build time test is
added to ensure the upstream sources API version does
not differ to one the redis package Provides:.

The devel package now provides an rpm macros file for
the %{redis_modules_abi} and %{redis_modules_dir}.

Much of this is ideas from Haikel and Remi - thanks!

Small cleanup - the _hardened_build macro is dropped
as this has been the default since f22.
This commit is contained in:
Nathan Scott 2017-10-02 11:05:08 +11:00
parent 25bfce9ab8
commit da65cc3c98
2 changed files with 25 additions and 3 deletions

2
macros.redis Normal file
View File

@ -0,0 +1,2 @@
%redis_modules_abi 1
%redis_modules_dir %{_libdir}/redis/modules

View File

@ -1,4 +1,3 @@
%global _hardened_build 1
%global with_perftools 0
%if 0%{?fedora} >= 19 || 0%{?rhel} >= 7
@ -14,7 +13,7 @@
%endif
# Tests fail in mock, not in local build.
%global with_tests %{?_with_tests:1}%{!?_with_tests:0}
%global with_tests %{?_with_tests:1}%{!?_with_tests:0}
Name: redis
Version: 4.0.2
@ -31,6 +30,7 @@ Source5: %{name}.init
Source6: %{name}-shutdown
Source7: %{name}-limit-systemd
Source8: %{name}-limit-init
Source9: macros.%{name}
# To refresh patches:
# tar xf redis-xxx.tar.gz && cd redis-xxx && git init && git add . && git commit -m "%%{version} baseline"
# git am %%{patches}
@ -73,6 +73,10 @@ Provides: bundled(hiredis)
Provides: bundled(lua-libs)
Provides: bundled(linenoise)
%global redis_modules_abi 1
%global redis_modules_dir %{_libdir}/%{name}/modules
Provides: redis(modules_abi)%{?_isa} = %{redis_modules_abi}
%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
@ -129,11 +133,20 @@ rm -frv deps/jemalloc
sed -i -e '/cd jemalloc && /d' deps/Makefile
sed -i -e 's|../deps/jemalloc/lib/libjemalloc.a|-ljemalloc -ldl|g' src/Makefile
sed -i -e 's|-I../deps/jemalloc.*|-DJEMALLOC_NO_DEMANGLE -I/usr/include/jemalloc|g' src/Makefile
# Configuration file changes and additions
sed -i -e 's|^logfile .*$|logfile /var/log/redis/redis.log|g' redis.conf
sed -i -e '$ alogfile /var/log/redis/sentinel.log' sentinel.conf
sed -i -e 's|^dir .*$|dir /var/lib/redis|g' redis.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
%if 0%{?with_perftools}
%global malloc_flags MALLOC=tcmalloc
%else
@ -151,6 +164,7 @@ make %{make_flags} install
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}
@ -196,6 +210,10 @@ done
ln -s redis-server.1 %{buildroot}%{_mandir}/man1/redis-sentinel.1
ln -s redis.conf.5 %{buildroot}%{_mandir}/man5/redis-sentinel.conf.5
# Install rpm macros for redis modules
mkdir -p %{buildroot}%{rpmmacrodir}
install -pDm644 %{S:9} %{buildroot}%{rpmmacrodir}/macros.%{name}
%check
%if 0%{?with_tests}
# https://github.com/antirez/redis/issues/1417 (for "taskset -c 1")
@ -257,7 +275,8 @@ fi
%if 0%{?with_redistrib}
%exclude %{_bindir}/%{name}-trib
%endif
%exclude %{_includedir}/%{name}module.h
%exclude %{buildroot}%{rpmmacrodir}
%exclude %{_includedir}
%{_bindir}/%{name}-*
%{_libexecdir}/%{name}-*
%{_mandir}/man1/%{name}*
@ -278,6 +297,7 @@ fi
%files devel
%license COPYING
%{_includedir}/%{name}module.h
%{rpmmacrodir}/*
%if 0%{?with_redistrib}
%files trib