aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2018-01-05 15:38:37 -0200
committerHisham Muhammad <hisham@gobolinux.org>2018-01-05 15:38:37 -0200
commit98a0bd9a97190be8ba10f14a3d67e42de827b04a (patch)
tree079b71a6416b62a5d9ab61a5a4f47e340d353831 /src
parent291c34696daa496d4ceb1e58b282fa935d90a3f5 (diff)
downloadluarocks-98a0bd9a97190be8ba10f14a3d67e42de827b04a.tar.gz
luarocks-98a0bd9a97190be8ba10f14a3d67e42de827b04a.tar.bz2
luarocks-98a0bd9a97190be8ba10f14a3d67e42de827b04a.zip
path: use versioned LUA_xPATH_5_x variables
`luarocks path` now exports versioned variables `LUA_PATH_5_x` and `LUA_CPATH_5_x` instead of `LUA_PATH` and `LUA_CPATH` when those are in use in your system. Fixes #760.
Diffstat (limited to 'src')
-rw-r--r--src/luarocks/cmd/path.lua20
-rw-r--r--src/luarocks/core/cfg.lua6
-rw-r--r--src/luarocks/fs/unix.lua4
-rw-r--r--src/luarocks/fs/win32.lua4
4 files changed, 25 insertions, 9 deletions
diff --git a/src/luarocks/cmd/path.lua b/src/luarocks/cmd/path.lua
index 3cf43091..9bcd1c81 100644
--- a/src/luarocks/cmd/path.lua
+++ b/src/luarocks/cmd/path.lua
@@ -5,6 +5,7 @@ local path_cmd = {}
5 5
6local util = require("luarocks.util") 6local util = require("luarocks.util")
7local cfg = require("luarocks.core.cfg") 7local cfg = require("luarocks.core.cfg")
8local fs = require("luarocks.fs")
8 9
9path_cmd.help_summary = "Return the currently configured package path." 10path_cmd.help_summary = "Return the currently configured package path."
10path_cmd.help_arguments = "" 11path_cmd.help_arguments = ""
@@ -56,11 +57,24 @@ function path_cmd.command(flags)
56 lr_cpath = lr_cpath .. ";" .. package.cpath 57 lr_cpath = lr_cpath .. ";" .. package.cpath
57 lr_bin = lr_bin .. path_sep .. os.getenv("PATH") 58 lr_bin = lr_bin .. path_sep .. os.getenv("PATH")
58 end 59 end
60
61 local lpath_var = "LUA_PATH"
62 local lcpath_var = "LUA_CPATH"
63
64 local lv = cfg.lua_version:gsub("%.", "_")
65 if lv ~= "5_1" then
66 if os.getenv("LUA_PATH_" .. lv) then
67 lpath_var = "LUA_PATH_" .. lv
68 end
69 if os.getenv("LUA_CPATH_" .. lv) then
70 lcpath_var = "LUA_CPATH_" .. lv
71 end
72 end
59 73
60 util.printout(cfg.export_lua_path:format(util.cleanup_path(lr_path, ';', cfg.lua_version))) 74 util.printout(fs.export_cmd(lpath_var, util.cleanup_path(lr_path, ';', cfg.lua_version)))
61 util.printout(cfg.export_lua_cpath:format(util.cleanup_path(lr_cpath, ';', cfg.lua_version))) 75 util.printout(fs.export_cmd(lcpath_var, util.cleanup_path(lr_cpath, ';', cfg.lua_version)))
62 if flags["bin"] then 76 if flags["bin"] then
63 util.printout(cfg.export_path:format(util.cleanup_path(lr_bin, path_sep))) 77 util.printout(fs.export_cmd("PATH", util.cleanup_path(lr_bin, path_sep)))
64 end 78 end
65 return true 79 return true
66end 80end
diff --git a/src/luarocks/core/cfg.lua b/src/luarocks/core/cfg.lua
index e6351add..3326375f 100644
--- a/src/luarocks/core/cfg.lua
+++ b/src/luarocks/core/cfg.lua
@@ -473,10 +473,7 @@ if cfg.platforms.windows then
473 lib = { "?.dll", "lib?.dll" }, 473 lib = { "?.dll", "lib?.dll" },
474 include = { "?.h" } 474 include = { "?.h" }
475 } 475 }
476 defaults.export_path = "SET PATH=%s"
477 defaults.export_path_separator = ";" 476 defaults.export_path_separator = ";"
478 defaults.export_lua_path = "SET LUA_PATH=%s"
479 defaults.export_lua_cpath = "SET LUA_CPATH=%s"
480 defaults.wrapper_suffix = ".bat" 477 defaults.wrapper_suffix = ".bat"
481 478
482 local localappdata = os.getenv("LOCALAPPDATA") 479 local localappdata = os.getenv("LOCALAPPDATA")
@@ -541,10 +538,7 @@ if cfg.platforms.unix then
541 lib = { "lib?.so", "lib?.so.*" }, 538 lib = { "lib?.so", "lib?.so.*" },
542 include = { "?.h" } 539 include = { "?.h" }
543 } 540 }
544 defaults.export_path = "export PATH='%s'"
545 defaults.export_path_separator = ":" 541 defaults.export_path_separator = ":"
546 defaults.export_lua_path = "export LUA_PATH='%s'"
547 defaults.export_lua_cpath = "export LUA_CPATH='%s'"
548 defaults.wrapper_suffix = "" 542 defaults.wrapper_suffix = ""
549 defaults.local_cache = cfg.home.."/.cache/luarocks" 543 defaults.local_cache = cfg.home.."/.cache/luarocks"
550 if not defaults.variables.CFLAGS:match("-fPIC") then 544 if not defaults.variables.CFLAGS:match("-fPIC") then
diff --git a/src/luarocks/fs/unix.lua b/src/luarocks/fs/unix.lua
index 52634246..c99e1566 100644
--- a/src/luarocks/fs/unix.lua
+++ b/src/luarocks/fs/unix.lua
@@ -136,4 +136,8 @@ function unix.current_user()
136 return os.getenv("USER") 136 return os.getenv("USER")
137end 137end
138 138
139function unix.export_cmd(var, val)
140 return ("export %s='%s'"):format(var, val)
141end
142
139return unix 143return unix
diff --git a/src/luarocks/fs/win32.lua b/src/luarocks/fs/win32.lua
index 92068e39..6fd24fa5 100644
--- a/src/luarocks/fs/win32.lua
+++ b/src/luarocks/fs/win32.lua
@@ -272,4 +272,8 @@ function win32.current_user()
272 return os.getenv("USERNAME") 272 return os.getenv("USERNAME")
273end 273end
274 274
275function win32.export_cmd(var, val)
276 return ("SET %s=%s"):format(var, val)
277end
278
275return win32 279return win32