diff options
author | Thijs Schreijer <thijs@thijsschreijer.nl> | 2014-05-01 22:20:28 +0200 |
---|---|---|
committer | Thijs Schreijer <thijs@thijsschreijer.nl> | 2014-05-01 22:20:28 +0200 |
commit | 17437fd52b648a6ad512c6e0587241c62b353f45 (patch) | |
tree | 789173b6910abe57df9725ba8755e1a37f34716b /src | |
parent | 999e27d74abd0bc53165d2ce2642fb5a7af81f40 (diff) | |
download | luarocks-17437fd52b648a6ad512c6e0587241c62b353f45.tar.gz luarocks-17437fd52b648a6ad512c6e0587241c62b353f45.tar.bz2 luarocks-17437fd52b648a6ad512c6e0587241c62b353f45.zip |
fixes #251
- order of path; user vs system tree corrected.
- bin directories of all trees included, instead of current tree
Diffstat (limited to 'src')
-rw-r--r-- | src/luarocks/cfg.lua | 20 | ||||
-rw-r--r-- | src/luarocks/path_cmd.lua | 30 |
2 files changed, 35 insertions, 15 deletions
diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua index 1207d600..97b6a09e 100644 --- a/src/luarocks/cfg.lua +++ b/src/luarocks/cfg.lua | |||
@@ -523,18 +523,24 @@ local cfg_mt = { | |||
523 | setmetatable(cfg, cfg_mt) | 523 | setmetatable(cfg, cfg_mt) |
524 | 524 | ||
525 | function cfg.package_paths() | 525 | function cfg.package_paths() |
526 | local new_path, new_cpath = { extra_luarocks_module_dir }, {} | 526 | local new_path, new_cpath, new_bin = {}, {}, {} |
527 | for _,tree in ipairs(cfg.rocks_trees) do | 527 | for _,tree in ipairs(cfg.rocks_trees) do |
528 | if type(tree) == "string" then | 528 | if type(tree) == "string" then |
529 | table.insert(new_path, 1, tree..cfg.lua_modules_path.."/?.lua;"..tree..cfg.lua_modules_path.."/?/init.lua") | 529 | table.insert(new_path, tree..cfg.lua_modules_path.."/?.lua") |
530 | table.insert(new_cpath, 1, tree..cfg.lib_modules_path.."/?."..cfg.lib_extension) | 530 | table.insert(new_path, tree..cfg.lua_modules_path.."/?/init.lua") |
531 | table.insert(new_cpath, tree..cfg.lib_modules_path.."/?."..cfg.lib_extension) | ||
532 | table.insert(new_bin, tree.."/bin") | ||
531 | else | 533 | else |
532 | table.insert(new_path, 1, (tree.lua_dir or tree.root..cfg.lua_modules_path).."/?.lua;".. | 534 | table.insert(new_path, (tree.lua_dir or tree.root..cfg.lua_modules_path).."/?.lua") |
533 | (tree.lua_dir or tree.root..cfg.lua_modules_path).."/?/init.lua") | 535 | table.insert(new_path, (tree.lua_dir or tree.root..cfg.lua_modules_path).."/?/init.lua") |
534 | table.insert(new_cpath, 1, (tree.lib_dir or tree.root..cfg.lib_modules_path).."/?."..cfg.lib_extension) | 536 | table.insert(new_cpath, (tree.lib_dir or tree.root..cfg.lib_modules_path).."/?."..cfg.lib_extension) |
537 | table.insert(new_bin, (tree.bin_dir or tree.root.."/bin")) | ||
535 | end | 538 | end |
536 | end | 539 | end |
537 | return table.concat(new_path, ";"), table.concat(new_cpath, ";") | 540 | if extra_luarocks_module_dir then |
541 | table.insert(new_path, extra_luarocks_module_dir) | ||
542 | end | ||
543 | return table.concat(new_path, ";"), table.concat(new_cpath, ";"), table.concat(new_bin, ";") | ||
538 | end | 544 | end |
539 | 545 | ||
540 | function cfg.which_config() | 546 | function cfg.which_config() |
diff --git a/src/luarocks/path_cmd.lua b/src/luarocks/path_cmd.lua index d52f985a..4aeba41c 100644 --- a/src/luarocks/path_cmd.lua +++ b/src/luarocks/path_cmd.lua | |||
@@ -12,8 +12,24 @@ path_cmd.help_summary = "Return the currently configured package path." | |||
12 | path_cmd.help_arguments = "" | 12 | path_cmd.help_arguments = "" |
13 | path_cmd.help = [[ | 13 | path_cmd.help = [[ |
14 | Returns the package path currently configured for this installation | 14 | Returns the package path currently configured for this installation |
15 | of LuaRocks, formatted as shell commands to update LUA_PATH and | 15 | of LuaRocks, formatted as shell commands to update LUA_PATH and LUA_CPATH. |
16 | LUA_CPATH. (On Unix systems, you may run: eval `luarocks path`) | 16 | |
17 | --bin Adds the system path to the output | ||
18 | |||
19 | --append Appends the paths to the existing paths. Default is to prefix | ||
20 | the LR paths to the existing paths. | ||
21 | |||
22 | --lr-path Exports the Lua path (not formatted as shell command) | ||
23 | |||
24 | --lr-cpath Exports the Lua cpath (not formatted as shell command) | ||
25 | |||
26 | --lr-bin Exports the system path (not formatted as shell command) | ||
27 | |||
28 | |||
29 | On Unix systems, you may run: | ||
30 | eval `luarocks path` | ||
31 | And on Windows: | ||
32 | luarocks path > "%temp%\_lrp.bat" && call "%temp%\_lrp.bat" && del "%temp%\_lrp.bat" | ||
17 | ]] | 33 | ]] |
18 | 34 | ||
19 | --- Driver function for "path" command. | 35 | --- Driver function for "path" command. |
@@ -22,8 +38,7 @@ function path_cmd.run(...) | |||
22 | local flags = util.parse_flags(...) | 38 | local flags = util.parse_flags(...) |
23 | local deps_mode = deps.get_deps_mode(flags) | 39 | local deps_mode = deps.get_deps_mode(flags) |
24 | 40 | ||
25 | local lr_path, lr_cpath = cfg.package_paths() | 41 | local lr_path, lr_cpath, lr_bin = cfg.package_paths() |
26 | local bin_dirs = path.map_trees(deps_mode, path.deploy_bin_dir) | ||
27 | 42 | ||
28 | if flags["lr-path"] then | 43 | if flags["lr-path"] then |
29 | util.printout(util.remove_path_dupes(lr_path, ';')) | 44 | util.printout(util.remove_path_dupes(lr_path, ';')) |
@@ -32,7 +47,6 @@ function path_cmd.run(...) | |||
32 | util.printout(util.remove_path_dupes(lr_cpath, ';')) | 47 | util.printout(util.remove_path_dupes(lr_cpath, ';')) |
33 | return true | 48 | return true |
34 | elseif flags["lr-bin"] then | 49 | elseif flags["lr-bin"] then |
35 | local lr_bin = util.remove_path_dupes(table.concat(bin_dirs, cfg.export_path_separator), cfg.export_path_separator) | ||
36 | util.printout(util.remove_path_dupes(lr_bin, ';')) | 50 | util.printout(util.remove_path_dupes(lr_bin, ';')) |
37 | return true | 51 | return true |
38 | end | 52 | end |
@@ -40,17 +54,17 @@ function path_cmd.run(...) | |||
40 | if flags["append"] then | 54 | if flags["append"] then |
41 | lr_path = package.path .. ";" .. lr_path | 55 | lr_path = package.path .. ";" .. lr_path |
42 | lr_cpath = package.cpath .. ";" .. lr_cpath | 56 | lr_cpath = package.cpath .. ";" .. lr_cpath |
57 | lr_bin = os.getenv("PATH") .. ";" .. lr_bin | ||
43 | else | 58 | else |
44 | lr_path = lr_path.. ";" .. package.path | 59 | lr_path = lr_path.. ";" .. package.path |
45 | lr_cpath = lr_cpath .. ";" .. package.cpath | 60 | lr_cpath = lr_cpath .. ";" .. package.cpath |
61 | lr_bin = lr_bin .. ";" .. os.getenv("PATH") | ||
46 | end | 62 | end |
47 | 63 | ||
48 | util.printout(cfg.export_lua_path:format(util.remove_path_dupes(lr_path, ';'))) | 64 | util.printout(cfg.export_lua_path:format(util.remove_path_dupes(lr_path, ';'))) |
49 | util.printout(cfg.export_lua_cpath:format(util.remove_path_dupes(lr_cpath, ';'))) | 65 | util.printout(cfg.export_lua_cpath:format(util.remove_path_dupes(lr_cpath, ';'))) |
50 | if flags["bin"] then | 66 | if flags["bin"] then |
51 | table.insert(bin_dirs, 1, os.getenv("PATH")) | 67 | util.printout(cfg.export_path:format(util.remove_path_dupes(lr_bin,';'))) |
52 | local lr_bin = util.remove_path_dupes(table.concat(bin_dirs, cfg.export_path_separator), cfg.export_path_separator) | ||
53 | util.printout(cfg.export_path:format(lr_bin)) | ||
54 | end | 68 | end |
55 | return true | 69 | return true |
56 | end | 70 | end |