nginx: add required modules for Openresty lua module
authorJavier Marcet <javier@marcet.info>
Fri, 30 Jun 2023 11:28:53 +0000 (13:28 +0200)
committerChristian Marangi <ansuelsmth@gmail.com>
Fri, 22 Sep 2023 12:55:01 +0000 (14:55 +0200)
Add nginx-mod-lua-resty-core and nginx-mod-lua-resty-lrucache new module
required for the lua module to correctly works.

The module are based on luajit2 from Openresty.

Signed-off-by: Javier Marcet <javier@marcet.info>
[ improve commit description/tile and fix redundant dependency ]
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
net/nginx/Makefile

index fef7f8b65d3b0a0ce04b24e82818b1b341d0d4e4..fe5e033b3ad74c15820505706ce3677c42c3873c 100644 (file)
@@ -29,6 +29,8 @@ PKG_BUILD_FLAGS:=gc-sections
 PKG_MOD_EXTRA := \
        geoip2 \
        lua \
+       lua-resty-core \
+       lua-resty-lrucache \
        rtmp \
        dav-ext \
        naxsi \
@@ -206,6 +208,33 @@ define Download/nginx-mod-geoip2
   PROTO:=git
 endef
 
+define Package/nginx-mod-lua-resty-lrucache
+  $(call Package/nginx/default)
+  DEPENDS:=+luajit2
+  TITLE:=Nginx Lua OpenResty lrucache module
+endef
+
+define Package/nginx-mod-lua-resty-core
+  $(call Package/nginx/default)
+  DEPENDS:=+nginx-mod-lua-resty-lrucache
+  TITLE:=Nginx Lua OpenResty core module
+endef
+
+define Package/nginx-mod-lua-resty-lrucache/install
+       $(INSTALL_DIR) $(1)/usr/lib/lua/resty/lrucache
+       $(INSTALL_BIN) $(PKG_BUILD_DIR)/nginx-mod-lua-resty-lrucache/lib/resty/*.lua $(1)/usr/lib/lua/resty
+       $(INSTALL_BIN) $(PKG_BUILD_DIR)/nginx-mod-lua-resty-lrucache/lib/resty/lrucache/*.lua $(1)/usr/lib/lua/resty/lrucache
+endef
+
+define Package/nginx-mod-lua-resty-core/install
+       $(INSTALL_DIR) $(1)/usr/lib/lua/ngx/ssl
+       $(INSTALL_DIR) $(1)/usr/lib/lua/resty/core
+       $(INSTALL_BIN) $(PKG_BUILD_DIR)/nginx-mod-lua-resty-core/lib/ngx/*.lua $(1)/usr/lib/lua/ngx
+       $(INSTALL_BIN) $(PKG_BUILD_DIR)/nginx-mod-lua-resty-core/lib/ngx/ssl/*.lua $(1)/usr/lib/lua/ngx/ssl
+       $(INSTALL_BIN) $(PKG_BUILD_DIR)/nginx-mod-lua-resty-core/lib/resty/*.lua $(1)/usr/lib/lua/resty
+       $(INSTALL_BIN) $(PKG_BUILD_DIR)/nginx-mod-lua-resty-core/lib/resty/core/*.lua $(1)/usr/lib/lua/resty/core
+endef
+
 define Download/nginx-mod-headers-more
   VERSION:=bea1be3bbf6af28f6aa8cf0c01c07ee1637e2bd0
   URL:=https://github.com/openresty/headers-more-nginx-module.git
@@ -249,6 +278,20 @@ define Download/nginx-mod-lua
   PROTO:=git
 endef
 
+define Download/nginx-mod-lua-resty-core
+  VERSION:=698d7de385c7d58d00f4853b6a9ab2ab10243ca5
+  URL:=https://github.com/openresty/lua-resty-core.git
+  MIRROR_HASH:=366f24e1ba6221e34f6ba20ab29146438438f88c89fd71f9500d169b3f5aedf0
+  PROTO:=git
+endef
+
+define Download/nginx-mod-lua-resty-lrucache
+  VERSION:=a79615ec9dc547fdb4aaee59ef8f5a50648ce9fd
+  URL:=https://github.com/openresty/lua-resty-lrucache.git
+  MIRROR_HASH:=7122a7f5f00fa0a1bb8e84f82fe1cc4ad7c368093508a8c04948b1c8d770a88f
+  PROTO:=git
+endef
+
 define Download/nginx-mod-dav-ext
   VERSION:=f5e30888a256136d9c550bf1ada77d6ea78a48af
   URL:=https://github.com/arut/nginx-dav-ext-module.git
@@ -408,16 +451,18 @@ CONFIGURE_ARGS += \
        $(if $(call IsEnabled,NGINX_HTTP_SUB),--with-http_sub_module) \
        $(if $(CONFIG_PACKAGE_nginx-mod-stream),--with-stream=dynamic --with-stream_ssl_module --with-stream_ssl_preread_module) \
        $(if $(CONFIG_PACKAGE_nginx-mod-naxsi),--add-dynamic-module=$(PKG_BUILD_DIR)/nginx-mod-naxsi/naxsi_src) \
-       $(foreach m,$(filter-out naxsi,$(PKG_MOD_EXTRA)), \
+       $(foreach m,$(filter-out lua-resty-core lua-resty-lrucache naxsi,$(PKG_MOD_EXTRA)), \
                $(if $(CONFIG_PACKAGE_nginx-mod-$(m)),--add-dynamic-module=$(PKG_BUILD_DIR)/nginx-mod-$(m)))
 
 $(eval $(call BuildPackage,nginx-ssl))
 $(eval $(call BuildPackage,nginx-full))
 $(eval $(call BuildPackage,nginx-mod-luci))
+$(eval $(call BuildPackage,nginx-mod-lua-resty-lrucache))
+$(eval $(call BuildPackage,nginx-mod-lua-resty-core))
 $(eval $(call BuildModule,stream,+@NGINX_STREAM_CORE_MODULE, \
        ngx_stream, Add support for NGINX request streaming.))
-$(eval $(call BuildModule,lua,+luajit,ngx_http_lua, \
-       Enable Lua module))
+$(eval $(call BuildModule,lua,+nginx-mod-lua-resty-core,ngx_http_lua, \
+       Enable Lua module (luajit2 based, OpenResty patches)))
 $(eval $(call BuildModule,ubus,+libubus +libjson-c +libblobmsg-json +@NGINX_UBUS, \
        ngx_http_ubus,Enable UBUS api support directly from the server.))
 $(eval $(call BuildModule,dav-ext,+@NGINX_DAV +libxml2,ngx_http_dav_ext, \