aboutsummaryrefslogtreecommitdiffstats
path: root/community/lua-hiredis/0002-lua-hiredis-master.patch
diff options
context:
space:
mode:
authorNathan Angelacos <nangel@alpinelinux.org>2016-04-29 01:50:34 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2016-05-02 17:30:27 +0000
commitb083df45bc139ba58d6d6015ae070040d2934c62 (patch)
treeec6760287afb463816bb5f7bc4b588bb9b76ba68 /community/lua-hiredis/0002-lua-hiredis-master.patch
parent4bf97c41ecf5391ad046883164979e2ff7fee447 (diff)
downloadaports-b083df45bc139ba58d6d6015ae070040d2934c62.tar.bz2
aports-b083df45bc139ba58d6d6015ae070040d2934c62.tar.xz
community/lua-hiredis
Make sure libhiredis is liked to the module Apply various codefixes from github to bring code base to e6355d4 (Mar 24 2014) Apply https://github.com/agladysh/lua-hiredis/pull/6
Diffstat (limited to 'community/lua-hiredis/0002-lua-hiredis-master.patch')
-rw-r--r--community/lua-hiredis/0002-lua-hiredis-master.patch245
1 files changed, 245 insertions, 0 deletions
diff --git a/community/lua-hiredis/0002-lua-hiredis-master.patch b/community/lua-hiredis/0002-lua-hiredis-master.patch
new file mode 100644
index 0000000000..83b8be7692
--- /dev/null
+++ b/community/lua-hiredis/0002-lua-hiredis-master.patch
@@ -0,0 +1,245 @@
+diff --git a/AUTHORS b/AUTHORS
+index ffdadfa..bd5ee8a 100644
+--- a/AUTHORS
++++ b/AUTHORS
+@@ -3,3 +3,8 @@ lua-hiredis bindings authors:
+
+ Alexander Gladysh <agladysh@gmail.com>
+
++lua-hiredis bindings contributors:
++----------------------------------
++
++Stein Ivar Berghei <stein-ivar@berghei.no>
++Peter Melnichenko <petjamelnik@yandex.ru>
+diff --git a/COPYRIGHT b/COPYRIGHT
+index 0af707a..4f31953 100644
+--- a/COPYRIGHT
++++ b/COPYRIGHT
+@@ -9,7 +9,7 @@ Note that hiredis library itself (included for convenience) is licensed under BS
+
+ ===============================================================================
+
+-Copyright (C) 2011—2012 lua-hiredis bindings authors
++Copyright (C) 2011—2014 lua-hiredis bindings authors
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+diff --git a/README.md b/README.md
+index bfc065b..1121f09 100644
+--- a/README.md
++++ b/README.md
+@@ -14,7 +14,12 @@ is not 1.0 yet. But all the features necessary for regular usage are here.
+ API
+ ---
+
+-* `hiredis.connect(host : string, port : number) : conn / nil, err, error_code`
++* `hiredis.connect(host / socket : string, port : number / nil) : conn / nil, err, error_code`
++
++ * `hiredis.connect("localhost", 6379)` connects to Redis at `localhost:6379`
++ via TCP/IP socket.
++ * `hiredis.connect("/var/run/redis/redis.sock")` connects to Redis at
++ `/var/run/redis/redis.sock` via Unix domain socket.
+
+ * `hiredis.unwrap_reply(reply) : reply / name, hiredis.REPLY_STATUS / nil, err`
+
+diff --git a/TODO b/TODO
+index 49e1097..2e1b220 100644
+--- a/TODO
++++ b/TODO
+@@ -1,10 +1,7 @@
+ TODO:
+ -----
+
+- -- hiredis.unwrap_reply should pass everything through without looking
+- if it is called with more than one argument,
+- so this would not lose an error:
+- hiredis.unwrap_reply(conn.command())
++ -- Make nolibs rockspec default, remove lib/*
+ -- Document current API.
+ -- Run splint all over it.
+ -- Run under valgrind
+diff --git a/make.sh b/make.sh
+index 0c012f2..4657b4c 100755
+--- a/make.sh
++++ b/make.sh
+@@ -6,14 +6,14 @@ echo "----> Going pedantic all over the source"
+
+ # Ugh. hiredis.h is not c89-compatible
+ echo "--> c89..."
+-gcc -O2 -fPIC -I/usr/include/lua5.1 -c src/lua-hiredis.c -o /dev/null -Isrc/ -Ilib/hiredis/ -Wall --pedantic --std=c89 #-Werror
++gcc -O2 -fPIC -I/usr/include/lua5.1 -c src/lua-hiredis.c -o /dev/null -Isrc/ -Ilib/ -Wall --pedantic --std=c89 #-Werror
+
+ echo "--> c99..."
+-gcc -O2 -fPIC -I/usr/include/lua5.1 -c src/lua-hiredis.c -o /dev/null -Isrc/ -Ilib/hiredis/ -Wall --pedantic -Werror --std=c99
++gcc -O2 -fPIC -I/usr/include/lua5.1 -c src/lua-hiredis.c -o /dev/null -Isrc/ -Ilib/ -Wall --pedantic -Werror --std=c99
+
+ # Ugh. hiredis.h is not c++98-compatible
+ echo "--> c++98..."
+-gcc -xc++ -O2 -fPIC -I/usr/include/lua5.1 -c src/lua-hiredis.c -o /dev/null -Isrc/c/ -Ilib/hiredis/ --pedantic -Wall --std=c++98 #-Werror
++gcc -xc++ -O2 -fPIC -I/usr/include/lua5.1 -c src/lua-hiredis.c -o /dev/null -Isrc/c/ -Ilib/ --pedantic -Wall --std=c++98 #-Werror
+
+ echo "----> Making rock"
+ sudo luarocks make rockspec/lua-hiredis-scm-1.rockspec
+diff --git a/rockspec/lua-hiredis-scm-1.rockspec b/rockspec/lua-hiredis-scm-1.rockspec
+index a9ec60a..65f87ae 100644
+--- a/rockspec/lua-hiredis-scm-1.rockspec
++++ b/rockspec/lua-hiredis-scm-1.rockspec
+@@ -31,6 +31,7 @@ build = {
+ "src/",
+
+ -- bundled hiredis code --
++ "lib/",
+ "lib/hiredis/"
+ }
+ }
+diff --git a/src/lua-hiredis.c b/src/lua-hiredis.c
+index f8b2fdf..3dfafc1 100644
+--- a/src/lua-hiredis.c
++++ b/src/lua-hiredis.c
+@@ -14,7 +14,7 @@ extern "C" {
+ }
+ #endif
+
+-#include "hiredis.h"
++#include "hiredis/hiredis.h"
+
+ #if 0
+ #define SPAM(a) printf a
+@@ -23,7 +23,7 @@ extern "C" {
+ #endif
+
+ #define LUAHIREDIS_VERSION "lua-hiredis 0.2.1"
+-#define LUAHIREDIS_COPYRIGHT "Copyright (C) 2011—2012, lua-hiredis authors"
++#define LUAHIREDIS_COPYRIGHT "Copyright (C) 2011—2013, lua-hiredis authors"
+ #define LUAHIREDIS_DESCRIPTION "Bindings for hiredis Redis-client library"
+
+ #define LUAHIREDIS_CONN_MT "lua-hiredis.connection"
+@@ -77,7 +77,7 @@ static int lconst_tostring(lua_State * L)
+ }
+
+ /* const API */
+-static const struct luaL_reg CONST_MT[] =
++static const struct luaL_Reg CONST_MT[] =
+ {
+ { "__tostring", lconst_tostring },
+
+@@ -136,7 +136,7 @@ static int lstatus_index(lua_State * L)
+ }
+
+ /* status API */
+-static const struct luaL_reg STATUS_MT[] =
++static const struct luaL_Reg STATUS_MT[] =
+ {
+ { "__index", lstatus_index },
+
+@@ -418,7 +418,7 @@ static int lconn_tostring(lua_State * L)
+ return 1;
+ }
+
+-static const luaL_reg M[] =
++static const luaL_Reg M[] =
+ {
+ { "command", lconn_command },
+ { "append_command", lconn_append_command },
+@@ -436,12 +436,18 @@ static int lhiredis_connect(lua_State * L)
+ luahiredis_Connection * pResult = NULL;
+ redisContext * pContext = NULL;
+
+- const char * host = luaL_checkstring(L, 1);
+- int port = luaL_checkint(L, 2);
++ const char * host_or_socket = luaL_checkstring(L, 1);
+
+- /* TODO: Support Timeout, Unix and UnixTimeout flavors */
++ /* TODO: Support Timeout and UnixTimeout flavors */
++ if (lua_isnoneornil(L, 2))
++ {
++ pContext = redisConnectUnix(host_or_socket);
++ }
++ else
++ {
++ pContext = redisConnect(host_or_socket, luaL_checkint(L, 2));
++ }
+
+- pContext = redisConnect(host, port);
+ if (!pContext)
+ {
+ luaL_checkstack(L, 2, "not enough stack to push error");
+@@ -567,13 +573,13 @@ static int lhiredis_unwrap_reply(lua_State * L)
+ return 1;
+ }
+
+-static const struct luaL_reg E[] = /* Empty */
++static const struct luaL_Reg E[] = /* Empty */
+ {
+ { NULL, NULL }
+ };
+
+ /* Lua module API */
+-static const struct luaL_reg R[] =
++static const struct luaL_Reg R[] =
+ {
+ { "connect", lhiredis_connect },
+ { "unwrap_reply", lhiredis_unwrap_reply },
+diff --git a/test/test.lua b/test/test.lua
+index 2f15c04..d47fc00 100644
+--- a/test/test.lua
++++ b/test/test.lua
+@@ -8,6 +8,12 @@ local CACHED_ERR = nil
+
+ --------------------------------------------------------------------------------
+
++local UDS_SOCKET = "/var/run/redis/redis.sock"
++local HOST = "localhost"
++local PORT = 6379
++
++--------------------------------------------------------------------------------
++
+ assert(type(hiredis.NIL == "table"))
+ assert(hiredis.NIL.name == "NIL")
+ assert(hiredis.NIL.type == hiredis.REPLY_NIL)
+@@ -53,7 +59,44 @@ assert(hiredis.connect("badaddress", 1) == nil)
+
+ --------------------------------------------------------------------------------
+
+-local conn = assert(hiredis.connect("localhost", 6379))
++assert(hiredis.connect("/var/run/redis/inexistant.sock") == nil)
++
++--------------------------------------------------------------------------------
++
++local ok, posix = pcall(require, "posix")
++if not ok then
++ print("WARNING: luaposix not found, can't test Unix Domain Socket support")
++ print(" consider installing it as follows:")
++ print("")
++ print(" sudo luarocks install luaposix")
++ print("")
++elseif not posix.stat(UDS_SOCKET) then
++ print("WARNING: Redis Unix domain socket file not found.")
++ print(" Can't test Unix Domain Socket support.")
++ print(" consider running Redis as follows:")
++ print("")
++ print(" sudo redis-server --unixsocket ".. UDS_SOCKET .. " --port 0")
++ print("")
++else
++ local net_unix = assert(io.open("/proc/net/unix", "r"))
++ local sockets = assert(net_unix:read("*a"))
++ net_unix:close()
++ if not sockets:find(UDS_SOCKET, nil, true) then
++ print("WARNING: Redis Unix domain socket file not open.")
++ print(" Can't test Unix Domain Socket support.")
++ print(" consider running Redis as follows:")
++ print("")
++ print(" sudo redis-server --unixsocket ".. UDS_SOCKET .. " --port 0")
++ print("")
++ else
++ local conn = assert(hiredis.connect(UDS_SOCKET))
++ assert(conn:command("quit"))
++ end
++end
++
++--------------------------------------------------------------------------------
++
++local conn = assert(hiredis.connect(HOST, PORT))
+
+ --------------------------------------------------------------------------------
+