From eddf776d64941454377f996733f96873cb79bcae Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Mon, 11 Apr 2022 16:15:15 -0300 Subject: Changes for building the all-in-one binary with Lua 5.4 --- GNUmakefile | 7 ++- binary/Makefile.windows | 2 +- binary/all_in_one | 26 ++++---- binary/lua-bz2-0.1.0-1.rockspec | 44 -------------- binary/lua-bz2-0.2.1-1.rockspec | 44 ++++++++++++++ binary/lua-zlib-1.2-0.rockspec | 2 +- binary/luaposix-34.0.4-1.rockspec | 55 ----------------- binary/luaposix-35.1-1.rockspec | 61 +++++++++++++++++++ binary/luasec-0.8.1-2.rockspec | 124 -------------------------------------- binary/luasec-1.0.2-1.rockspec | 115 +++++++++++++++++++++++++++++++++++ src/luarocks/fs/tools.lua | 2 +- src/luarocks/fs/unix.lua | 3 +- src/luarocks/fs/win32.lua | 3 +- 13 files changed, 245 insertions(+), 243 deletions(-) delete mode 100644 binary/lua-bz2-0.1.0-1.rockspec create mode 100644 binary/lua-bz2-0.2.1-1.rockspec delete mode 100644 binary/luaposix-34.0.4-1.rockspec create mode 100644 binary/luaposix-35.1-1.rockspec delete mode 100644 binary/luasec-0.8.1-2.rockspec create mode 100644 binary/luasec-1.0.2-1.rockspec diff --git a/GNUmakefile b/GNUmakefile index f4a6015f..cbb47996 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -14,9 +14,10 @@ luadir = $(datarootdir)/lua/$(LUA_VERSION) builddir = ./build buildbinarydir = ./build-binary - LUAROCKS_FILES = $(shell find src/luarocks/ -type f -name '*.lua') +LUA_ENV_VARS = LUA_PATH LUA_PATH_5_2 LUA_PATH_5_3 LUA_PATH_5_4 LUA_CPATH LUA_CPATH_5_2 LUA_CPATH_5_3 LUA_CPATH_5_4 + all: build # ---------------------------------------- @@ -51,7 +52,7 @@ luarocks: config.unix $(builddir)/config-$(LUA_VERSION).lua cp $(builddir)/config-$(LUA_VERSION).lua .luarocks/config-$(LUA_VERSION).lua rm -f src/luarocks/core/hardcoded.lua echo "#!/bin/sh" > luarocks - echo "unset LUA_PATH LUA_PATH_5_2 LUA_PATH_5_3 LUA_PATH_5_4 LUA_CPATH LUA_CPATH_5_2 LUA_CPATH_5_3 LUA_CPATH_5_4" >> luarocks + echo "unset $(LUA_ENV_VARS)" >> luarocks echo 'LUAROCKS_SYSCONFDIR="$(luarocksconfdir)" LUA_PATH="$(CURDIR)/src/?.lua;;" exec "$(LUA)" "$(CURDIR)/src/bin/luarocks" --project-tree="$(CURDIR)/lua_modules" "$$@"' >> luarocks chmod +rx ./luarocks ./luarocks init @@ -59,7 +60,7 @@ luarocks: config.unix $(builddir)/config-$(LUA_VERSION).lua luarocks-admin: config.unix rm -f src/luarocks/core/hardcoded.lua echo "#!/bin/sh" > luarocks-admin - echo "unset LUA_PATH LUA_PATH_5_2 LUA_PATH_5_3 LUA_PATH_5_4 LUA_CPATH LUA_CPATH_5_2 LUA_CPATH_5_3 LUA_CPATH_5_4" >> luarocks-admin + echo "unset $(LUA_ENV_VARS)" >> luarocks-admin echo 'LUAROCKS_SYSCONFDIR="$(luarocksconfdir)" LUA_PATH="$(CURDIR)/src/?.lua;;" exec "$(LUA)" "$(CURDIR)/src/bin/luarocks-admin" --project-tree="$(CURDIR)/lua_modules" "$$@"' >> luarocks-admin chmod +rx ./luarocks-admin diff --git a/binary/Makefile.windows b/binary/Makefile.windows index e6ec26bf..8dbbc270 100644 --- a/binary/Makefile.windows +++ b/binary/Makefile.windows @@ -6,7 +6,7 @@ MINGW_SYSROOT=/usr/lib/mingw-w64-sysroot/$(MINGW_PREFIX) # "mingw" or "mingw64" OPENSSL_PLATFORM=mingw # Versions of dependencies -LIBLUA_VERSION=5.3.4 +LIBLUA_VERSION=5.4.3 OPENSSL_VERSION=1.0.2o ZLIB_VERSION=1.2.11 BZIP2_VERSION=1.0.6 diff --git a/binary/all_in_one b/binary/all_in_one index bfe9c974..34b84a2c 100755 --- a/binary/all_in_one +++ b/binary/all_in_one @@ -164,7 +164,7 @@ local function write_hardcoded_module(dir) LUA_BINDIR = if_platform("unix", cfg.variables.LUA_BINDIR), LUA_INTERPRETER = if_platform("unix", cfg.lua_interpreter), } - + local name = dir .. "/luarocks/core/hardcoded.lua" persist.save_as_module(name, hardcoded) return name @@ -335,7 +335,7 @@ static int pmain(lua_State *L) { /* error handler, from luac */ static int msghandler (lua_State *L) { /* is error object not a string? */ - const char *msg = lua_tostring(L, 1); + const char *msg = lua_tostring(L, 1); if (msg == NULL) { /* does it have a metamethod that produces a string */ if (luaL_callmeta(L, 1, "__tostring") && lua_type(L, -1) == LUA_TSTRING) { @@ -393,7 +393,7 @@ local function generate(main_program, dir, skip) local program_name = main_program:gsub(".*/", "") local hardcoded = write_hardcoded_module(dir) - + local out = {} table.insert(out, ([[static const char* progname = %q;]]):format(program_name)) table.insert(out, c_preamble) @@ -404,7 +404,7 @@ local function generate(main_program, dir, skip) table.insert(out, c_main) os.remove(hardcoded) - + local c_filename = TARGET_DIR .. "/" .. program_name .. ".exe.c" local fd = io.open(c_filename, "w") fd:write(reindent_c(table.concat(out, "\n"))) @@ -412,7 +412,7 @@ local function generate(main_program, dir, skip) deps.check_lua_incdir(cfg.variables) deps.check_lua_libdir(cfg.variables) - + cmd = table.concat(filter_in(nonnull, { CC, "-o", TARGET_DIR .. "/" .. program_name .. ".exe", "-I", cfg.variables.LUA_INCDIR, @@ -426,6 +426,7 @@ local function generate(main_program, dir, skip) cfg.variables.LUA_LIBDIR .. "/" .. cfg.variables.LUALIB:gsub("%.so.*$", ".a"), if_platform("unix", "-ldl"), if_platform("unix", "-lpthread"), + if_platform("windows", "-mwindows"), "-lm" }), " ") print(cmd) @@ -445,7 +446,7 @@ local function main() path.use_tree(LUA_MODULES) local CONFIG_FILE = CONFIG_DIR .. "/config-" .. cfg.lua_version .. ".lua" - + fs.make_dir(CONFIG_DIR) persist.save_from_table(CONFIG_FILE, { @@ -456,22 +457,23 @@ local function main() LD = fs.current_dir() .. "/binary/static-gcc", LIB_EXTENSION = "a", LIBFLAG = "-static", + PWD = "pwd", }, platforms = if_platform("windows", { "windows", "win32", "mingw32" }), external_deps_dirs = if_platform("windows", { CROSSCOMPILER_SYSROOT, fs.current_dir() .. "/windows-deps-" .. TRIPLET }), }) - + local dependencies = { md5 = "md5", - luasec = "./binary/luasec-0.8.1-2.rockspec", - luaposix = if_platform("unix", "./binary/luaposix-34.0.4-1.rockspec"), - luasocket = "luasocket", + luasec = "./binary/luasec-1.0.2-1.rockspec", ["lua-zlib"] = "./binary/lua-zlib-1.2-0.rockspec", - ["lua-bz2"] = "./binary/lua-bz2-0.1.0-1.rockspec", + ["lua-bz2"] = "./binary/lua-bz2-0.2.1-1.rockspec", + luaposix = if_platform("unix", "./binary/luaposix-35.1-1.rockspec"), + luasocket = "luasocket", luafilesystem = "luafilesystem", dkjson = "dkjson", } - + fs.make_dir(LUA_MODULES) for name, arg in pairs(dependencies) do print("----------------------------------------------------------------") diff --git a/binary/lua-bz2-0.1.0-1.rockspec b/binary/lua-bz2-0.1.0-1.rockspec deleted file mode 100644 index aa29293f..00000000 --- a/binary/lua-bz2-0.1.0-1.rockspec +++ /dev/null @@ -1,44 +0,0 @@ -package = "lua-bz2" -version = "0.1.0-1" -source = { - url = "git+ssh://git@github.com/hishamhm/lua-bz2.git", - tag = "0.1.0", -} -description = { - summary = "A Lua binding to Julian Seward's libbzip2", - detailed = [[ - Support for reading and writing .bz2 files - and handling streams compressed in bzip2 format. - ]], - homepage = "https://github.com/harningt/lua-bz2", - license = "ISC" -} -external_dependencies = { - BZ2 = { - library = "bz2" - } -} -build = { - type = "builtin", - modules = { - bz2 = { - incdirs = { - "$(BZ2_INCDIR)" - }, - libdirs = { - "$(BZ2_LIBDIR)" - }, - libraries = { - "bz2" - }, - sources = { - "lbz.c", - "lbz2_common.c", - "lbz2_file_reader.c", - "lbz2_file_writer.c", - "lbz2_stream.c", - } - }, - ["bz2.ltn12"] = "bz2/ltn12.lua", - } -} diff --git a/binary/lua-bz2-0.2.1-1.rockspec b/binary/lua-bz2-0.2.1-1.rockspec new file mode 100644 index 00000000..d5a73778 --- /dev/null +++ b/binary/lua-bz2-0.2.1-1.rockspec @@ -0,0 +1,44 @@ +package = "lua-bz2" +version = "0.2.1-1" +source = { + url = "git+ssh://git@github.com/hishamhm/lua-bz2.git", + tag = "0.2.1", +} +description = { + summary = "A Lua binding to Julian Seward's libbzip2", + detailed = [[ + Support for reading and writing .bz2 files + and handling streams compressed in bzip2 format. + ]], + homepage = "https://github.com/harningt/lua-bz2", + license = "ISC" +} +external_dependencies = { + BZ2 = { + library = "bz2" + } +} +build = { + type = "builtin", + modules = { + bz2 = { + incdirs = { + "$(BZ2_INCDIR)" + }, + libdirs = { + "$(BZ2_LIBDIR)" + }, + libraries = { + "bz2" + }, + sources = { + "lbz.c", + "lbz2_common.c", + "lbz2_file_reader.c", + "lbz2_file_writer.c", + "lbz2_stream.c", + } + }, + ["bz2.ltn12"] = "bz2/ltn12.lua", + } +} diff --git a/binary/lua-zlib-1.2-0.rockspec b/binary/lua-zlib-1.2-0.rockspec index dd0c4a15..4e32448f 100644 --- a/binary/lua-zlib-1.2-0.rockspec +++ b/binary/lua-zlib-1.2-0.rockspec @@ -16,7 +16,7 @@ description = { license = "MIT" } dependencies = { - "lua >= 5.1, <= 5.3" + "lua >= 5.1, <= 5.4" } external_dependencies = { ZLIB = { diff --git a/binary/luaposix-34.0.4-1.rockspec b/binary/luaposix-34.0.4-1.rockspec deleted file mode 100644 index 490715d5..00000000 --- a/binary/luaposix-34.0.4-1.rockspec +++ /dev/null @@ -1,55 +0,0 @@ -local _MODREV, _SPECREV = '34.0.4', '-1' - -package = 'luaposix' -version = _MODREV .. _SPECREV - -description = { - summary = 'Lua bindings for POSIX', - detailed = [[ - A library binding various POSIX APIs. POSIX is the IEEE Portable - Operating System Interface standard. luaposix is based on lposix. - ]], - homepage = 'http://github.com/luaposix/luaposix/', - license = 'MIT/X11', -} - -dependencies = { - 'bit32', - 'lua >= 5.1, < 5.4', - 'std.normalize', -} - -source = { - url = 'http://github.com/luaposix/luaposix/archive/v' .. _MODREV .. '.zip', - dir = 'luaposix-' .. _MODREV, -} - -build = { - type = 'command', - build_command = '$(LUA) build-aux/luke' - .. ' package="' .. package .. '"' - .. ' version="' .. _MODREV .. '"' - .. ' PREFIX="$(PREFIX)"' - .. ' LUA="$(LUA)"' - .. ' LUA_INCDIR="$(LUA_INCDIR)"' - .. ' CFLAGS="$(CFLAGS)"' - .. ' LIBFLAG="$(LIBFLAG)"' - .. ' LIB_EXTENSION="$(LIB_EXTENSION)"' - .. ' OBJ_EXTENSION="$(OBJ_EXTENSION)"' - .. ' INST_LIBDIR="$(LIBDIR)"' - .. ' INST_LUADIR="$(LUADIR)"' - , - install_command = '$(LUA) build-aux/luke install --quiet' - .. ' INST_LIBDIR="$(LIBDIR)"' - .. ' LIB_EXTENSION="$(LIB_EXTENSION)"' - .. ' INST_LUADIR="$(LUADIR)"' - , -} - -if _MODREV == 'git' then - dependencies[#dependencies + 1] = 'ldoc' - - source = { - url = 'git://github.com/luaposix/luaposix.git', - } -end diff --git a/binary/luaposix-35.1-1.rockspec b/binary/luaposix-35.1-1.rockspec new file mode 100644 index 00000000..1940c755 --- /dev/null +++ b/binary/luaposix-35.1-1.rockspec @@ -0,0 +1,61 @@ +local _MODREV, _SPECREV = '35.1', '-1' + +package = 'luaposix' +version = _MODREV .. _SPECREV + +description = { + summary = 'Lua bindings for POSIX', + detailed = [[ + A library binding various POSIX APIs. POSIX is the IEEE Portable + Operating System Interface standard. luaposix is based on lposix. + ]], + homepage = 'http://github.com/luaposix/luaposix/', + license = 'MIT/X11', +} + +dependencies = { + 'lua >= 5.1, < 5.5', +} + +do + -- We only want to install a bit32 module for Lua 5.1. + local _ENV={package=nil, dependencies=dependencies} + if package then + dependencies[#dependencies + 1] = 'bit32' + end +end + +source = { + url = 'http://github.com/luaposix/luaposix/archive/v' .. _MODREV .. '.zip', + dir = 'luaposix-' .. _MODREV, +} + +build = { + type = 'command', + build_command = '$(LUA) build-aux/luke' + .. ' package="' .. package .. '"' + .. ' version="' .. _MODREV .. '"' + .. ' PREFIX="$(PREFIX)"' + .. ' LUA="$(LUA)"' + .. ' LUA_INCDIR="$(LUA_INCDIR)"' + .. ' CFLAGS="$(CFLAGS)"' + .. ' LIBFLAG="$(LIBFLAG)"' + .. ' LIB_EXTENSION="$(LIB_EXTENSION)"' + .. ' OBJ_EXTENSION="$(OBJ_EXTENSION)"' + .. ' INST_LIBDIR="$(LIBDIR)"' + .. ' INST_LUADIR="$(LUADIR)"' + , + install_command = '$(LUA) build-aux/luke install --quiet' + .. ' INST_LIBDIR="$(LIBDIR)"' + .. ' LIB_EXTENSION="$(LIB_EXTENSION)"' + .. ' INST_LUADIR="$(LUADIR)"' + , +} + +if _MODREV == 'git' then + dependencies[#dependencies + 1] = 'ldoc' + + source = { + url = 'git://github.com/luaposix/luaposix.git', + } +end diff --git a/binary/luasec-0.8.1-2.rockspec b/binary/luasec-0.8.1-2.rockspec deleted file mode 100644 index 510e88ef..00000000 --- a/binary/luasec-0.8.1-2.rockspec +++ /dev/null @@ -1,124 +0,0 @@ -package = "LuaSec" -version = "0.8.1-2" -source = { - url = "https://github.com/brunoos/luasec/archive/luasec-0.8.1.tar.gz", - dir = "luasec-luasec-0.8.1" -} -description = { - summary = "A binding for OpenSSL library to provide TLS/SSL communication over LuaSocket.", - detailed = "This version delegates to LuaSocket the TCP connection establishment between the client and server. Then LuaSec uses this connection to start a secure TLS/SSL session.", - homepage = "https://github.com/brunoos/luasec/wiki", - license = "MIT" -} -dependencies = { - "lua >= 5.1", "luasocket" -} -external_dependencies = { - platforms = { - unix = { - OPENSSL = { - header = "openssl/ssl.h", - library = "ssl" - } - }, - windows = { - OPENSSL = { - header = "openssl/ssl.h", - } - }, - mingw32 = { - OPENSSL = { - library = "ssl", - } - }, - } -} -build = { - type = "builtin", - copy_directories = { - "samples" - }, - platforms = { - unix = { - modules = { - ['ssl.https'] = "src/https.lua", - ['ssl.init'] = "src/ssl.lua", - ssl = { - defines = { - "WITH_LUASOCKET", "LUASOCKET_DEBUG", - }, - incdirs = { - "$(OPENSSL_INCDIR)", "src/", "src/luasocket", - }, - libdirs = { - "$(OPENSSL_LIBDIR)" - }, - libraries = { - "ssl", "crypto" - }, - sources = { - "src/config.c", "src/ec.c", - "src/x509.c", "src/context.c", "src/ssl.c", - "src/luasocket/buffer.c", "src/luasocket/io.c", - "src/luasocket/timeout.c", "src/luasocket/usocket.c" - } - } - } - }, - mingw32 = { - modules = { - ssl = { - libraries = { - "ssl", "crypto", "ws2_32", "gdi32" - } - } - } - }, - windows = { - modules = { - ['ssl.https'] = "src/https.lua", - ['ssl.init'] = "src/ssl.lua", - ssl = { - defines = { - "WIN32", "NDEBUG", "_WINDOWS", "_USRDLL", "LSEC_EXPORTS", "BUFFER_DEBUG", "LSEC_API=__declspec(dllexport)", - "WITH_LUASOCKET", "LUASOCKET_DEBUG", - "LUASEC_INET_NTOP", "WINVER=0x0501", "_WIN32_WINNT=0x0501", "NTDDI_VERSION=0x05010300" - }, - libdirs = { - "$(OPENSSL_LIBDIR)", - "$(OPENSSL_BINDIR)", - }, - libraries = { - "libssl32MD", "libcrypto32MD", "ws2_32" - }, - incdirs = { - "$(OPENSSL_INCDIR)", "src/", "src/luasocket" - }, - sources = { - "src/config.c", "src/ec.c", - "src/x509.c", "src/context.c", "src/ssl.c", - "src/luasocket/buffer.c", "src/luasocket/io.c", - "src/luasocket/timeout.c", "src/luasocket/wsocket.c" - } - } - }, - patches = { -["lowercase-winsock-h.diff"] = [[ -diff --git a/src/ssl.c b/src/ssl.c -index 95109c4..e5defa8 100644 ---- a/src/ssl.c -+++ b/src/ssl.c -@@ -11,7 +11,7 @@ - #include - - #if defined(WIN32) --#include -+#include - #endif - - #include -]] - } - } - } -} diff --git a/binary/luasec-1.0.2-1.rockspec b/binary/luasec-1.0.2-1.rockspec new file mode 100644 index 00000000..b6741257 --- /dev/null +++ b/binary/luasec-1.0.2-1.rockspec @@ -0,0 +1,115 @@ +package = "LuaSec" +version = "1.0.2-1" +source = { + url = "git://github.com/brunoos/luasec", + tag = "v1.0.2", +} +description = { + summary = "A binding for OpenSSL library to provide TLS/SSL communication over LuaSocket.", + detailed = "This version delegates to LuaSocket the TCP connection establishment between the client and server. Then LuaSec uses this connection to start a secure TLS/SSL session.", + homepage = "https://github.com/brunoos/luasec/wiki", + license = "MIT" +} +dependencies = { + "lua >= 5.1", "luasocket" +} +external_dependencies = { + platforms = { + unix = { + OPENSSL = { + header = "openssl/ssl.h", + library = "ssl" + } + }, + windows = { + OPENSSL = { + header = "openssl/ssl.h", + } + }, + mingw32 = { + OPENSSL = { + library = "ssl", + } + }, + } +} +build = { + type = "builtin", + copy_directories = { + "samples" + }, + platforms = { + unix = { + modules = { + ['ssl.https'] = "src/https.lua", + ['ssl.init'] = "src/ssl.lua", + ssl = { + defines = { + "WITH_LUASOCKET", "LUASOCKET_DEBUG", + }, + incdirs = { + "$(OPENSSL_INCDIR)", "src/", "src/luasocket", + }, + libdirs = { + "$(OPENSSL_LIBDIR)" + }, + libraries = { + "ssl", "crypto" + }, + sources = { + "src/options.c", "src/config.c", "src/ec.c", + "src/x509.c", "src/context.c", "src/ssl.c", + "src/luasocket/buffer.c", "src/luasocket/io.c", + "src/luasocket/usocket.c" -- , "src/luasocket/timeout.c" + } + } + } + }, + windows = { + modules = { + ['ssl.https'] = "src/https.lua", + ['ssl.init'] = "src/ssl.lua", + ssl = { + defines = { + "WIN32", "NDEBUG", "_WINDOWS", "_USRDLL", "LSEC_EXPORTS", "BUFFER_DEBUG", "LSEC_API=__declspec(dllexport)", + "WITH_LUASOCKET", "LUASOCKET_DEBUG", + "LUASEC_INET_NTOP", "WINVER=0x0501", "_WIN32_WINNT=0x0501", "NTDDI_VERSION=0x05010300" + }, + libdirs = { + "$(OPENSSL_LIBDIR)", + "$(OPENSSL_BINDIR)", + }, + libraries = { + "ssl", "crypto", "ws2_32" + }, + incdirs = { + "$(OPENSSL_INCDIR)", "src/", "src/luasocket" + }, + sources = { + "src/options.c", "src/config.c", "src/ec.c", + "src/x509.c", "src/context.c", "src/ssl.c", + "src/luasocket/buffer.c", "src/luasocket/io.c", + "src/luasocket/wsocket.c", "src/luasocket/timeout.c" + } + } + }, + patches = { +["lowercase-winsock-h.diff"] = [[ +diff --git a/src/ssl.c b/src/ssl.c +index 95109c4..e5defa8 100644 +--- a/src/ssl.c ++++ b/src/ssl.c +@@ -11,7 +11,7 @@ + #include + + #if defined(WIN32) +-#include ++#include + #endif + + #include +]] + } + } + } +} diff --git a/src/luarocks/fs/tools.lua b/src/luarocks/fs/tools.lua index 623e5a90..0a154794 100644 --- a/src/luarocks/fs/tools.lua +++ b/src/luarocks/fs/tools.lua @@ -57,7 +57,7 @@ do local current = cache_pwd if not current then local pipe = io.popen(fs.quiet_stderr(vars.PWD)) - current = pipe:read("*l"):gsub("%s*", "") + current = pipe:read("*a"):gsub("^%s*", ""):gsub("%s*$", "") pipe:close() cache_pwd = current end diff --git a/src/luarocks/fs/unix.lua b/src/luarocks/fs/unix.lua index 2c66eaa3..0065753e 100644 --- a/src/luarocks/fs/unix.lua +++ b/src/luarocks/fs/unix.lua @@ -90,7 +90,8 @@ function unix.wrap_script(script, target, deps_mode, name, version, ...) } local remove_interpreter = false - if target == "luarocks" or target == "luarocks-admin" then + local base = dir.base_name(target):gsub("%..*$", "") + if base == "luarocks" or base == "luarocks-admin" then if cfg.is_binary then remove_interpreter = true end diff --git a/src/luarocks/fs/win32.lua b/src/luarocks/fs/win32.lua index 1902a691..a3f42df7 100644 --- a/src/luarocks/fs/win32.lua +++ b/src/luarocks/fs/win32.lua @@ -167,7 +167,8 @@ function win32.wrap_script(script, target, deps_mode, name, version, ...) } local remove_interpreter = false - if target == "luarocks" or target == "luarocks-admin" then + local base = dir.base_name(target):gsub("%..*$", "") + if base == "luarocks" or base == "luarocks-admin" then if cfg.is_binary then remove_interpreter = true end -- cgit v1.2.3-55-g6feb