-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
224 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk | |
|
||
PKG_NAME:=lua-cjson | ||
PKG_VERSION:=2.1.0 | ||
PKG_RELEASE:=3 | ||
PKG_RELEASE:=4 | ||
PKG_MAINTAINER:=Dirk Chang <[email protected]> | ||
PKG_LICENSE:=MIT | ||
PKG_LICENSE_FILES:=LICENSE | ||
|
@@ -18,31 +18,52 @@ PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz | |
PKG_SOURCE_URL:=https://kyne.au/~mark/software/download/ | ||
PKG_HASH:=51bc69cd55931e0cba2ceae39e9efa2483f4292da3a88a1ed470eda829f6c778 | ||
|
||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION) | ||
|
||
HOST_BUILD_DEPENDS:=lua/host | ||
|
||
include $(INCLUDE_DIR)/host-build.mk | ||
include $(INCLUDE_DIR)/package.mk | ||
include $(INCLUDE_DIR)/cmake.mk | ||
|
||
define Package/lua-cjson | ||
define Package/lua-cjson/default | ||
SUBMENU:=Lua | ||
SECTION:=lang | ||
CATEGORY:=Languages | ||
TITLE:=Lua CJSON parser | ||
URL:=https://github.com/mpx/lua-cjson | ||
DEPENDS:= +lua | ||
endef | ||
|
||
define Package/lua-cjson/description | ||
define Package/lua-cjson | ||
$(Package/lua-cjson/default) | ||
DEPENDS+=+liblua | ||
VARIANT:=lua-51 | ||
endef | ||
|
||
define Package/lua-cjson-lua5.3 | ||
$(Package/lua-cjson/default) | ||
DEPENDS+=+liblua5.3 | ||
VARIANT:=lua-53 | ||
endef | ||
|
||
define Package/lua-cjson/default/description | ||
Lua CJSON is a fast JSON encoding/parsing module for Lua. | ||
endef | ||
|
||
define Package/lua-cjson-5.3/description | ||
Lua5.3 CJSON is a fast JSON encoding/parsing module for Lua. | ||
endef | ||
|
||
CMAKE_OPTIONS += \ | ||
-DUSE_LUA=ON | ||
|
||
CMAKE_HOST_OPTIONS += \ | ||
-DLUA_MATH_LIBRARY=m | ||
|
||
ifeq ($(BUILD_VARIANT),lua-53) | ||
CMAKE_OPTIONS += -DUSE_LUA53=ON | ||
endif | ||
|
||
define Package/lua-cjson/install | ||
$(INSTALL_DIR) $(1)/usr/lib/lua | ||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/cjson.so $(1)/usr/lib/lua/ | ||
|
@@ -51,5 +72,11 @@ define Package/lua-cjson/install | |
$(INSTALL_DATA) $(PKG_BUILD_DIR)/lua/cjson/util.lua $(1)/usr/lib/lua/cjson | ||
endef | ||
|
||
define Package/lua-cjson-lua5.3/install | ||
$(INSTALL_DIR) $(1)/usr/local/lib/lua/5.3 | ||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/cjson.so $(1)/usr/local/lib/lua/5.3 | ||
endef | ||
|
||
$(eval $(call HostBuild)) | ||
$(eval $(call BuildPackage,lua-cjson)) | ||
$(eval $(call BuildPackage,lua-cjson-lua5.3)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
--- a/lua_cjson.c | ||
+++ b/lua_cjson.c | ||
@@ -1227,7 +1227,10 @@ static void json_process_value(lua_State | ||
lua_pushlstring(l, token->value.string, token->string_len); | ||
break;; | ||
case T_NUMBER: | ||
- lua_pushnumber(l, token->value.number); | ||
+ if ((lua_Integer)token->value.number == token->value.number) | ||
+ lua_pushinteger(l, (lua_Integer)token->value.number); | ||
+ else | ||
+ lua_pushnumber(l, token->value.number); | ||
break;; | ||
case T_BOOLEAN: | ||
lua_pushboolean(l, token->value.boolean); | ||
--- a/CMakeLists.txt | ||
+++ b/CMakeLists.txt | ||
@@ -15,8 +15,19 @@ if(NOT CMAKE_BUILD_TYPE) | ||
FORCE) | ||
endif() | ||
|
||
-find_package(Lua51 REQUIRED) | ||
-include_directories(${LUA_INCLUDE_DIR}) | ||
+if(USE_LUA53) | ||
+ find_path(LUA53_INCLUDE_DIRS lua.h PATH_SUFFIXES lua5.3) | ||
+ find_library(LUA53_LIBRARIES lua5.3) | ||
+ | ||
+ if (NOT LUA53_INCLUDE_DIRS OR NOT LUA53_LIBRARIES) | ||
+ message(FATAL_ERROR "Liblua 5.3 is required.") | ||
+ endif() | ||
+ | ||
+ include_directories(${LUA53_INCLUDE_DIRS}) | ||
+else() | ||
+ find_package(Lua51 REQUIRED) | ||
+ include_directories(${LUA_INCLUDE_DIR}) | ||
+endif() | ||
|
||
if(NOT USE_INTERNAL_FPCONV) | ||
# Use libc number conversion routines (strtod(), sprintf()) | ||
@@ -51,7 +62,12 @@ if(NOT HAVE_ISINF) | ||
endif() | ||
|
||
set(_MODULE_LINK "${CMAKE_THREAD_LIBS_INIT}") | ||
-get_filename_component(_lua_lib_dir ${LUA_LIBRARY} PATH) | ||
+ | ||
+if(USE_LUA53) | ||
+ get_filename_component(_lua_lib_dir ${LUA53_LIBRARIES} PATH) | ||
+else() | ||
+ get_filename_component(_lua_lib_dir ${LUA_LIBRARY} PATH) | ||
+endif() | ||
|
||
if(APPLE) | ||
set(CMAKE_SHARED_MODULE_CREATE_C_FLAGS | ||
@@ -65,7 +81,11 @@ if(WIN32) | ||
# Windows sprintf()/strtod() handle NaN/inf differently. Not supported. | ||
add_definitions(-DDISABLE_INVALID_NUMBERS) | ||
else() | ||
- set(_lua_module_dir "${_lua_lib_dir}/lua/5.1") | ||
+ if(USE_LUA53) | ||
+ set(_lua_module_dir "${_lua_lib_dir}/lua/5.3") | ||
+ else() | ||
+ set(_lua_module_dir "${_lua_lib_dir}/lua/5.1") | ||
+ endif() | ||
endif() | ||
|
||
add_library(cjson MODULE lua_cjson.c strbuf.c ${FPCONV_SOURCES}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/bin/sh | ||
|
||
. /lib/functions.sh | ||
|
||
KEEPALIVED_STATUS_DIR="/var/run/keepalived" | ||
|
||
# Add a TAG for configured INSTANCE/GROUP | ||
tag_config() { | ||
local cfg="$1" | ||
local type="$2" | ||
local name | ||
|
||
config_get name "$cfg" name | ||
mkdir -p "${KEEPALIVED_STATUS_DIR}/${name}_${type}" | ||
touch "${KEEPALIVED_STATUS_DIR}/${name}_${type}/TAG" | ||
} | ||
|
||
main() { | ||
# Remove TAG flag | ||
for dir in ${KEEPALIVED_STATUS_DIR}/*; do | ||
rm -rf "$dir/TAG" | ||
done | ||
|
||
config_load keepalived | ||
config_foreach tag_config vrrp_instance INSTANCE | ||
config_foreach tag_config vrrp_sync_group GROUP | ||
|
||
# Delete run time directories which are not configured anymore | ||
for dir in ${KEEPALIVED_STATUS_DIR}/*; do | ||
if [ ! -e "$dir/TAG" ]; then | ||
rm -rf "$dir" | ||
fi | ||
done | ||
|
||
# Do not update 'GROUP' status if action is 'NOTIFY' | ||
[ "$ACTION" = "NOTIFY" ] && [ "$TYPE" = "GROUP" ] && return | ||
|
||
if [ -n "${NAME}" ] && [ -n "${TYPE}" ]; then | ||
mkdir -p "${KEEPALIVED_STATUS_DIR}/${NAME}_${TYPE}" | ||
[ -n "$ACTION" ] || ACTION="NOTIFY_UNKNOWN" | ||
echo "$ACTION" > "${KEEPALIVED_STATUS_DIR}/${NAME}_${TYPE}/STATUS" | ||
date +'%s' > "${KEEPALIVED_STATUS_DIR}/${NAME}_${TYPE}/TIME" | ||
fi | ||
} | ||
|
||
main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/bin/sh | ||
|
||
. /usr/share/libubox/jshn.sh | ||
|
||
KEEPALIVED_STATUS_DIR="/var/run/keepalived" | ||
|
||
dump() { | ||
local type="${1}" | ||
local value name time status | ||
|
||
json_add_array "$(echo "$type" | tr A-Z a-z)" | ||
for dir in ${KEEPALIVED_STATUS_DIR}/*; do | ||
value="${dir##*_}" | ||
name="${dir%_*}" | ||
name="${name##*/}" | ||
[ -f "${dir}/TIME" ] && time=$(cat "${dir}/TIME") | ||
[ -f "${dir}/STATUS" ] && status=$(cat "${dir}/STATUS") | ||
if [ "${value}" = "${type}" ]; then | ||
json_add_object | ||
json_add_string "name" "${name}" | ||
json_add_int "event" "${time}" | ||
json_add_string "status" "${status}" | ||
json_close_object | ||
fi | ||
done | ||
json_close_array | ||
} | ||
|
||
status() { | ||
json_init | ||
dump "INSTANCE" | ||
dump "GROUP" | ||
json_dump | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
From 60336ceecbd1cda73aa26dd44cfdaf2e31a046e1 Mon Sep 17 00:00:00 2001 | ||
From: Tobias Brunner <[email protected]> | ||
Date: Fri, 4 Oct 2024 11:23:28 +0200 | ||
Subject: [PATCH] wolfssl: Don't undef PARSE_ERROR as headers included later | ||
might refer to it | ||
|
||
--- | ||
src/libstrongswan/plugins/wolfssl/wolfssl_common.h | 2 -- | ||
1 file changed, 2 deletions(-) | ||
|
||
--- a/src/libstrongswan/plugins/wolfssl/wolfssl_common.h | ||
+++ b/src/libstrongswan/plugins/wolfssl/wolfssl_common.h | ||
@@ -78,6 +78,4 @@ typedef union { | ||
} wolfssl_ed_key; | ||
#endif /* HAVE_ED25519 || HAVE_ED448 */ | ||
|
||
-#undef PARSE_ERROR | ||
- | ||
#endif /* WOLFSSL_PLUGIN_COMMON_H_ */ |