From 291fc8a34fc186b011c9d6b09a80bf179cae6f62 Mon Sep 17 00:00:00 2001 From: Pierre Chapuis Date: Mon, 1 Dec 2025 22:25:11 +0100 Subject: support Lua 5.5 --- src/luarocks/cmd/write_rockspec.lua | 10 ++++++++++ src/luarocks/cmd/write_rockspec.tl | 12 +++++++++++- src/luarocks/core/util.lua | 2 +- src/luarocks/core/util.tl | 2 +- src/luarocks/deps.lua | 6 +++++- src/luarocks/deps.tl | 6 +++++- src/luarocks/fs/lua.lua | 1 + src/luarocks/tools/patch.lua | 1 + src/luarocks/tools/patch.tl | 1 + src/luarocks/util.lua | 6 +++--- src/luarocks/util.tl | 6 +++--- 11 files changed, 42 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/luarocks/cmd/write_rockspec.lua b/src/luarocks/cmd/write_rockspec.lua index b84c2803..5710c982 100644 --- a/src/luarocks/cmd/write_rockspec.lua +++ b/src/luarocks/cmd/write_rockspec.lua @@ -28,12 +28,17 @@ local lua_versions = { "5.2", "5.3", "5.4", + "5.5", "5.1,5.2", "5.2,5.3", "5.3,5.4", + "5.4,5.5", "5.1,5.2,5.3", "5.2,5.3,5.4", + "5.3,5.4,5.5", "5.1,5.2,5.3,5.4", + "5.2,5.3,5.4,5.5", + "5.1,5.2,5.3,5.4,5.5", } function write_rockspec.cmd_options(parser) @@ -110,12 +115,17 @@ local lua_version_dep = { ["5.2"] = "lua ~> 5.2", ["5.3"] = "lua ~> 5.3", ["5.4"] = "lua ~> 5.4", + ["5.5"] = "lua ~> 5.5", ["5.1,5.2"] = "lua >= 5.1, < 5.3", ["5.2,5.3"] = "lua >= 5.2, < 5.4", ["5.3,5.4"] = "lua >= 5.3, < 5.5", + ["5.4,5.5"] = "lua >= 5.4, < 5.6", ["5.1,5.2,5.3"] = "lua >= 5.1, < 5.4", ["5.2,5.3,5.4"] = "lua >= 5.2, < 5.5", + ["5.3,5.4,5.5"] = "lua >= 5.3, < 5.6", ["5.1,5.2,5.3,5.4"] = "lua >= 5.1, < 5.5", + ["5.2,5.3,5.4,5.5"] = "lua >= 5.2, < 5.6", + ["5.1,5.2,5.3,5.4,5.5"] = "lua >= 5.1, < 5.6", } local simple_scm_protocols = { diff --git a/src/luarocks/cmd/write_rockspec.tl b/src/luarocks/cmd/write_rockspec.tl index 7354a683..2ec4eea9 100644 --- a/src/luarocks/cmd/write_rockspec.tl +++ b/src/luarocks/cmd/write_rockspec.tl @@ -28,12 +28,17 @@ local lua_versions = { "5.2", "5.3", "5.4", + "5.5", "5.1,5.2", "5.2,5.3", "5.3,5.4", + "5.4,5.5", "5.1,5.2,5.3", "5.2,5.3,5.4", - "5.1,5.2,5.3,5.4" + "5.3,5.4,5.5", + "5.1,5.2,5.3,5.4", + "5.2,5.3,5.4,5.5", + "5.1,5.2,5.3,5.4,5.5", } function write_rockspec.cmd_options(parser: Parser) @@ -110,12 +115,17 @@ local lua_version_dep = { ["5.2"] = "lua ~> 5.2", ["5.3"] = "lua ~> 5.3", ["5.4"] = "lua ~> 5.4", + ["5.5"] = "lua ~> 5.5", ["5.1,5.2"] = "lua >= 5.1, < 5.3", ["5.2,5.3"] = "lua >= 5.2, < 5.4", ["5.3,5.4"] = "lua >= 5.3, < 5.5", + ["5.4,5.5"] = "lua >= 5.4, < 5.6", ["5.1,5.2,5.3"] = "lua >= 5.1, < 5.4", ["5.2,5.3,5.4"] = "lua >= 5.2, < 5.5", + ["5.3,5.4,5.5"] = "lua >= 5.3, < 5.6", ["5.1,5.2,5.3,5.4"] = "lua >= 5.1, < 5.5", + ["5.2,5.3,5.4,5.5"] = "lua >= 5.2, < 5.6", + ["5.1,5.2,5.3,5.4,5.5"] = "lua >= 5.1, < 5.6", } local simple_scm_protocols = { diff --git a/src/luarocks/core/util.lua b/src/luarocks/core/util.lua index a6ff0fcb..40ba213d 100644 --- a/src/luarocks/core/util.lua +++ b/src/luarocks/core/util.lua @@ -96,7 +96,7 @@ function util.show_table(t, tname, top_indent) else cart = cart .. " = {\n" for k, v in pairs(value) do - k = basic_serialize(k) + local k = basic_serialize(k) local fname = ("%s[%s]"):format(name, k) field = ("[%s]"):format(k) diff --git a/src/luarocks/core/util.tl b/src/luarocks/core/util.tl index b1bbea05..1a6fefca 100644 --- a/src/luarocks/core/util.tl +++ b/src/luarocks/core/util.tl @@ -96,7 +96,7 @@ function util.show_table(t: {any:any}, tname: string, top_indent: string): strin else cart = cart .. " = {\n" for k, v in pairs(value) do - k = basic_serialize(k) + local k = basic_serialize(k) local fname = ("%s[%s]"):format(name, k) field = ("[%s]"):format(k) -- three spaces between levels diff --git a/src/luarocks/deps.lua b/src/luarocks/deps.lua index 13b531f6..3eded47a 100644 --- a/src/luarocks/deps.lua +++ b/src/luarocks/deps.lua @@ -713,7 +713,11 @@ local function lua_h_exists(d, luaver) if fd then local data = fd:read("*a") fd:close() - if data:match("LUA_VERSION_NUM%s*" .. tostring(luanum)) then + if major == "5" and minor == "5" then + if data:match("LUA_VERSION_MINOR_N%s5") and data:match("LUA_VERSION_MAJOR_N%s5") then + return d ~= nil + end + elseif data:match("LUA_VERSION_NUM%s*" .. tostring(luanum)) then return d ~= nil end return nil, "Lua header lua.h found at " .. d .. " does not match Lua version " .. luaver .. ". You can use `luarocks config variables.LUA_INCDIR ` to set the correct location.", "dependency", 2 diff --git a/src/luarocks/deps.tl b/src/luarocks/deps.tl index 98fad54d..85980347 100644 --- a/src/luarocks/deps.tl +++ b/src/luarocks/deps.tl @@ -713,7 +713,11 @@ local function lua_h_exists(d: string, luaver: string): boolean, string, string, if fd then local data = fd:read("*a") fd:close() - if data:match("LUA_VERSION_NUM%s*" .. tostring(luanum)) then + if major == "5" and minor == "5" then + if data:match("LUA_VERSION_MINOR_N%s5") and data:match("LUA_VERSION_MAJOR_N%s5") then + return d ~= nil + end + elseif data:match("LUA_VERSION_NUM%s*" .. tostring(luanum)) then return d ~= nil end return nil, "Lua header lua.h found at " .. d .. " does not match Lua version " .. luaver .. ". You can use `luarocks config variables.LUA_INCDIR ` to set the correct location.", "dependency", 2 diff --git a/src/luarocks/fs/lua.lua b/src/luarocks/fs/lua.lua index 0f1ee55e..45324c77 100644 --- a/src/luarocks/fs/lua.lua +++ b/src/luarocks/fs/lua.lua @@ -213,6 +213,7 @@ function fs_lua.modules(at) local path = package.path:sub(-1, -1) == ";" and package.path or package.path .. ";" local paths = {} for location in path:gmatch("(.-);") do + local location = location if location:lower() == "?.lua" then location = "./?.lua" end diff --git a/src/luarocks/tools/patch.lua b/src/luarocks/tools/patch.lua index d1575cb0..5b00e9b1 100644 --- a/src/luarocks/tools/patch.lua +++ b/src/luarocks/tools/patch.lua @@ -188,6 +188,7 @@ function patch.read_patch(filename, data) local lineno = 0 for line in file_lines(fp) do + local line = line lineno = lineno + 1 if state == 'header' then if startswith(line, "--- ") then diff --git a/src/luarocks/tools/patch.tl b/src/luarocks/tools/patch.tl index 553964e3..2cfd3841 100644 --- a/src/luarocks/tools/patch.tl +++ b/src/luarocks/tools/patch.tl @@ -188,6 +188,7 @@ function patch.read_patch(filename: string, data: string): Files, boolean local lineno = 0 for line in file_lines(fp) do + local line = line lineno = lineno + 1 if state == 'header' then if startswith(line, "--- ") then diff --git a/src/luarocks/util.lua b/src/luarocks/util.lua index ffa53b09..b35c63ce 100644 --- a/src/luarocks/util.lua +++ b/src/luarocks/util.lua @@ -160,7 +160,7 @@ function util.variable_substitutions(tbl, vars) end function util.lua_versions(sort) - local versions = { "5.1", "5.2", "5.3", "5.4" } + local versions = { "5.1", "5.2", "5.3", "5.4", "5.5" } local i = 0 if sort == "descending" then i = #versions + 1 @@ -286,7 +286,7 @@ local function collect_rockspecs(versions, paths, unnamed_paths, subdir) local vers = require("luarocks.core.vers") if fs.is_dir(subdir) then for file in fs.dir(subdir) do - file = dir.path(subdir, file) + local file = dir.path(subdir, file) if file:match("rockspec$") and fs.is_file(file) then local rock, version = path.parse_name(file) @@ -550,7 +550,7 @@ function util.get_rocks_provided(rockspec) rocks_provided["bit32"] = lv .. "-1" end - if lv == "5.3" or lv == "5.4" then + if lv == "5.3" or lv == "5.4" or lv == "5.5" then rocks_provided["utf8"] = lv .. "-1" end diff --git a/src/luarocks/util.tl b/src/luarocks/util.tl index b68883e5..f2fb5a5a 100644 --- a/src/luarocks/util.tl +++ b/src/luarocks/util.tl @@ -160,7 +160,7 @@ function util.variable_substitutions(tbl: {K: string}, vars: {string: string} end function util.lua_versions(sort?: string): function(): string - local versions = { "5.1", "5.2", "5.3", "5.4" } + local versions = { "5.1", "5.2", "5.3", "5.4", "5.5" } local i = 0 if sort == "descending" then i = #versions + 1 @@ -286,7 +286,7 @@ local function collect_rockspecs(versions: {string: string}, paths: {string: str local vers = require("luarocks.core.vers") if fs.is_dir(subdir) then for file in fs.dir(subdir) do - file = dir.path(subdir, file) + local file = dir.path(subdir, file) if file:match("rockspec$") and fs.is_file(file) then local rock, version = path.parse_name(file) @@ -550,7 +550,7 @@ function util.get_rocks_provided(rockspec?: Rockspec): {string: string} rocks_provided["bit32"] = lv.."-1" end - if lv == "5.3" or lv == "5.4" then + if lv == "5.3" or lv == "5.4" or lv == "5.5" then rocks_provided["utf8"] = lv.."-1" end -- cgit v1.2.3-55-g6feb From d9e6c13f50d7cc8e76fb74643f135ab82c3aa9ba Mon Sep 17 00:00:00 2001 From: Pierre Chapuis Date: Wed, 24 Dec 2025 14:53:36 +0100 Subject: support Lua 5.5 in install.bat and win32 fs module Co-authored-by: luau-project --- install.bat | 14 +++++++------- src/luarocks/fs/win32/tools.lua | 3 ++- 2 files changed, 9 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/install.bat b/install.bat index 5210a862..25fc697e 100644 --- a/install.bat +++ b/install.bat @@ -136,7 +136,7 @@ Configuring the destinations: if you create a self contained installation. Configuring the Lua interpreter: -/LV [version] Lua version to use; either 5.1, 5.2, 5.3, or 5.4. +/LV [version] Lua version to use; either 5.1, 5.2, 5.3, 5.4 or 5.5. Default is auto-detected. /LUA [dir] Location where Lua is installed - e.g. c:\lua\5.1\ If not provided, the installer will search the system @@ -258,8 +258,8 @@ local function check_flags() die("Bundled Lua version is 5.1, cannot install "..vars.LUA_VERSION) end end - if not vars.LUA_VERSION:match("^5%.[1234]$") then - die("Bad argument: /LV must either be 5.1, 5.2, 5.3, or 5.4") + if not vars.LUA_VERSION:match("^5%.[12345]$") then + die("Bad argument: /LV must either be 5.1, 5.2, 5.3, 5.4 or 5.5") end if USE_MSVC_MANUAL and USE_MINGW then die("Cannot combine option /MSVC and /MW") @@ -277,7 +277,7 @@ local function detect_lua_version(interpreter_path) local full_version = handler:read("*a") handler:close() - local version = full_version:match(" (5%.[1234])$") + local version = full_version:match(" (5%.[12345])$") if not version then return nil, "unknown interpreter version '" .. full_version .. "'" end @@ -289,7 +289,7 @@ local function look_for_interpreter(directory) if lua_version_set then names = {S"lua$LUA_VERSION.exe", S"lua$LUA_SHORTV.exe"} else - names = {"lua5.4.exe", "lua54.exe", "lua5.3.exe", "lua53.exe", "lua5.2.exe", "lua52.exe", "lua5.1.exe", "lua51.exe"} + names = {"lua5.5.exe", "lua55.exe", "lua5.4.exe", "lua54.exe", "lua5.3.exe", "lua53.exe", "lua5.2.exe", "lua52.exe", "lua5.1.exe", "lua51.exe"} end table.insert(names, "lua.exe") table.insert(names, "luajit.exe") @@ -622,7 +622,7 @@ local function get_possible_lua_directories() local directories = {} for dir in path:gmatch("[^;]+") do -- Remove trailing backslashes, but not from a drive letter like `C:\`. - dir = dir:gsub("([^:])\\+$", "%1") + local dir = dir:gsub("([^:])\\+$", "%1") -- Remove trailing `bin` subdirectory, the searcher will check there anyway. if dir:upper():match("[:\\]BIN$") then dir = dir:sub(1, -5) @@ -1024,7 +1024,7 @@ end if not exec(S[[XCOPY /S src\luarocks\*.* "$LUADIR\luarocks" >NUL]]) then die() end -if vars.LUA_VERSION ~= "5.3" or vars.LUA_VERSION ~= "5.4" then +if vars.LUA_VERSION ~= "5.3" or vars.LUA_VERSION ~= "5.4" or vars.LUA_VERSION ~= "5.5" then -- Copy the vendored lua-copmat53 source files if not exists(S[[$LUADIR\compat53]]) then if not mkdir(S[[$LUADIR\compat53]]) then diff --git a/src/luarocks/fs/win32/tools.lua b/src/luarocks/fs/win32/tools.lua index 86cbb45b..56f04b19 100644 --- a/src/luarocks/fs/win32/tools.lua +++ b/src/luarocks/fs/win32/tools.lua @@ -131,6 +131,7 @@ function tools.find(at) local pipe = io.popen(fs.command_at(at, fs.quiet_stderr(vars.FIND), true)) for file in pipe:lines() do -- Windows find is a bit different + local file = file local first_two = file:sub(1,2) if first_two == ".\\" or first_two == "./" then file=file:sub(3) end if file ~= "." then @@ -223,7 +224,7 @@ local function get_system_users() local result = {} local fd = assert(io.popen("wmic UserAccount get name")) for user in fd:lines() do - user = user:gsub("%s+$", "") + local user = user:gsub("%s+$", "") if not exclude[user] then table.insert(result, user) end -- cgit v1.2.3-55-g6feb From ee8194313e61c9d0d7b8a0d52d22b026a06282bb Mon Sep 17 00:00:00 2001 From: Pierre Chapuis Date: Fri, 26 Dec 2025 11:22:19 +0100 Subject: improve header matching for Lua 5.5+ --- src/luarocks/deps.lua | 10 +++++----- src/luarocks/deps.tl | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/luarocks/deps.lua b/src/luarocks/deps.lua index 3eded47a..90c11bd5 100644 --- a/src/luarocks/deps.lua +++ b/src/luarocks/deps.lua @@ -705,19 +705,19 @@ function deps.scan_deps(results, mdeps, name, version, deps_mode) end local function lua_h_exists(d, luaver) - local major, minor = luaver:match("(%d+)%.(%d+)") - local luanum = ("%s%02d"):format(major, math.tointeger(minor)) + local major_s, minor_s = luaver:match("(%d+)%.(%d+)") + local major, minor = math.tointeger(major_s), math.tointeger(minor_s) local lua_h = dir.path(d, "lua.h") local fd = io.open(lua_h) if fd then local data = fd:read("*a") fd:close() - if major == "5" and minor == "5" then - if data:match("LUA_VERSION_MINOR_N%s5") and data:match("LUA_VERSION_MAJOR_N%s5") then + if vers.parse_version(("%d.%d"):format(major, minor)) >= vers.parse_version("5.5") then + if data:match("LUA_VERSION_MAJOR_N%s+" .. major) and data:match("LUA_VERSION_MINOR_N%s+" .. minor) then return d ~= nil end - elseif data:match("LUA_VERSION_NUM%s*" .. tostring(luanum)) then + elseif data:match("LUA_VERSION_NUM%s*" .. ("%d%02d"):format(major, minor)) then return d ~= nil end return nil, "Lua header lua.h found at " .. d .. " does not match Lua version " .. luaver .. ". You can use `luarocks config variables.LUA_INCDIR ` to set the correct location.", "dependency", 2 diff --git a/src/luarocks/deps.tl b/src/luarocks/deps.tl index 85980347..55006a95 100644 --- a/src/luarocks/deps.tl +++ b/src/luarocks/deps.tl @@ -705,19 +705,19 @@ function deps.scan_deps(results: {string: string}, mdeps: {string: {string: {Que end local function lua_h_exists(d: string, luaver: string): boolean, string, string, integer - local major, minor = luaver:match("(%d+)%.(%d+)") - local luanum = ("%s%02d"):format(major, math.tointeger(minor)) + local major_s, minor_s = luaver:match("(%d+)%.(%d+)") + local major, minor = math.tointeger(major_s), math.tointeger(minor_s) local lua_h = dir.path(d, "lua.h") local fd = io.open(lua_h) if fd then local data = fd:read("*a") fd:close() - if major == "5" and minor == "5" then - if data:match("LUA_VERSION_MINOR_N%s5") and data:match("LUA_VERSION_MAJOR_N%s5") then + if vers.parse_version(("%d.%d"):format(major, minor)) >= vers.parse_version("5.5") then + if data:match("LUA_VERSION_MAJOR_N%s+" .. major) and data:match("LUA_VERSION_MINOR_N%s+" .. minor) then return d ~= nil end - elseif data:match("LUA_VERSION_NUM%s*" .. tostring(luanum)) then + elseif data:match("LUA_VERSION_NUM%s*" .. ("%d%02d"):format(major, minor)) then return d ~= nil end return nil, "Lua header lua.h found at " .. d .. " does not match Lua version " .. luaver .. ". You can use `luarocks config variables.LUA_INCDIR ` to set the correct location.", "dependency", 2 -- cgit v1.2.3-55-g6feb