aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2013-06-26 17:33:50 -0300
committerHisham Muhammad <hisham@gobolinux.org>2013-06-26 17:33:50 -0300
commite494bbe5b91bd2ba5c7e1f231ff1d6f58cf6ccdb (patch)
tree9d1d04b748076f1bcc6caf9471f4213ffe6752cd
parent6dfda90a9a9f503eb38207cf1451ef3557608ddd (diff)
downloadluarocks-e494bbe5b91bd2ba5c7e1f231ff1d6f58cf6ccdb.tar.gz
luarocks-e494bbe5b91bd2ba5c7e1f231ff1d6f58cf6ccdb.tar.bz2
luarocks-e494bbe5b91bd2ba5c7e1f231ff1d6f58cf6ccdb.zip
Add flags --lr-path, --lr-cpath, --lr-bin to `luarocks path`, for convenience in scripts.
-rw-r--r--src/luarocks/cfg.lua28
-rw-r--r--src/luarocks/path.lua19
2 files changed, 36 insertions, 11 deletions
diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua
index 259293c3..967d756c 100644
--- a/src/luarocks/cfg.lua
+++ b/src/luarocks/cfg.lua
@@ -443,15 +443,25 @@ local cfg_mt = {
443} 443}
444setmetatable(_M, cfg_mt) 444setmetatable(_M, cfg_mt)
445 445
446for _,tree in ipairs(rocks_trees) do 446function package_paths()
447 if type(tree) == "string" then 447 local new_path, new_cpath = {}, {}
448 package.path = tree..lua_modules_path.."/?.lua;"..tree..lua_modules_path.."/?/init.lua;"..package.path 448 for _,tree in ipairs(rocks_trees) do
449 package.cpath = tree..lib_modules_path.."/?."..lib_extension..";"..package.cpath 449 if type(tree) == "string" then
450 else 450 table.insert(new_path, 1, tree..lua_modules_path.."/?.lua;"..tree..lua_modules_path.."/?/init.lua")
451 package.path = (tree.lua_dir or tree.root..lua_modules_path).."/?.lua;".. 451 table.insert(new_cpath, 1, tree..lib_modules_path.."/?."..lib_extension)
452 (tree.lua_dir or tree.root..lua_modules_path).."/?/init.lua;"..package.path 452 else
453 package.cpath = (tree.lib_dir or tree.root..lib_modules_path).."/?."..lib_extension..";"..package.cpath 453 table.insert(new_path, 1, (tree.lua_dir or tree.root..lua_modules_path).."/?.lua;"..
454 end 454 (tree.lua_dir or tree.root..lua_modules_path).."/?/init.lua")
455 table.insert(new_cpath, 1, (tree.lib_dir or tree.root..lib_modules_path).."/?."..lib_extension)
456 end
457 end
458 return table.concat(new_path, ";"), table.concat(new_cpath, ";")
459end
460
461do
462 local new_path, new_cpath = package_paths()
463 package.path = new_path..";"..package.path
464 package.cpath = new_cpath..";"..package.cpath
455end 465end
456 466
457function which_config() 467function which_config()
diff --git a/src/luarocks/path.lua b/src/luarocks/path.lua
index cfe06118..7af81c07 100644
--- a/src/luarocks/path.lua
+++ b/src/luarocks/path.lua
@@ -389,13 +389,28 @@ end
389function run(...) 389function run(...)
390 local flags = util.parse_flags(...) 390 local flags = util.parse_flags(...)
391 local deps_mode = deps.get_deps_mode(flags) 391 local deps_mode = deps.get_deps_mode(flags)
392
393 local lr_path, lr_cpath = cfg.package_paths()
394 local bin_dirs = map_trees(deps_mode, deploy_bin_dir)
395
396 if flags["lr-path"] then
397 util.printout(util.remove_path_dupes(lr_path, ';'))
398 return true
399 elseif flags["lr-cpath"] then
400 util.printout(util.remove_path_dupes(lr_cpath, ';'))
401 return true
402 elseif flags["lr-bin"] then
403 local lr_bin = util.remove_path_dupes(table.concat(bin_dirs, cfg.export_path_separator), cfg.export_path_separator)
404 util.printout(util.remove_path_dupes(lr_bin, ';'))
405 return true
406 end
392 407
393 util.printout(cfg.export_lua_path:format(util.remove_path_dupes(package.path, ';'))) 408 util.printout(cfg.export_lua_path:format(util.remove_path_dupes(package.path, ';')))
394 util.printout(cfg.export_lua_cpath:format(util.remove_path_dupes(package.cpath, ';'))) 409 util.printout(cfg.export_lua_cpath:format(util.remove_path_dupes(package.cpath, ';')))
395 if flags["bin"] then 410 if flags["bin"] then
396 local bin_dirs = map_trees(deps_mode, deploy_bin_dir)
397 table.insert(bin_dirs, 1, os.getenv("PATH")) 411 table.insert(bin_dirs, 1, os.getenv("PATH"))
398 util.printout(cfg.export_path:format(util.remove_path_dupes(table.concat(bin_dirs, cfg.export_path_separator), cfg.export_path_separator))) 412 local lr_bin = util.remove_path_dupes(table.concat(bin_dirs, cfg.export_path_separator), cfg.export_path_separator)
413 util.printout(cfg.export_path:format(lr_bin))
399 end 414 end
400 return true 415 return true
401end 416end