summaryrefslogtreecommitdiffhomepage
path: root/modules
diff options
context:
space:
mode:
authorDaniel Dickinson <openwrt@daniel.thecshore.com>2016-03-25 03:04:18 -0400
committerDaniel Dickinson <openwrt@daniel.thecshore.com>2016-03-25 03:04:25 -0400
commit9652d44ef20d5ffcf65df319653590426029ebce (patch)
tree056661d9161af90b710c50c3e2d60a5bb3af405e /modules
parent5b79e62c0a99bab8dfb8dce8124d9fecc11da54b (diff)
luci-base: Add option to check linked libraries
Some packages have different variants that have different capabilities depending on which libraries against which they are linked. Add a function to check which library a binary links against in order to determine available functionality. Signed-off-by: Daniel Dickinson <openwrt@daniel.thecshore.com>
Diffstat (limited to 'modules')
-rw-r--r--modules/luci-base/luasrc/util.lua17
1 files changed, 17 insertions, 0 deletions
diff --git a/modules/luci-base/luasrc/util.lua b/modules/luci-base/luasrc/util.lua
index 2956aadcf3..d614a6c799 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