From: Hannu Nyman Date: Tue, 29 Mar 2016 12:33:00 +0000 (+0300) Subject: Merge pull request #678 from cshore/pull-request-lib-depends X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fluci.git;a=commitdiff_plain;h=6b627a934f525feebbaf72cd233c8f237d908918;hp=a28761f314f4d3b1e560962cb4edb493f66c6a81 Merge pull request #678 from cshore/pull-request-lib-depends luci-base: Add option to check linked libraries --- 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