diff options
| author | Hisham Muhammad <hisham@gobolinux.org> | 2013-06-26 17:33:50 -0300 |
|---|---|---|
| committer | Hisham Muhammad <hisham@gobolinux.org> | 2013-06-26 17:33:50 -0300 |
| commit | e494bbe5b91bd2ba5c7e1f231ff1d6f58cf6ccdb (patch) | |
| tree | 9d1d04b748076f1bcc6caf9471f4213ffe6752cd /src | |
| parent | 6dfda90a9a9f503eb38207cf1451ef3557608ddd (diff) | |
| download | luarocks-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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/luarocks/cfg.lua | 28 | ||||
| -rw-r--r-- | src/luarocks/path.lua | 19 |
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 | } |
| 444 | setmetatable(_M, cfg_mt) | 444 | setmetatable(_M, cfg_mt) |
| 445 | 445 | ||
| 446 | for _,tree in ipairs(rocks_trees) do | 446 | function 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, ";") | ||
| 459 | end | ||
| 460 | |||
| 461 | do | ||
| 462 | local new_path, new_cpath = package_paths() | ||
| 463 | package.path = new_path..";"..package.path | ||
| 464 | package.cpath = new_cpath..";"..package.cpath | ||
| 455 | end | 465 | end |
| 456 | 466 | ||
| 457 | function which_config() | 467 | function 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 | |||
| 389 | function run(...) | 389 | function 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 |
| 401 | end | 416 | end |
