diff options
author | Hannu Nyman <hannu.nyman@iki.fi> | 2016-03-29 15:33:00 +0300 |
---|---|---|
committer | Hannu Nyman <hannu.nyman@iki.fi> | 2016-03-29 15:33:00 +0300 |
commit | 6b627a934f525feebbaf72cd233c8f237d908918 (patch) | |
tree | 2add5e9672aa10d610a4f8b12357bee4727197a4 | |
parent | a28761f314f4d3b1e560962cb4edb493f66c6a81 (diff) | |
parent | 9652d44ef20d5ffcf65df319653590426029ebce (diff) |
Merge pull request #678 from cshore/pull-request-lib-depends
luci-base: Add option to check linked libraries
-rw-r--r-- | modules/luci-base/luasrc/util.lua | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/modules/luci-base/luasrc/util.lua b/modules/luci-base/luasrc/util.lua index 2956aadcf..d614a6c79 100644 --- a/modules/luci-base/luasrc/util.lua +++ b/modules/luci-base/luasrc/util.lua @@ -636,6 +636,23 @@ function libpath() return require "nixio.fs".dirname(ldebug.__file__) end +function checklib(fullpathexe, wantedlib) + local fs = require "nixio.fs" + local haveldd = fs.access('/usr/bin/ldd') + if not haveldd then + return -1 + end + local libs = exec("/usr/bin/ldd " .. fullpathexe) + if not libs then + return 0 + end + for k, v in ipairs(split(libs)) do + if v:find(wantedlib) then + return 1 + end + end + return 0 +end -- -- Coroutine safe xpcall and pcall versions modified for Luci |