From 0b8605f5d53a9fef54ca17bf5447132327b0ae6e Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Mon, 19 Aug 2013 19:44:49 -0300 Subject: Make behavior more intuitive when the key in a modules or build.install.lua section asks to rename a module. I personally think it's a bad practice, but the syntax implies this is possible and the previous behavior is surely worse than the new one. See http://stackoverflow.com/questions/18314068/does-luarocks-rockspec-use-only-file-names-for-module-sub-names --- src/luarocks/build.lua | 18 ++++++++++++++---- src/luarocks/build/builtin.lua | 14 ++++++++++---- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/luarocks/build.lua b/src/luarocks/build.lua index 7bd54a0c..4f089cff 100644 --- a/src/luarocks/build.lua +++ b/src/luarocks/build.lua @@ -53,22 +53,32 @@ local function install_files(files, location, is_module_path) if files then for k, file in pairs(files) do local dest = location + local filename = dir.base_name(file) if type(k) == "string" then + local modname = k if is_module_path then - dest = dir.path(location, path.module_to_path(k)) + dest = dir.path(location, path.module_to_path(modname)) local ok, err = fs.make_dir(dest) if not ok then return nil, err end + if filename:match("%.lua$") then + local basename = modname:match("([^.]+)$") + local baseinfo = filename:gsub("%.lua$", "") + if basename ~= baseinfo then + filename = basename..".lua" + end + end else - dest = dir.path(location, dir.dir_name(k)) + dest = dir.path(location, dir.dir_name(modname)) local ok, err = fs.make_dir(dest) if not ok then return nil, err end - dest = dir.path(dest, dir.base_name(k)) + filename = dir.base_name(modname) end else local ok, err = fs.make_dir(dest) if not ok then return nil, err end end - local ok = fs.copy(dir.path(file), dest) +print("COPYING ",dir.path(file), dir.path(dest, filename)) + local ok = fs.copy(dir.path(file), dir.path(dest, filename)) if not ok then return nil, "Failed copying "..file end diff --git a/src/luarocks/build/builtin.lua b/src/luarocks/build/builtin.lua index c96a2496..3bace7c4 100644 --- a/src/luarocks/build/builtin.lua +++ b/src/luarocks/build/builtin.lua @@ -196,10 +196,17 @@ function run(rockspec) if type(info) == "string" then local ext = info:match(".([^.]+)$") if ext == "lua" then + local filename = dir.base_name(info) if info:match("init%.lua$") and not name:match("%.init$") then moddir = path.module_to_path(name..".init") + else + local basename = name:match("([^.]+)$") + local baseinfo = filename:gsub("%.lua$", "") + if basename ~= baseinfo then + filename = basename..".lua" + end end - local dest = dir.path(luadir, moddir) + local dest = dir.path(luadir, moddir, filename) built_modules[info] = dest else info = {info} @@ -227,8 +234,7 @@ function run(rockspec) local ok, err = fs.make_dir(moddir) if not ok then return nil, err end end - local dest = dir.path(libdir, moddir) - built_modules[module_name] = dest + built_modules[module_name] = dir.path(libdir, moddir, module_name) ok = compile_library(module_name, objects, info.libraries, info.libdirs, name) if not ok then return nil, "Failed compiling module "..module_name @@ -236,7 +242,7 @@ function run(rockspec) end end for name, dest in pairs(built_modules) do - fs.make_dir(dest) + fs.make_dir(dir.dir_name(dest)) ok = fs.copy(name, dest) if not ok then return nil, "Failed installing "..name.." in "..dest -- cgit v1.2.3-55-g6feb