[RFT] Rewrite LuCI runtime in ucode
This PR adds a mostly feature complete re-implementation of the LuCI server side runtime in ucode instead of Lua. It supports running the complete standard LuCI environment (as selected by the luci meta package) without having to install lua, liblua or any of the Lua specific binding libraries onto the system.
Backwards compatibility with existing Lua based LuCI applications can be achieved by installing the luci-lua-runtime package.
Requires OpenWrt commits https://github.com/openwrt/openwrt/commit/639754e36d849553e288f8e34f51f793761c07db and https://github.com/openwrt/openwrt/commit/94129cbefb6027cdfe2b7801a6e27a36d4ec58b8
We need to cleanup the lua_prefix:
# logread -e uhttp
Wed Oct 5 08:50:31 2022 daemon.err uhttpd[2545]: Error initializing /usr/lib/lua/luci/sgi/uhttpd.lua Lua handler: /usr/lib/lua/luci/http.lua:143: attempt to index local 'L' (a nil value)
Wed Oct 5 08:50:37 2022 daemon.err uhttpd[3777]: Error initializing /usr/lib/lua/luci/sgi/uhttpd.lua Lua handler: /usr/lib/lua/luci/http.lua:143: attempt to index local 'L' (a nil value)
Wed Oct 5 08:50:42 2022 daemon.err uhttpd[3844]: Error initializing /usr/lib/lua/luci/sgi/uhttpd.lua Lua handler: /usr/lib/lua/luci/http.lua:143: attempt to index local 'L' (a nil value)
Wed Oct 5 08:50:48 2022 daemon.err uhttpd[3911]: Error initializing /usr/lib/lua/luci/sgi/uhttpd.lua Lua handler: /usr/lib/lua/luci/http.lua:143: attempt to index local 'L' (a nil value)
Wed Oct 5 08:50:53 2022 daemon.err uhttpd[3978]: Error initializing /usr/lib/lua/luci/sgi/uhttpd.lua Lua handler: /usr/lib/lua/luci/http.lua:143: attempt to index local 'L' (a nil value)
Wed Oct 5 08:50:58 2022 daemon.err uhttpd[4045]: Error initializing /usr/lib/lua/luci/sgi/uhttpd.lua Lua handler: /usr/lib/lua/luci/http.lua:143: attempt to index local 'L' (a nil value)
Wed Oct 5 08:50:58 2022 daemon.info procd: Instance uhttpd::instance1 s in a crash loop 6 crashes, 1 seconds since last crash
We also need to fix lua_prefix handling in /etc/init.d/uhttpd. After removing lua_prefix from /etc/config/uhttpd:
# /etc/init.d/uhttpd restart
Skipping invalid Lua prefix "="
The empty Lua prefix is not fatal though.
Status > Realtime Graphs > Connections shows 0 for everything.

System > Status > Firewall
NetworkError
HTTP error 404 while loading class file "/luci-static/resources/tools/firewall.js?v=git-22.270.30123-c4d514b"
at compileClass (https://192.168.1.1/luci-static/resources/luci.js?v=git-22.270.30123-c4d514b:168:16)
This happens on a system without firewall3/4 package.
We need to cleanup the lua_prefix:
Fixed by 0a3a13a1a45ba0a8ddcaa7049896451e3fad1b0e
We also need to fix lua_prefix handling in /etc/init.d/uhttpd. After removing lua_prefix from /etc/config/uhttpd:
Fixed by https://git.openwrt.org/?p=openwrt/staging/jow.git;a=commit;h=c10058b706f1816418deba5633e2f983c871b5c5
Status > Realtime Graphs > Connections shows 0 for everything.
The kernel might be lacking legacy /proc/net/nf_conntrack support. Is luci-bwc -c on the cli showing anything?
System > Status > Firewall
This one is unrelated to the ucode rewrite
@jow- this build fail to me. build failed:
make V=s package/feeds/luci/luci-base/compile
make[2]: Entering directory '/mnt/Data/Sources/openwrt/x-wrt/scripts/config'
make[2]: 'conf' is up to date.
make[2]: Leaving directory '/mnt/Data/Sources/openwrt/x-wrt/scripts/config'
make[1]: Entering directory '/mnt/Data/Sources/openwrt/x-wrt'
make[2]: Entering directory '/mnt/Data/Sources/openwrt/openwrt-feeds/luci/modules/luci-base'
../../luci.mk:115: *** unterminated call to function 'if': missing ')'. Stop.
make[2]: Leaving directory '/mnt/Data/Sources/openwrt/openwrt-feeds/luci/modules/luci-base'
time: package/feeds/luci/luci-base/host-compile#0.19#0.15#0.34
ERROR: package/feeds/luci/luci-base [host] failed to build.
package/Makefile:114: recipe for target 'package/feeds/luci/luci-base/host/compile' failed
make[1]: *** [package/feeds/luci/luci-base/host/compile] Error 1
make[1]: Leaving directory '/mnt/Data/Sources/openwrt/x-wrt'
/mnt/Data/Sources/openwrt/x-wrt/include/toplevel.mk:229: recipe for target 'package/feeds/luci/luci-base/compile' failed
make: *** [package/feeds/luci/luci-base/compile] Error 2
Please see if an rm -r tmp/ fixes it. I can't reproduce it here.
@ptpt52 - it appears the problem is specific to make 4.2, works with 4.3
@jow- very strange on Ubuntu 22.04, my build is good but failed on Ubuntu 18.04
Please see if an
rm -r tmp/fixes it. I can't reproduce it here.@ptpt52 - it appears the problem is specific to make 4.2, works with 4.3
sure, it is make 4.1 on Ubuntu 18.04
@jow- is it possible to make it compatible with make 4.1 ?
@jow- great. another issue: Luci theme bootstrap language translate cannot works.
I change lang to zh_CN, but the UI still in English.
@ptpt52 - fixed as well
git status shows uncommited files.
This maybe?
diff --git a/.gitignore b/.gitignore
index 7834b9bce4..54fce84c96 100644
--- a/.gitignore
+++ b/.gitignore
@@ -10,8 +10,8 @@ package-lock.json
modules/luci-base/src/po2lmo
modules/luci-base/src/jsmin
modules/luci-base/src/contrib/lemon
-modules/luci-base/src/ucode/plural_formula.c
-modules/luci-base/src/ucode/plural_formula.h
+modules/luci-base/src/lib/plural_formula.c
+modules/luci-base/src/lib/plural_formula.h
modules/luci-compat/src/contrib/lemon
modules/luci-compat/src/plural_formula.c
modules/luci-compat/src/plural_formula.h
@dhewg - thanks, fixed.
@jow-
root@X-WRT:~# echo 'require("luci.http")' | lua
lua: /usr/lib/lua/luci/http.lua:143: attempt to index local 'L' (a nil value)
stack traceback:
/usr/lib/lua/luci/http.lua:143: in main chunk
[C]: in function 'require'
stdin:1: in main chunk
[C]: ?
I am trying to load luci.http but show this error.
@ptpt52 - This module currently cannot be used anymore in a stand alone manner anymore. Can you please show the code that was working previously and is not anymore?