summaryrefslogtreecommitdiff
path: root/dev-db/redict/files/redict-7.3.0-system-hiredict.patch
blob: 53b9d93087d410304fa6bdcdf40ff95b46fb57db (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
# Patch from https://codeberg.org/redict/redict/pulls/44
# and https://salsa.debian.org/redict-team/redict/-/blob/1d2b9f08f3dcc7ba4f03ddd9066545d0fd6b716e/debian/patches/0005-Fix-hiredict-imports.patch
# The first patch got upstreamed, the second will be soon

From ffb9f03106de48a2a09d60f691a8852a0cf917ad Mon Sep 17 00:00:00 2001
From: Maytham Alsudany <maytha8thedev@gmail.com>
Date: Sun, 14 Apr 2024 11:52:21 +0300
Subject: [PATCH 1/2] Add ability to use system hiredict

Co-authored-by: Chris Lamb <lamby@debian.org>
Signed-off-by: Maytham Alsudany <maytha8thedev@gmail.com>
---
 deps/Makefile |  2 ++
 src/Makefile  | 27 ++++++++++++++++++++++-----
 2 files changed, 24 insertions(+), 5 deletions(-)

diff --git a/deps/Makefile b/deps/Makefile
index 345e1f703..e071cfa03 100644
--- a/deps/Makefile
+++ b/deps/Makefile
@@ -36,7 +36,9 @@ ifneq ($(shell sh -c '[ -f .make-ldflags ] && cat .make-ldflags || echo none'),
 endif
 
 distclean:
+ifneq ($(USE_SYSTEM_HIREDICT),yes)
 	-(cd hiredict && $(MAKE) clean) > /dev/null || true
+endif
 	-(cd linenoise && $(MAKE) clean) > /dev/null || true
 	-(cd lua && $(MAKE) clean) > /dev/null || true
 ifneq ($(USE_SYSTEM_JEMALLOC),yes)
diff --git a/src/Makefile b/src/Makefile
index fbcc20f02..8ca30a6df 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -24,7 +24,7 @@ endif
 ifneq ($(OPTIMIZATION),-O0)
 	OPTIMIZATION+=-fno-omit-frame-pointer
 endif
-DEPENDENCY_TARGETS=hiredict linenoise lua hdr_histogram fpconv
+DEPENDENCY_TARGETS=linenoise lua hdr_histogram fpconv
 NODEPS:=clean distclean
 
 # Default settings
@@ -226,7 +226,7 @@ ifdef OPENSSL_PREFIX
 endif
 
 # Include paths to dependencies
-FINAL_CFLAGS+= -I../deps/hiredict -I../deps/linenoise -I../deps/lua/src -I../deps/hdr_histogram -I../deps/fpconv
+FINAL_CFLAGS+= -I../deps/linenoise -I../deps/lua/src -I../deps/hdr_histogram -I../deps/fpconv
 
 # Determine systemd support and/or build preference (defaulting to auto-detection)
 BUILD_WITH_SYSTEMD=no
@@ -277,6 +277,15 @@ else
 endif
 endif
 
+ifeq ($(USE_SYSTEM_HIREDICT),yes)
+    FINAL_LIBS+= $(shell $(PKG_CONFIG) --libs hiredict)
+    FINAL_CFLAGS+= $(shell $(PKG_CONFIG) --cflags hiredict)
+else
+    DEPENDENCY_TARGETS += hiredict
+    FINAL_LIBS+= ../deps/hiredict/libhiredict.a
+    FINAL_CFLAGS+= -I../deps/hiredict
+endif
+
 # LIBSSL & LIBCRYPTO
 LIBSSL_LIBS=
 LIBSSL_PKGCONFIG := $(shell $(PKG_CONFIG) --exists libssl && echo $$?)
@@ -299,15 +308,23 @@ BUILD_MODULE:=2
 ifeq ($(BUILD_TLS),yes)
 	FINAL_CFLAGS+=-DUSE_OPENSSL=$(BUILD_YES) $(OPENSSL_CFLAGS) -DBUILD_TLS_MODULE=$(BUILD_NO)
 	FINAL_LDFLAGS+=$(OPENSSL_LDFLAGS)
+ifeq ($(USE_SYSTEM_HIREDICT),yes)
+	FINAL_LIBS += $(shell $(PKG_CONFIG) --libs hiredict_ssl) $(LIBSSL_LIBS) $(LIBCRYPTO_LIBS)
+else
 	FINAL_LIBS += ../deps/hiredict/libhiredict_ssl.a $(LIBSSL_LIBS) $(LIBCRYPTO_LIBS)
 endif
+endif
 
 TLS_MODULE=
 TLS_MODULE_NAME:=redict-tls$(PROG_SUFFIX).so
 TLS_MODULE_CFLAGS:=$(FINAL_CFLAGS)
 ifeq ($(BUILD_TLS),module)
 	FINAL_CFLAGS+=-DUSE_OPENSSL=$(BUILD_MODULE) $(OPENSSL_CFLAGS)
+ifeq ($(USE_SYSTEM_HIREDICT),yes)
+	TLS_CLIENT_LIBS = $(shell $(PKG_CONFIG) --libs hiredict_ssl) $(LIBSSL_LIBS) $(LIBCRYPTO_LIBS)
+else
 	TLS_CLIENT_LIBS = ../deps/hiredict/libhiredict_ssl.a $(LIBSSL_LIBS) $(LIBCRYPTO_LIBS)
+endif
 	TLS_MODULE=$(TLS_MODULE_NAME)
 	TLS_MODULE_CFLAGS+=-DUSE_OPENSSL=$(BUILD_MODULE) $(OPENSSL_CFLAGS) -DBUILD_TLS_MODULE=$(BUILD_MODULE)
 endif
@@ -406,7 +423,7 @@ endif
 
 # redict-server
 $(REDICT_SERVER_NAME): $(REDICT_SERVER_OBJ)
-	$(REDICT_LD) -o $@ $^ ../deps/hiredict/libhiredict.a ../deps/lua/src/liblua.a ../deps/hdr_histogram/libhdrhistogram.a ../deps/fpconv/libfpconv.a $(FINAL_LIBS)
+	$(REDICT_LD) -o $@ $^ ../deps/lua/src/liblua.a ../deps/hdr_histogram/libhdrhistogram.a ../deps/fpconv/libfpconv.a $(FINAL_LIBS)
 
 # redict-sentinel
 $(REDICT_SENTINEL_NAME): $(REDICT_SERVER_NAME)
@@ -426,11 +443,11 @@ $(TLS_MODULE_NAME): $(REDICT_SERVER_NAME)
 
 # redict-cli
 $(REDICT_CLI_NAME): $(REDICT_CLI_OBJ)
-	$(REDICT_LD) -o $@ $^ ../deps/hiredict/libhiredict.a ../deps/linenoise/linenoise.o $(FINAL_LIBS) $(TLS_CLIENT_LIBS)
+	$(REDICT_LD) -o $@ $^ ../deps/linenoise/linenoise.o $(FINAL_LIBS) $(TLS_CLIENT_LIBS)
 
 # redict-benchmark
 $(REDICT_BENCHMARK_NAME): $(REDICT_BENCHMARK_OBJ)
-	$(REDICT_LD) -o $@ $^ ../deps/hiredict/libhiredict.a ../deps/hdr_histogram/libhdrhistogram.a $(FINAL_LIBS) $(TLS_CLIENT_LIBS)
+	$(REDICT_LD) -o $@ $^ ../deps/hdr_histogram/libhdrhistogram.a $(FINAL_LIBS) $(TLS_CLIENT_LIBS)
 
 DEP = $(REDICT_SERVER_OBJ:%.o=%.d) $(REDICT_CLI_OBJ:%.o=%.d) $(REDICT_BENCHMARK_OBJ:%.o=%.d)
 -include $(DEP)
-- 
2.39.2


From bd55c900ac123db05b7243f6e958e311a622fb7d Mon Sep 17 00:00:00 2001
From: Maytham Alsudany <maytha8thedev@gmail.com>
Date: Sun, 14 Apr 2024 11:53:13 +0300
Subject: [PATCH 2/2] Mention USE_SYSTEM_HIREDICT setting in README

Signed-off-by: Maytham Alsudany <maytha8thedev@gmail.com>
---
 README.md | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/README.md b/README.md
index ae77a235a..cf4944e6f 100644
--- a/README.md
+++ b/README.md
@@ -25,6 +25,8 @@ You can pass the following variables to Redict to customize the build:
 * `USE_JEMALLOC=no MALLOC=libc`: use the libc allocator rather than jemalloc
 * `USE_SYSTEM_JEMALLOC=yes`: use the system's installed jemalloc libraries
    rather than the vendored copy.
+* `USE_SYSTEM_HIREDICT=yes`: use the system's installed hiredict libraries
+  rather than the vendored copy.
 * `BUILD_TLS=yes`: build with TLS support. Requires OpenSSL.
 * `USE_SYSTEMD=yes`: build with systemd support. Requires libsystemd.
 * `PROG_SUFFIX="-suffix"`: Append "-suffix" to executable names
-- 
2.39.2

From: Maytham Alsudany <maytha8thedev@gmail.com>
Subject: Fix hiredict imports
Forwarded: no

--- a/src/cli_common.c
+++ b/src/cli_common.c
@@ -13,15 +13,15 @@
 #include <stdlib.h>
 #include <fcntl.h>
 #include <errno.h>
-#include <hiredict.h>
-#include <sds.h>
+#include <hiredict/hiredict.h>
+#include <hiredict/sds.h>
 #include <unistd.h>
 #include <string.h>
 #include <ctype.h>
 #ifdef USE_OPENSSL
 #include <openssl/ssl.h>
 #include <openssl/err.h>
-#include <hiredict_ssl.h>
+#include <hiredict/hiredict_ssl.h>
 #endif
 
 #define UNUSED(V) ((void) V)
--- a/src/cli_common.h
+++ b/src/cli_common.h
@@ -7,8 +7,8 @@
 #ifndef __CLICOMMON_H
 #define __CLICOMMON_H
 
-#include <hiredict.h>
-#include <sds.h>
+#include <hiredict/hiredict.h>
+#include <hiredict/sds.h>
 
 typedef struct cliSSLconfig {
     /* Requested SNI, or NULL */
--- a/src/redict-benchmark.c
+++ b/src/redict-benchmark.c
@@ -19,13 +19,13 @@
 #include <math.h>
 #include <pthread.h>
 
-#include <sds.h>
+#include <hiredict/sds.h>
 #include "ae.h"
-#include <hiredict.h>
+#include <hiredict/hiredict.h>
 #ifdef USE_OPENSSL
 #include <openssl/ssl.h>
 #include <openssl/err.h>
-#include <hiredict_ssl.h>
+#include <hiredict/hiredict_ssl.h>
 #endif
 #include "adlist.h"
 #include "dict.h"
--- a/src/redict-cli.c
+++ b/src/redict-cli.c
@@ -23,13 +23,13 @@
 #include <math.h>
 #include <termios.h>
 
-#include <hiredict.h>
+#include <hiredict/hiredict.h>
 #ifdef USE_OPENSSL
 #include <openssl/ssl.h>
 #include <openssl/err.h>
-#include <hiredict_ssl.h>
+#include <hiredict/hiredict_ssl.h>
 #endif
-#include <sds.h>
+#include <hiredict/sds.h>
 #include "dict.h"
 #include "adlist.h"
 #include "zmalloc.h"
--- a/src/sentinel.c
+++ b/src/sentinel.c
@@ -6,12 +6,12 @@
 // SPDX-License-Identifier: LGPL-3.0-only
 
 #include "server.h"
-#include "hiredict.h"
+#include "hiredict/hiredict.h"
 #if USE_OPENSSL == 1 /* BUILD_YES */
 #include "openssl/ssl.h"
-#include "hiredict_ssl.h"
+#include "hiredict/hiredict_ssl.h"
 #endif
-#include "async.h"
+#include "hiredict/async.h"
 
 #include <ctype.h>
 #include <arpa/inet.h>