From 9d8f40e12c9374a1c916fe5a5d20023f43b99b94 Mon Sep 17 00:00:00 2001 From: Alexander M Pickering Date: Wed, 25 Sep 2024 17:41:09 -0500 Subject: Seperate patches for lua51 and luajit --- init | 4 ++-- luarocks.exe.c.51.patch | 47 +++++++++++++++++++++++++++++++++++++++++++++++ luarocks.exe.c.jit.patch | 13 +++++++++++++ luarocks.exe.c.patch | 47 ----------------------------------------------- 4 files changed, 62 insertions(+), 49 deletions(-) create mode 100644 luarocks.exe.c.51.patch create mode 100644 luarocks.exe.c.jit.patch delete mode 100644 luarocks.exe.c.patch diff --git a/init b/init index 6b8c5a7..b7c8e4f 100755 --- a/init +++ b/init @@ -12,8 +12,8 @@ mkdir build-binary sed -i 's/local program_version = "dev"/local program_version = "lua4.win"/g' /root/luarocks/src/luarocks/core/cfg.lua patch -i /root/luarocks-packaging/all_in_one.patch binary/all_in_one LUAROCKS_CROSS_COMPILING=1 lua5.4 binary/all_in_one "src/bin/luarocks" "" "^src/luarocks/admin/" "/config" "build-binary" "yes" "windows" -if [ "$LUA_VER" = "51" ]; then - patch -i /root/luarocks-packaging/luarocks.exe.c.patch build-binary/luarocks.exe.c +if [ -e "/root/luarocks-packaging/luarocks.exe.c.$LUA_VER.patch" ]; then + patch -i "/root/luarocks-packaging/luarocks.exe.c.$LUA_VER.patch" build-binary/luarocks.exe.c fi gcc -o build-binary/luarocks.exe -Oz build-binary/luarocks.exe.c -I/root/lua/src /root/libbz2.a /root/libssl.a /root/libz.a /root/liblua.a -mconsole -mwindows -lm cp build-binary/luarocks.exe /root diff --git a/luarocks.exe.c.51.patch b/luarocks.exe.c.51.patch new file mode 100644 index 0000000..a8c022f --- /dev/null +++ b/luarocks.exe.c.51.patch @@ -0,0 +1,47 @@ +--- luarocks.exe.c 2024-09-23 15:25:00.870448000 -0500 ++++ luarocks.exe.c 2024-09-23 15:27:52.663551300 -0500 +@@ -17,6 +17,33 @@ + #define getprogname() + #endif + ++/* LUA_OK defined in lua 5.2+ */ ++#ifndef LUA_OK ++#define LUA_OK 0 ++#endif ++ ++/* luaL_traceback() introduced in lua 5.2 */ ++#ifndef luaL_traceback ++static inline void ++luaL_traceback(lua_State *L, lua_State *L1, const char *msg, int level){ ++ lua_getfield(L, LUA_GLOBALSINDEX, "debug"); ++ if(!lua_istable(L,-1)){ ++ lua_pop(L,1); ++ return; ++ } ++ lua_getfield(L, -1, "traceback"); ++ if(!lua_isfunction(L,-1)){ ++ lua_pop(L,2); ++ return; ++ } ++ lua_pushthread(L1); ++ lua_pushstring(L,msg); ++ lua_pushnumber(L,level); ++ lua_call(L,3,1); ++ return; ++} ++#endif ++ + static int registry_key; + + /* fatal error, from srlua */ +@@ -38282,7 +38309,9 @@ + lua_pop(L, 1); + lua_getfield(L, -1, "loaders"); /* table table.insert package package.loaders */ + } +- lua_copy(L, 4, 3); /* table table.insert package.searchers */ ++ /* lua_copy introduced in lua 5.2 */ ++ lua_replace(L,3); ++ //lua_copy(L, 4, 3); /* table table.insert package.searchers */ + lua_settop(L, 3); /* table table.insert package.searchers */ + lua_pushnumber(L, 1); /* table table.insert package.searchers 1 */ + lua_pushcfunction(L, pkg_loader); /* table table.insert package.searchers 1 pkg_loader */ diff --git a/luarocks.exe.c.jit.patch b/luarocks.exe.c.jit.patch new file mode 100644 index 0000000..3ba5e87 --- /dev/null +++ b/luarocks.exe.c.jit.patch @@ -0,0 +1,13 @@ +--- luarocks.exe.c 2024-09-23 15:25:00.870448000 -0500 ++++ luarocks.exe.c 2024-09-23 15:27:52.663551300 -0500 +@@ -38282,7 +38309,9 @@ + lua_pop(L, 1); + lua_getfield(L, -1, "loaders"); /* table table.insert package package.loaders */ + } +- lua_copy(L, 4, 3); /* table table.insert package.searchers */ ++ /* lua_copy introduced in lua 5.2 */ ++ lua_replace(L,3); ++ //lua_copy(L, 4, 3); /* table table.insert package.searchers */ + lua_settop(L, 3); /* table table.insert package.searchers */ + lua_pushnumber(L, 1); /* table table.insert package.searchers 1 */ + lua_pushcfunction(L, pkg_loader); /* table table.insert package.searchers 1 pkg_loader */ diff --git a/luarocks.exe.c.patch b/luarocks.exe.c.patch deleted file mode 100644 index a8c022f..0000000 --- a/luarocks.exe.c.patch +++ /dev/null @@ -1,47 +0,0 @@ ---- luarocks.exe.c 2024-09-23 15:25:00.870448000 -0500 -+++ luarocks.exe.c 2024-09-23 15:27:52.663551300 -0500 -@@ -17,6 +17,33 @@ - #define getprogname() - #endif - -+/* LUA_OK defined in lua 5.2+ */ -+#ifndef LUA_OK -+#define LUA_OK 0 -+#endif -+ -+/* luaL_traceback() introduced in lua 5.2 */ -+#ifndef luaL_traceback -+static inline void -+luaL_traceback(lua_State *L, lua_State *L1, const char *msg, int level){ -+ lua_getfield(L, LUA_GLOBALSINDEX, "debug"); -+ if(!lua_istable(L,-1)){ -+ lua_pop(L,1); -+ return; -+ } -+ lua_getfield(L, -1, "traceback"); -+ if(!lua_isfunction(L,-1)){ -+ lua_pop(L,2); -+ return; -+ } -+ lua_pushthread(L1); -+ lua_pushstring(L,msg); -+ lua_pushnumber(L,level); -+ lua_call(L,3,1); -+ return; -+} -+#endif -+ - static int registry_key; - - /* fatal error, from srlua */ -@@ -38282,7 +38309,9 @@ - lua_pop(L, 1); - lua_getfield(L, -1, "loaders"); /* table table.insert package package.loaders */ - } -- lua_copy(L, 4, 3); /* table table.insert package.searchers */ -+ /* lua_copy introduced in lua 5.2 */ -+ lua_replace(L,3); -+ //lua_copy(L, 4, 3); /* table table.insert package.searchers */ - lua_settop(L, 3); /* table table.insert package.searchers */ - lua_pushnumber(L, 1); /* table table.insert package.searchers 1 */ - lua_pushcfunction(L, pkg_loader); /* table table.insert package.searchers 1 pkg_loader */ -- cgit v1.2.3-55-g6feb