diff options
| author | Hisham Muhammad <hisham@gobolinux.org> | 2020-04-13 20:00:57 -0300 |
|---|---|---|
| committer | Hisham Muhammad <hisham@gobolinux.org> | 2020-04-13 20:00:57 -0300 |
| commit | b86f0d72c891bc38a2cff021ae656e4fc8fce7a8 (patch) | |
| tree | 19b5ba33bdec160afa8c692aeb383b4588994ca4 /src | |
| parent | 852e290f50b35d56be0d8dfaa9f8092cbf37ee36 (diff) | |
| download | luarocks-b86f0d72c891bc38a2cff021ae656e4fc8fce7a8.tar.gz luarocks-b86f0d72c891bc38a2cff021ae656e4fc8fce7a8.tar.bz2 luarocks-b86f0d72c891bc38a2cff021ae656e4fc8fce7a8.zip | |
do not call Lua interpreter when making wrapper for luarocks binary
Closes #1174.
Diffstat (limited to 'src')
| -rw-r--r-- | src/luarocks/core/cfg.lua | 4 | ||||
| -rw-r--r-- | src/luarocks/fs/unix.lua | 11 | ||||
| -rw-r--r-- | src/luarocks/fs/win32.lua | 11 |
3 files changed, 26 insertions, 0 deletions
diff --git a/src/luarocks/core/cfg.lua b/src/luarocks/core/cfg.lua index b3561422..48aff4d8 100644 --- a/src/luarocks/core/cfg.lua +++ b/src/luarocks/core/cfg.lua | |||
| @@ -542,6 +542,10 @@ function cfg.init(detected, warning) | |||
| 542 | cfg.program_series = program_series | 542 | cfg.program_series = program_series |
| 543 | cfg.major_version = major_version | 543 | cfg.major_version = major_version |
| 544 | 544 | ||
| 545 | if hardcoded.IS_BINARY then | ||
| 546 | cfg.is_binary = true | ||
| 547 | end | ||
| 548 | |||
| 545 | -- Use detected values as defaults, overridable via config files or CLI args | 549 | -- Use detected values as defaults, overridable via config files or CLI args |
| 546 | 550 | ||
| 547 | cfg.lua_version = detected.lua_version or hardcoded.LUA_VERSION or _VERSION:sub(5) | 551 | cfg.lua_version = detected.lua_version or hardcoded.LUA_VERSION or _VERSION:sub(5) |
diff --git a/src/luarocks/fs/unix.lua b/src/luarocks/fs/unix.lua index d62a93ca..53903f0c 100644 --- a/src/luarocks/fs/unix.lua +++ b/src/luarocks/fs/unix.lua | |||
| @@ -88,12 +88,18 @@ function unix.wrap_script(script, target, deps_mode, name, version, ...) | |||
| 88 | "package.path="..util.LQ(lpath..";").."..package.path", | 88 | "package.path="..util.LQ(lpath..";").."..package.path", |
| 89 | "package.cpath="..util.LQ(lcpath..";").."..package.cpath", | 89 | "package.cpath="..util.LQ(lcpath..";").."..package.cpath", |
| 90 | } | 90 | } |
| 91 | |||
| 92 | local remove_interpreter = false | ||
| 91 | if target == "luarocks" or target == "luarocks-admin" then | 93 | if target == "luarocks" or target == "luarocks-admin" then |
| 94 | if cfg.is_binary then | ||
| 95 | remove_interpreter = true | ||
| 96 | end | ||
| 92 | luainit = { | 97 | luainit = { |
| 93 | "package.path="..util.LQ(package.path), | 98 | "package.path="..util.LQ(package.path), |
| 94 | "package.cpath="..util.LQ(package.cpath), | 99 | "package.cpath="..util.LQ(package.cpath), |
| 95 | } | 100 | } |
| 96 | end | 101 | end |
| 102 | |||
| 97 | if name and version then | 103 | if name and version then |
| 98 | local addctx = "local k,l,_=pcall(require,"..util.LQ("luarocks.loader")..") _=k " .. | 104 | local addctx = "local k,l,_=pcall(require,"..util.LQ("luarocks.loader")..") _=k " .. |
| 99 | "and l.add_context("..util.LQ(name)..","..util.LQ(version)..")" | 105 | "and l.add_context("..util.LQ(name)..","..util.LQ(version)..")" |
| @@ -107,6 +113,11 @@ function unix.wrap_script(script, target, deps_mode, name, version, ...) | |||
| 107 | script and fs.Q(script) or [[$([ "$*" ] || echo -i)]], | 113 | script and fs.Q(script) or [[$([ "$*" ] || echo -i)]], |
| 108 | ... | 114 | ... |
| 109 | } | 115 | } |
| 116 | if remove_interpreter then | ||
| 117 | table.remove(argv, 1) | ||
| 118 | table.remove(argv, 1) | ||
| 119 | table.remove(argv, 1) | ||
| 120 | end | ||
| 110 | 121 | ||
| 111 | wrapper:write("#!/bin/sh\n\n") | 122 | wrapper:write("#!/bin/sh\n\n") |
| 112 | wrapper:write("LUAROCKS_SYSCONFDIR="..fs.Q(cfg.sysconfdir) .. " ") | 123 | wrapper:write("LUAROCKS_SYSCONFDIR="..fs.Q(cfg.sysconfdir) .. " ") |
diff --git a/src/luarocks/fs/win32.lua b/src/luarocks/fs/win32.lua index ec75e605..f544393d 100644 --- a/src/luarocks/fs/win32.lua +++ b/src/luarocks/fs/win32.lua | |||
| @@ -163,12 +163,18 @@ function win32.wrap_script(script, target, deps_mode, name, version, ...) | |||
| 163 | "package.path="..util.LQ(lpath..";").."..package.path", | 163 | "package.path="..util.LQ(lpath..";").."..package.path", |
| 164 | "package.cpath="..util.LQ(lcpath..";").."..package.cpath", | 164 | "package.cpath="..util.LQ(lcpath..";").."..package.cpath", |
| 165 | } | 165 | } |
| 166 | |||
| 167 | local remove_interpreter = false | ||
| 166 | if target == "luarocks" or target == "luarocks-admin" then | 168 | if target == "luarocks" or target == "luarocks-admin" then |
| 169 | if cfg.is_binary then | ||
| 170 | remove_interpreter = true | ||
| 171 | end | ||
| 167 | luainit = { | 172 | luainit = { |
| 168 | "package.path="..util.LQ(package.path), | 173 | "package.path="..util.LQ(package.path), |
| 169 | "package.cpath="..util.LQ(package.cpath), | 174 | "package.cpath="..util.LQ(package.cpath), |
| 170 | } | 175 | } |
| 171 | end | 176 | end |
| 177 | |||
| 172 | if name and version then | 178 | if name and version then |
| 173 | local addctx = "local k,l,_=pcall(require,'luarocks.loader') _=k " .. | 179 | local addctx = "local k,l,_=pcall(require,'luarocks.loader') _=k " .. |
| 174 | "and l.add_context('"..name.."','"..version.."')" | 180 | "and l.add_context('"..name.."','"..version.."')" |
| @@ -182,6 +188,11 @@ function win32.wrap_script(script, target, deps_mode, name, version, ...) | |||
| 182 | script and fs.Qb(script) or "%I%", | 188 | script and fs.Qb(script) or "%I%", |
| 183 | ... | 189 | ... |
| 184 | } | 190 | } |
| 191 | if remove_interpreter then | ||
| 192 | table.remove(argv, 1) | ||
| 193 | table.remove(argv, 1) | ||
| 194 | table.remove(argv, 1) | ||
| 195 | end | ||
| 185 | 196 | ||
| 186 | wrapper:write("@echo off\r\n") | 197 | wrapper:write("@echo off\r\n") |
| 187 | wrapper:write("setlocal\r\n") | 198 | wrapper:write("setlocal\r\n") |
