Skip to content
This repository was archived by the owner on Sep 23, 2024. It is now read-only.

Commit da65cc3

Browse files
committed
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.
1 parent 25bfce9 commit da65cc3

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

macros.redis

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
%redis_modules_abi 1
2+
%redis_modules_dir %{_libdir}/redis/modules

redis.spec

+23-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
%global _hardened_build 1
21
%global with_perftools 0
32

43
%if 0%{?fedora} >= 19 || 0%{?rhel} >= 7
@@ -14,7 +13,7 @@
1413
%endif
1514

1615
# Tests fail in mock, not in local build.
17-
%global with_tests %{?_with_tests:1}%{!?_with_tests:0}
16+
%global with_tests %{?_with_tests:1}%{!?_with_tests:0}
1817

1918
Name: redis
2019
Version: 4.0.2
@@ -31,6 +30,7 @@ Source5: %{name}.init
3130
Source6: %{name}-shutdown
3231
Source7: %{name}-limit-systemd
3332
Source8: %{name}-limit-init
33+
Source9: macros.%{name}
3434
# To refresh patches:
3535
# tar xf redis-xxx.tar.gz && cd redis-xxx && git init && git add . && git commit -m "%%{version} baseline"
3636
# git am %%{patches}
@@ -73,6 +73,10 @@ Provides: bundled(hiredis)
7373
Provides: bundled(lua-libs)
7474
Provides: bundled(linenoise)
7575

76+
%global redis_modules_abi 1
77+
%global redis_modules_dir %{_libdir}/%{name}/modules
78+
Provides: redis(modules_abi)%{?_isa} = %{redis_modules_abi}
79+
7680
%description
7781
Redis is an advanced key-value store. It is often referred to as a data
7882
structure server since keys can contain strings, hashes, lists, sets and
@@ -129,11 +133,20 @@ rm -frv deps/jemalloc
129133
sed -i -e '/cd jemalloc && /d' deps/Makefile
130134
sed -i -e 's|../deps/jemalloc/lib/libjemalloc.a|-ljemalloc -ldl|g' src/Makefile
131135
sed -i -e 's|-I../deps/jemalloc.*|-DJEMALLOC_NO_DEMANGLE -I/usr/include/jemalloc|g' src/Makefile
136+
132137
# Configuration file changes and additions
133138
sed -i -e 's|^logfile .*$|logfile /var/log/redis/redis.log|g' redis.conf
134139
sed -i -e '$ alogfile /var/log/redis/sentinel.log' sentinel.conf
135140
sed -i -e 's|^dir .*$|dir /var/lib/redis|g' redis.conf
136141

142+
# Module API version safety check
143+
api=`sed -n -e 's/#define REDISMODULE_APIVER_[0-9][0-9]* //p' src/redismodule.h`
144+
if test "$api" != "%{redis_modules_abi}"; then
145+
: Error: Upstream API version is now ${api}, expecting %%{redis_modules_abi}.
146+
: Update the redis_modules_abi macro, the rpmmacros file, and rebuild.
147+
exit 1
148+
fi
149+
137150
%if 0%{?with_perftools}
138151
%global malloc_flags MALLOC=tcmalloc
139152
%else
@@ -151,6 +164,7 @@ make %{make_flags} install
151164
install -d %{buildroot}%{_sharedstatedir}/%{name}
152165
install -d %{buildroot}%{_localstatedir}/log/%{name}
153166
install -d %{buildroot}%{_localstatedir}/run/%{name}
167+
install -d %{buildroot}%{redis_modules_dir}
154168

155169
# Install logrotate file.
156170
install -pDm644 %{S:1} %{buildroot}%{_sysconfdir}/logrotate.d/%{name}
@@ -196,6 +210,10 @@ done
196210
ln -s redis-server.1 %{buildroot}%{_mandir}/man1/redis-sentinel.1
197211
ln -s redis.conf.5 %{buildroot}%{_mandir}/man5/redis-sentinel.conf.5
198212

213+
# Install rpm macros for redis modules
214+
mkdir -p %{buildroot}%{rpmmacrodir}
215+
install -pDm644 %{S:9} %{buildroot}%{rpmmacrodir}/macros.%{name}
216+
199217
%check
200218
%if 0%{?with_tests}
201219
# https://github.com/antirez/redis/issues/1417 (for "taskset -c 1")
@@ -257,7 +275,8 @@ fi
257275
%if 0%{?with_redistrib}
258276
%exclude %{_bindir}/%{name}-trib
259277
%endif
260-
%exclude %{_includedir}/%{name}module.h
278+
%exclude %{buildroot}%{rpmmacrodir}
279+
%exclude %{_includedir}
261280
%{_bindir}/%{name}-*
262281
%{_libexecdir}/%{name}-*
263282
%{_mandir}/man1/%{name}*
@@ -278,6 +297,7 @@ fi
278297
%files devel
279298
%license COPYING
280299
%{_includedir}/%{name}module.h
300+
%{rpmmacrodir}/*
281301

282302
%if 0%{?with_redistrib}
283303
%files trib

0 commit comments

Comments
 (0)