aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2013-08-19 19:44:49 -0300
committerHisham Muhammad <hisham@gobolinux.org>2013-08-19 19:44:49 -0300
commit0b8605f5d53a9fef54ca17bf5447132327b0ae6e (patch)
treeb37bdefaf2b853d81e2c221213ffac34a7d24919
parent951cb2be4b29b65f9675b126ede52cd285528eea (diff)
downloadluarocks-0b8605f5d53a9fef54ca17bf5447132327b0ae6e.tar.gz
luarocks-0b8605f5d53a9fef54ca17bf5447132327b0ae6e.tar.bz2
luarocks-0b8605f5d53a9fef54ca17bf5447132327b0ae6e.zip
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
-rw-r--r--src/luarocks/build.lua18
-rw-r--r--src/luarocks/build/builtin.lua14
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)
53 if files then 53 if files then
54 for k, file in pairs(files) do 54 for k, file in pairs(files) do
55 local dest = location 55 local dest = location
56 local filename = dir.base_name(file)
56 if type(k) == "string" then 57 if type(k) == "string" then
58 local modname = k
57 if is_module_path then 59 if is_module_path then
58 dest = dir.path(location, path.module_to_path(k)) 60 dest = dir.path(location, path.module_to_path(modname))
59 local ok, err = fs.make_dir(dest) 61 local ok, err = fs.make_dir(dest)
60 if not ok then return nil, err end 62 if not ok then return nil, err end
63 if filename:match("%.lua$") then
64 local basename = modname:match("([^.]+)$")
65 local baseinfo = filename:gsub("%.lua$", "")
66 if basename ~= baseinfo then
67 filename = basename..".lua"
68 end
69 end
61 else 70 else
62 dest = dir.path(location, dir.dir_name(k)) 71 dest = dir.path(location, dir.dir_name(modname))
63 local ok, err = fs.make_dir(dest) 72 local ok, err = fs.make_dir(dest)
64 if not ok then return nil, err end 73 if not ok then return nil, err end
65 dest = dir.path(dest, dir.base_name(k)) 74 filename = dir.base_name(modname)
66 end 75 end
67 else 76 else
68 local ok, err = fs.make_dir(dest) 77 local ok, err = fs.make_dir(dest)
69 if not ok then return nil, err end 78 if not ok then return nil, err end
70 end 79 end
71 local ok = fs.copy(dir.path(file), dest) 80print("COPYING ",dir.path(file), dir.path(dest, filename))
81 local ok = fs.copy(dir.path(file), dir.path(dest, filename))
72 if not ok then 82 if not ok then
73 return nil, "Failed copying "..file 83 return nil, "Failed copying "..file
74 end 84 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)
196 if type(info) == "string" then 196 if type(info) == "string" then
197 local ext = info:match(".([^.]+)$") 197 local ext = info:match(".([^.]+)$")
198 if ext == "lua" then 198 if ext == "lua" then
199 local filename = dir.base_name(info)
199 if info:match("init%.lua$") and not name:match("%.init$") then 200 if info:match("init%.lua$") and not name:match("%.init$") then
200 moddir = path.module_to_path(name..".init") 201 moddir = path.module_to_path(name..".init")
202 else
203 local basename = name:match("([^.]+)$")
204 local baseinfo = filename:gsub("%.lua$", "")
205 if basename ~= baseinfo then
206 filename = basename..".lua"
207 end
201 end 208 end
202 local dest = dir.path(luadir, moddir) 209 local dest = dir.path(luadir, moddir, filename)
203 built_modules[info] = dest 210 built_modules[info] = dest
204 else 211 else
205 info = {info} 212 info = {info}
@@ -227,8 +234,7 @@ function run(rockspec)
227 local ok, err = fs.make_dir(moddir) 234 local ok, err = fs.make_dir(moddir)
228 if not ok then return nil, err end 235 if not ok then return nil, err end
229 end 236 end
230 local dest = dir.path(libdir, moddir) 237 built_modules[module_name] = dir.path(libdir, moddir, module_name)
231 built_modules[module_name] = dest
232 ok = compile_library(module_name, objects, info.libraries, info.libdirs, name) 238 ok = compile_library(module_name, objects, info.libraries, info.libdirs, name)
233 if not ok then 239 if not ok then
234 return nil, "Failed compiling module "..module_name 240 return nil, "Failed compiling module "..module_name
@@ -236,7 +242,7 @@ function run(rockspec)
236 end 242 end
237 end 243 end
238 for name, dest in pairs(built_modules) do 244 for name, dest in pairs(built_modules) do
239 fs.make_dir(dest) 245 fs.make_dir(dir.dir_name(dest))
240 ok = fs.copy(name, dest) 246 ok = fs.copy(name, dest)
241 if not ok then 247 if not ok then
242 return nil, "Failed installing "..name.." in "..dest 248 return nil, "Failed installing "..name.." in "..dest