aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2014-05-03 17:18:44 -0300
committerHisham Muhammad <hisham@gobolinux.org>2014-05-03 17:18:44 -0300
commit9f1a6be6c3eb62d70d3788e20604d4b83560faed (patch)
treeaa4fdf988de05ed5085287921b041bfbffba59be
parent4396b504b7848081322cbaa9d5e26c9641a161b4 (diff)
parent17437fd52b648a6ad512c6e0587241c62b353f45 (diff)
downloadluarocks-9f1a6be6c3eb62d70d3788e20604d4b83560faed.tar.gz
luarocks-9f1a6be6c3eb62d70d3788e20604d4b83560faed.tar.bz2
luarocks-9f1a6be6c3eb62d70d3788e20604d4b83560faed.zip
Merge pull request #253 from Tieske/fix_path_order
corrects order of exported paths
-rw-r--r--src/luarocks/cfg.lua20
-rw-r--r--src/luarocks/path_cmd.lua30
2 files changed, 35 insertions, 15 deletions
diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua
index c7ca4441..693cdbdb 100644
--- a/src/luarocks/cfg.lua
+++ b/src/luarocks/cfg.lua
@@ -524,18 +524,24 @@ local cfg_mt = {
524setmetatable(cfg, cfg_mt) 524setmetatable(cfg, cfg_mt)
525 525
526function cfg.package_paths() 526function cfg.package_paths()
527 local new_path, new_cpath = { extra_luarocks_module_dir }, {} 527 local new_path, new_cpath, new_bin = {}, {}, {}
528 for _,tree in ipairs(cfg.rocks_trees) do 528 for _,tree in ipairs(cfg.rocks_trees) do
529 if type(tree) == "string" then 529 if type(tree) == "string" then
530 table.insert(new_path, 1, tree..cfg.lua_modules_path.."/?.lua;"..tree..cfg.lua_modules_path.."/?/init.lua") 530 table.insert(new_path, tree..cfg.lua_modules_path.."/?.lua")
531 table.insert(new_cpath, 1, tree..cfg.lib_modules_path.."/?."..cfg.lib_extension) 531 table.insert(new_path, tree..cfg.lua_modules_path.."/?/init.lua")
532 table.insert(new_cpath, tree..cfg.lib_modules_path.."/?."..cfg.lib_extension)
533 table.insert(new_bin, tree.."/bin")
532 else 534 else
533 table.insert(new_path, 1, (tree.lua_dir or tree.root..cfg.lua_modules_path).."/?.lua;".. 535 table.insert(new_path, (tree.lua_dir or tree.root..cfg.lua_modules_path).."/?.lua")
534 (tree.lua_dir or tree.root..cfg.lua_modules_path).."/?/init.lua") 536 table.insert(new_path, (tree.lua_dir or tree.root..cfg.lua_modules_path).."/?/init.lua")
535 table.insert(new_cpath, 1, (tree.lib_dir or tree.root..cfg.lib_modules_path).."/?."..cfg.lib_extension) 537 table.insert(new_cpath, (tree.lib_dir or tree.root..cfg.lib_modules_path).."/?."..cfg.lib_extension)
538 table.insert(new_bin, (tree.bin_dir or tree.root.."/bin"))
536 end 539 end
537 end 540 end
538 return table.concat(new_path, ";"), table.concat(new_cpath, ";") 541 if extra_luarocks_module_dir then
542 table.insert(new_path, extra_luarocks_module_dir)
543 end
544 return table.concat(new_path, ";"), table.concat(new_cpath, ";"), table.concat(new_bin, ";")
539end 545end
540 546
541function cfg.which_config() 547function 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."
12path_cmd.help_arguments = "" 12path_cmd.help_arguments = ""
13path_cmd.help = [[ 13path_cmd.help = [[
14Returns the package path currently configured for this installation 14Returns the package path currently configured for this installation
15of LuaRocks, formatted as shell commands to update LUA_PATH and 15of LuaRocks, formatted as shell commands to update LUA_PATH and LUA_CPATH.
16LUA_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
29On Unix systems, you may run:
30 eval `luarocks path`
31And 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
56end 70end