From 8ce99cc3d2d12eb0b0e4808e5dd1fc402b8603d4 Mon Sep 17 00:00:00 2001 From: Peter Melnichenko Date: Wed, 12 Oct 2016 19:37:46 +0300 Subject: Fix manif.find_{current,next}_provider returning "untracked" incorrectly `find_providers` function used by `manif.find_current_provider` and `manif.find_next_provider` needs relative path from a directory an installed file is deployed in (bin dir, lua dir, or lib dir) to the file. It then uses that path as key in manifest, converting it to module name beforehand for lua files and lib files. It happened to leave a leading slash in this relative path for lua and lib files. `path.path_to_module` has a workaround stripping leading dots caused by leading slashes. However, if the file doesn't have `.lua` extension, slashes are not converted to dots and the workaround doesn't trigger. The issue results in files falsely considered "untracked" and backed-up when reinstalling a different version of a rock, see sailorproject/sailor#138. The fix is to use correct relative paths without leading slashes. --- src/luarocks/manif.lua | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/luarocks/manif.lua b/src/luarocks/manif.lua index e30c2a33..48b4f23d 100644 --- a/src/luarocks/manif.lua +++ b/src/luarocks/manif.lua @@ -464,6 +464,11 @@ function manif.zip_manifests() end end +local function relative_path(from_dir, to_file) + -- It is assumed that `from_dir` is prefix of `to_file`. + return (to_file:sub(#from_dir + 1):gsub("^[\\/]*", "")) +end + local function find_providers(file, root) assert(type(file) == "string") root = root or cfg.root_dir @@ -479,13 +484,13 @@ local function find_providers(file, root) if util.starts_with(file, deploy_lua) then manifest_tbl = manifest.modules - key = path.path_to_module(file:sub(#deploy_lua+1):gsub("\\", "/")) + key = path.path_to_module(relative_path(deploy_lua, file):gsub("\\", "/")) elseif util.starts_with(file, deploy_lib) then manifest_tbl = manifest.modules - key = path.path_to_module(file:sub(#deploy_lib+1):gsub("\\", "/")) + key = path.path_to_module(relative_path(deploy_lib, file):gsub("\\", "/")) elseif util.starts_with(file, deploy_bin) then manifest_tbl = manifest.commands - key = file:sub(#deploy_bin+1):gsub("^[\\/]*", "") + key = relative_path(deploy_bin, file) else assert(false, "Assertion failed: '"..file.."' is not a deployed file.") end -- cgit v1.2.3-55-g6feb From 23043499b9a5423ecbc19e968142df17dc5d15d1 Mon Sep 17 00:00:00 2001 From: Peter Melnichenko Date: Fri, 14 Oct 2016 23:45:15 +0300 Subject: Relax Lua version detection to support Ravi Ravi has "Ravi 5.3" as _VERSION. Don't use _VERSION:sub(5) to get Lua version, match " (5%.[123])$" instead. --- configure | 4 ++-- install.bat | 2 +- src/luarocks/cfg.lua | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/configure b/configure index 665d52bc..3636aed3 100755 --- a/configure +++ b/configure @@ -226,8 +226,8 @@ then fi detect_lua_version() { - detected_lua=`$1 -e 'print(_VERSION:sub(5))' 2> /dev/null` - if [ "$detected_lua" = "5.1" -o "$detected_lua" = "5.2" -o "$detected_lua" = "5.3" ] + detected_lua=`$1 -e 'print(_VERSION:match(" (5%.[123])$"))' 2> /dev/null` + if [ "$detected_lua" != "nil" ] then echo "Lua version detected: $detected_lua" if [ "$LUA_VERSION_SET" != "yes" ] diff --git a/install.bat b/install.bat index cfa080e5..0a35a28a 100644 --- a/install.bat +++ b/install.bat @@ -262,7 +262,7 @@ local function detect_lua_version(interpreter_path) local full_version = handler:read("*a") handler:close() - local version = full_version:match("^Lua (5%.[123])$") + local version = full_version:match(" (5%.[123])$") if not version then return nil, "unknown interpreter version '" .. full_version .. "'" end diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua index bcb30342..33176161 100644 --- a/src/luarocks/cfg.lua +++ b/src/luarocks/cfg.lua @@ -18,7 +18,7 @@ package.loaded["luarocks.cfg"] = cfg local util = require("luarocks.util") -cfg.lua_version = _VERSION:sub(5) +cfg.lua_version = _VERSION:match(" (5%.[123])$") or "5.1" local version_suffix = cfg.lua_version:gsub("%.", "_") -- Load site-local global configurations -- cgit v1.2.3-55-g6feb