diff options
author | Sewbacca <sewbacca@kolabnow.com> | 2024-02-16 18:50:33 +0100 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2024-02-16 19:34:02 -0300 |
commit | c0fe94c4a6f8c82e6d85a3700bab0e74e4244c4d (patch) | |
tree | fd6a01b60e5cef2465e0818ea75dc644e36eaa5a | |
parent | ea43975308abc8b5281ac8934657aa4d59bcdd75 (diff) | |
download | luarocks-c0fe94c4a6f8c82e6d85a3700bab0e74e4244c4d.tar.gz luarocks-c0fe94c4a6f8c82e6d85a3700bab0e74e4244c4d.tar.bz2 luarocks-c0fe94c4a6f8c82e6d85a3700bab0e74e4244c4d.zip |
fix: `build.install_command` doesn't execute on windows
-rw-r--r-- | src/luarocks/fs/lua.lua | 12 | ||||
-rw-r--r-- | src/luarocks/fs/win32.lua | 10 |
2 files changed, 16 insertions, 6 deletions
diff --git a/src/luarocks/fs/lua.lua b/src/luarocks/fs/lua.lua index ec497f88..0805efd2 100644 --- a/src/luarocks/fs/lua.lua +++ b/src/luarocks/fs/lua.lua | |||
@@ -54,7 +54,7 @@ function fs_lua.is_writable(file) | |||
54 | return result | 54 | return result |
55 | end | 55 | end |
56 | 56 | ||
57 | local function quote_args(command, ...) | 57 | function fs_lua.quote_args(command, ...) |
58 | local out = { command } | 58 | local out = { command } |
59 | local args = pack(...) | 59 | local args = pack(...) |
60 | for i=1, args.n do | 60 | for i=1, args.n do |
@@ -74,7 +74,7 @@ end | |||
74 | -- otherwise. | 74 | -- otherwise. |
75 | function fs_lua.execute(command, ...) | 75 | function fs_lua.execute(command, ...) |
76 | assert(type(command) == "string") | 76 | assert(type(command) == "string") |
77 | return fs.execute_string(quote_args(command, ...)) | 77 | return fs.execute_string(fs.quote_args(command, ...)) |
78 | end | 78 | end |
79 | 79 | ||
80 | --- Run the given command, quoting its arguments, silencing its output. | 80 | --- Run the given command, quoting its arguments, silencing its output. |
@@ -88,19 +88,19 @@ end | |||
88 | function fs_lua.execute_quiet(command, ...) | 88 | function fs_lua.execute_quiet(command, ...) |
89 | assert(type(command) == "string") | 89 | assert(type(command) == "string") |
90 | if cfg.verbose then -- omit silencing output | 90 | if cfg.verbose then -- omit silencing output |
91 | return fs.execute_string(quote_args(command, ...)) | 91 | return fs.execute_string(fs.quote_args(command, ...)) |
92 | else | 92 | else |
93 | return fs.execute_string(fs.quiet(quote_args(command, ...))) | 93 | return fs.execute_string(fs.quiet(fs.quote_args(command, ...))) |
94 | end | 94 | end |
95 | end | 95 | end |
96 | 96 | ||
97 | function fs.execute_env(env, command, ...) | 97 | function fs_lua.execute_env(env, command, ...) |
98 | assert(type(command) == "string") | 98 | assert(type(command) == "string") |
99 | local envstr = {} | 99 | local envstr = {} |
100 | for var, val in pairs(env) do | 100 | for var, val in pairs(env) do |
101 | table.insert(envstr, fs.export_cmd(var, val)) | 101 | table.insert(envstr, fs.export_cmd(var, val)) |
102 | end | 102 | end |
103 | return fs.execute_string(table.concat(envstr, "\n") .. "\n" .. quote_args(command, ...)) | 103 | return fs.execute_string(table.concat(envstr, "\n") .. "\n" .. fs.quote_args(command, ...)) |
104 | end | 104 | end |
105 | 105 | ||
106 | local tool_available_cache = {} | 106 | local tool_available_cache = {} |
diff --git a/src/luarocks/fs/win32.lua b/src/luarocks/fs/win32.lua index 6c49f447..1a35c3d4 100644 --- a/src/luarocks/fs/win32.lua +++ b/src/luarocks/fs/win32.lua | |||
@@ -35,6 +35,16 @@ function win32.quiet_stderr(cmd) | |||
35 | return cmd.." 2> NUL" | 35 | return cmd.." 2> NUL" |
36 | end | 36 | end |
37 | 37 | ||
38 | function win32.execute_env(env, command, ...) | ||
39 | assert(type(command) == "string") | ||
40 | local cmdstr = {} | ||
41 | for var, val in pairs(env) do | ||
42 | table.insert(cmdstr, fs.export_cmd(var, val)) | ||
43 | end | ||
44 | table.insert(cmdstr, fs.quote_args(command, ...)) | ||
45 | return fs.execute_string(table.concat(cmdstr, " & ")) | ||
46 | end | ||
47 | |||
38 | -- Split path into drive, root and the rest. | 48 | -- Split path into drive, root and the rest. |
39 | -- Example: "c:\\hello\\world" becomes "c:" "\\" "hello\\world" | 49 | -- Example: "c:\\hello\\world" becomes "c:" "\\" "hello\\world" |
40 | -- if any part is missing from input, it becomes an empty string. | 50 | -- if any part is missing from input, it becomes an empty string. |