diff options
author | Francois Perrad <francois.perrad@gadz.org> | 2021-06-09 22:00:15 +0200 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2021-06-22 17:28:36 -0300 |
commit | d4e82aae9f411d5d2cac10f7e043a0c3c6180eb1 (patch) | |
tree | 4e3068f41e649a61ba251a609dd47fe23e039f2c | |
parent | a9ea4395bca05516e8297588ec943c648f726345 (diff) | |
download | luarocks-d4e82aae9f411d5d2cac10f7e043a0c3c6180eb1.tar.gz luarocks-d4e82aae9f411d5d2cac10f7e043a0c3c6180eb1.tar.bz2 luarocks-d4e82aae9f411d5d2cac10f7e043a0c3c6180eb1.zip |
allow to work without debug library
-rw-r--r-- | src/luarocks/argparse.lua | 3 | ||||
-rw-r--r-- | src/luarocks/cmd.lua | 3 | ||||
-rw-r--r-- | src/luarocks/core/cfg.lua | 3 | ||||
-rw-r--r-- | src/luarocks/core/util.lua | 5 | ||||
-rw-r--r-- | src/luarocks/loader.lua | 4 | ||||
-rw-r--r-- | src/luarocks/util.lua | 3 |
6 files changed, 16 insertions, 5 deletions
diff --git a/src/luarocks/argparse.lua b/src/luarocks/argparse.lua index f440308d..2c2585dd 100644 --- a/src/luarocks/argparse.lua +++ b/src/luarocks/argparse.lua | |||
@@ -2067,6 +2067,9 @@ function Parser:parse(args) | |||
2067 | end | 2067 | end |
2068 | 2068 | ||
2069 | local function xpcall_error_handler(err) | 2069 | local function xpcall_error_handler(err) |
2070 | if not debug then | ||
2071 | return tostring(err) | ||
2072 | end | ||
2070 | return tostring(err) .. "\noriginal " .. debug.traceback("", 2):sub(2) | 2073 | return tostring(err) .. "\noriginal " .. debug.traceback("", 2):sub(2) |
2071 | end | 2074 | end |
2072 | 2075 | ||
diff --git a/src/luarocks/cmd.lua b/src/luarocks/cmd.lua index 72edc66d..233bb1bd 100644 --- a/src/luarocks/cmd.lua +++ b/src/luarocks/cmd.lua | |||
@@ -146,6 +146,9 @@ local function process_server_args(args) | |||
146 | end | 146 | end |
147 | 147 | ||
148 | local function error_handler(err) | 148 | local function error_handler(err) |
149 | if not debug then | ||
150 | return err | ||
151 | end | ||
149 | local mode = "Arch.: " .. (cfg and cfg.arch or "unknown") | 152 | local mode = "Arch.: " .. (cfg and cfg.arch or "unknown") |
150 | if package.config:sub(1, 1) == "\\" then | 153 | if package.config:sub(1, 1) == "\\" then |
151 | if cfg and cfg.fs_use_modules then | 154 | if cfg and cfg.fs_use_modules then |
diff --git a/src/luarocks/core/cfg.lua b/src/luarocks/core/cfg.lua index e24fa4f6..42f10991 100644 --- a/src/luarocks/core/cfg.lua +++ b/src/luarocks/core/cfg.lua | |||
@@ -50,6 +50,9 @@ local platform_order = { | |||
50 | } | 50 | } |
51 | 51 | ||
52 | local function detect_sysconfdir() | 52 | local function detect_sysconfdir() |
53 | if not debug then | ||
54 | return | ||
55 | end | ||
53 | local src = debug.getinfo(1, "S").source:gsub("\\", "/"):gsub("/+", "/") | 56 | local src = debug.getinfo(1, "S").source:gsub("\\", "/"):gsub("/+", "/") |
54 | if src:sub(1, 1) == "@" then | 57 | if src:sub(1, 1) == "@" then |
55 | src = src:sub(2) | 58 | src = src:sub(2) |
diff --git a/src/luarocks/core/util.lua b/src/luarocks/core/util.lua index 384a6eba..67a10b42 100644 --- a/src/luarocks/core/util.lua +++ b/src/luarocks/core/util.lua | |||
@@ -67,7 +67,10 @@ function util.show_table(t, tname, top_indent) | |||
67 | local function basic_serialize(o) | 67 | local function basic_serialize(o) |
68 | local so = tostring(o) | 68 | local so = tostring(o) |
69 | if type(o) == "function" then | 69 | if type(o) == "function" then |
70 | local info = debug.getinfo(o, "S") | 70 | local info = debug and debug.getinfo(o, "S") |
71 | if not info then | ||
72 | return ("%q"):format(so) | ||
73 | end | ||
71 | -- info.name is nil because o is not a calling level | 74 | -- info.name is nil because o is not a calling level |
72 | if info.what == "C" then | 75 | if info.what == "C" then |
73 | return ("%q"):format(so .. ", C function") | 76 | return ("%q"):format(so .. ", C function") |
diff --git a/src/luarocks/loader.lua b/src/luarocks/loader.lua index a3bd8f1b..825e4ce7 100644 --- a/src/luarocks/loader.lua +++ b/src/luarocks/loader.lua | |||
@@ -43,8 +43,8 @@ else | |||
43 | -- a global. | 43 | -- a global. |
44 | -- Detect when being called via -lluarocks.loader; this is | 44 | -- Detect when being called via -lluarocks.loader; this is |
45 | -- most likely a wrapper. | 45 | -- most likely a wrapper. |
46 | local info = debug.getinfo(2, "nS") | 46 | local info = debug and debug.getinfo(2, "nS") |
47 | if info.what == "C" and not info.name then | 47 | if info and info.what == "C" and not info.name then |
48 | luarocks = { loader = loader } | 48 | luarocks = { loader = loader } |
49 | temporary_global = true | 49 | temporary_global = true |
50 | -- For the other half of this hack, | 50 | -- For the other half of this hack, |
diff --git a/src/luarocks/util.lua b/src/luarocks/util.lua index ae96eb6a..bb474ff0 100644 --- a/src/luarocks/util.lua +++ b/src/luarocks/util.lua | |||
@@ -23,7 +23,6 @@ local unpack = unpack or table.unpack | |||
23 | local pack = table.pack or function(...) return { n = select("#", ...), ... } end | 23 | local pack = table.pack or function(...) return { n = select("#", ...), ... } end |
24 | 24 | ||
25 | local scheduled_functions = {} | 25 | local scheduled_functions = {} |
26 | local debug = require("debug") | ||
27 | 26 | ||
28 | --- Schedule a function to be executed upon program termination. | 27 | --- Schedule a function to be executed upon program termination. |
29 | -- This is useful for actions such as deleting temporary directories | 28 | -- This is useful for actions such as deleting temporary directories |
@@ -198,7 +197,7 @@ function util.this_program(default) | |||
198 | local i = 1 | 197 | local i = 1 |
199 | local last, cur = default, default | 198 | local last, cur = default, default |
200 | while i do | 199 | while i do |
201 | local dbg = debug.getinfo(i,"S") | 200 | local dbg = debug and debug.getinfo(i,"S") |
202 | if not dbg then break end | 201 | if not dbg then break end |
203 | last = cur | 202 | last = cur |
204 | cur = dbg.source | 203 | cur = dbg.source |