Commit c345abbe authored by Amadeu Andrade Barbosa Junior's avatar Amadeu Andrade Barbosa Junior
Browse files

BUGFIX: no installer e no check-lib-deps.

O check-lib-deps.libraries_deps fazia verificação erroneamente, agora
após platforms.missing_libraries (usa o ldd ou similar). Tentando 
encontrar a dependência ausente dentro do pacote openbus, pois
pode estar sendo provida. Caso não encontre, então realmente está
ausente. 

Para dar mais informações ao usuário poderíamos usar a 
platforms.search_ldlibpath para testar se existem nos diretórios que
sabemos que são mais comuns para cada plataforma alocar suas
bibliotecas do sistema.

git-svn-id: https://subversion.tecgraf.puc-rio.br/engdist/openbus/trunk@86031 ae0415b3-e90b-0410-900d-d0be9363c56b
parent bc60689f
......@@ -16,7 +16,9 @@ local checker = {}
-- Checks libraries dependencies in an OpenBus installation
function checker:libraries_deps(openbus_home)
assert(type(openbus_home) == "string", "ERROR: Check libraries function receives a nil parameter.")
local myplat = platforms[TEC_SYSNAME]
assert(type(myplat.dylibext) == "string", "ERROR: Missing dynamic libraries extension information on 'platforms'.")
local function rollback()
-- Recovering important variables to LuaVM
package.path = package_path
......@@ -24,34 +26,33 @@ function checker:libraries_deps(openbus_home)
end
local msg = "[ checker:libraries_deps ] "
local libpath = openbus_home.."/libpath/"..TEC_UNAME
local myplat = platforms[TEC_SYSNAME]
assert(type(myplat.dylibext) == "string", "ERROR: Missing dynamic libraries extension information on 'platforms'.")
local check_paths = {
openbus_home.."/libpath/"..TEC_UNAME,
openbus_home.."/bin/"..TEC_UNAME,
openbus_home.."/core/bin/"..TEC_UNAME,
}
print(msg.."assuming that libraries has '"..myplat.dylibext.."' extension.")
print(msg.."assuming OpenBus installation: "..openbus_home)
print(msg.."assuming additional path for libs: "..libpath)
print(msg.."assuming additional path for libs: "..check_paths[1])
package.cpath = package.cpath .. ";"..
-- posix module uses an unusual lua_open name!
libpath .."/libl?."..myplat.dylibext..";"..
check_paths[1] .."/libl?."..myplat.dylibext..";"..
-- others openbus libs uses lib<name>.<dylibext>
libpath .."/lib?."..myplat.dylibext..";"
-- trying load the posix module
local posix = require "posix"
check_paths[1] .."/lib?."..myplat.dylibext..";"
local misses = {}
local libpath_files = posix.dir(libpath)
if not libpath_files then
rollback()
return nil, {}, "ERROR: Invalid OpenBus path for your platform."
end
-- testing all dynamic library files
for _,file in ipairs(libpath_files) do
local fullname = libpath.."/"..file
if fullname:find("."..myplat.dylibext) then
for _, path in ipairs(check_paths) do
local files = {myplat.exec(myplat.cmd.ls..path):split("[^%s]+")}
if #files == 0 then
rollback()
return nil, {}, "ERROR: Invalid OpenBus path for your platform."
end
-- testing all dynamic library files
for _,file in ipairs(files) do
local fullname = path.."/"..file
--print("DEBUG: looking for "..file.." dynamic dependencies")
-- returns a table containing the misses
local miss = myplat:missing_libraries(fullname)
-- parse plat format to represent the unknown symbols
-- good for more information about the miss library
......@@ -61,10 +62,24 @@ function checker:libraries_deps(openbus_home)
-- print(s)
if miss then
-- second check: trying use openbus libpath (that can being installed!!)
local willbefine = myplat:search_ldlibpath(file,libpath)
if not willbefine then
table.insert(misses,{name = file, miss = miss})
-- maybe the openbus package will provide the miss libraries
-- if not then we will report a system_misses list!
local system_misses = {name = file, miss = {}}
for i,missfile in ipairs(miss) do
-- second check: trying use openbus libpath (that can being installed!!)
local willbefine = io.open(check_paths[1].."/"..missfile, "r")
if not willbefine then
if not system_misses.miss[missfile] then
system_misses.miss[missfile] = true
system_misses.miss[#system_misses.miss+1] = missfile
end
else
willbefine:close()
end
end
-- we actually don't known these libraries
if #system_misses.miss > 0 then
table.insert(misses,system_misses)
end
end
end
......@@ -72,8 +87,8 @@ function checker:libraries_deps(openbus_home)
-- return nil if we got misses
if #misses > 0 then
return nil, misses, "ERROR: Check if your system variable for dynamic "..
"libraries is right."
return nil, misses, "ERROR: Check your system variable that contains dynamic "..
"libraries paths."
else
print(msg.."done!")
return true
......@@ -89,8 +104,8 @@ function checker:start(openbus_home)
if not ok then
for i,t in ipairs(misses) do
if #t.miss > 0 then
print(" ERROR: missing for ",t.name)
table.foreach(t.miss,print)
print(" ERROR: "..t.name.." depends on:")
for _,libname in ipairs(t.miss) do print(libname) end
end
end
return nil, errmsg
......
......@@ -173,17 +173,19 @@ if arguments.package then
-- Trying extract the metadata.tar.gz from package
print(INSTALL, "Extracting metadata.")
extract_cmd = "gzip -c -d "..arguments.package.." | "
extract_cmd = extract_cmd .. "tar -C ".. TMPDIR .." -x metadata.tar.gz && "
extract_cmd = extract_cmd .. "gzip -c -d ".. TMPDIR .."/metadata.tar.gz |"
extract_cmd = extract_cmd .. "tar -C ".. TMPDIR .." -x"
extract_cmd = myplat.cmd.install..arguments.package.." ".. TMPDIR .."/tempinstall.tar.gz;"
extract_cmd = extract_cmd .. " cd "..TMPDIR.." ; gzip -c -d tempinstall.tar.gz | "
extract_cmd = extract_cmd .. "tar -xf - metadata.tar.gz && "
extract_cmd = extract_cmd .. "gzip -c -d metadata.tar.gz |"
extract_cmd = extract_cmd .. "tar -xf -"
assert(os.execute(extract_cmd) == 0, "ERROR: '".. arguments.package .."'"..
" is not a valid package! Please contact the administrator!")
-- Unpacking the openbus-<<release>>_plat.tar.gz package
-- Grant to user's configure_action functions that could operate over an
-- instalation tree and at the end all files will be copied to real path
assert(os.execute("gzip -c -d "..arguments.package.." |tar -C ".. TMPDIR .." -x") == 0)
assert(os.execute("cd "..TMPDIR.."; gzip -c -d tempinstall.tar.gz|tar -xf -") == 0)
assert(os.remove(TMPDIR.."/tempinstall.tar.gz"))
print(INSTALL, "Unpack DONE.")
-- Verifying the openbus libraries consistency for this system
......@@ -191,7 +193,7 @@ if arguments.package then
local libchecker = require "tools.check-lib-deps"
local ok, msg = libchecker:start(TMPDIR)
if not ok then error(msg.."\n '"..arguments.package.."'"..
" is not a valid package! Please contact the administrator!")
" has missing dependencies! Please contact the administrator!")
else print(INSTALL,msg) end
print(CONFIG, "Configuring the package based on package metadata")
......
......@@ -5,6 +5,13 @@ local print,io = print,io
module("platforms")
-- PROBLEMA: como identificar corretamente quais diretórios padrões são usados
-- pelo link editor em tempo de carga? se a LD_LBIRARY_PATH estiver vazia
-- esses diretórios padrões serão usados na busca por símbolos, mas aí nosso
-- search_ldlibpath não saberá identificar que não é uma falta de lib!
-- REFLEXAO: nossa intenção com search_ldlibpath é reproduzir o mecanismo por
-- plataforma de busca de bibliotecas dependentes! precisamos mesmo?
platforms = {
dylibext = "so",
cmd = { install = "cp -Rf ", make = "make ", mkdir = "mkdir -p ", rm = "rm -rf ", ls = "ls " },
......@@ -22,9 +29,11 @@ platforms = {
if ld_var then dirs = ld_var .. ":" .. dirs end
local realpath = false
for _,dir in ipairs({dirs:split("[^:]+")})
do
realpath = self.exec("find ".. dir .." -name ".. file)
if realpath == "" then realpath = false else break end
do
if io.open(dir .."/"..file, "r") then
realpath = dir .."/"..file
break
end
end
return realpath
end,
......@@ -40,7 +49,7 @@ platforms.Linux = {
if dir and not dir:find(":$") then dir = dir:gsub("$",":")
else dir = "" end
local libpath = dir.."/lib:/usr/lib:/usr/local/lib:/lib32:/lib64:/usr/lib32:/usr/lib64"
return platforms:search_ldlibpath(file,libpath)
return platforms.search_ldlibpath(self,file,libpath)
end,
-- sample ldd output on Linux:
-- linux-gate.so.1 => (0xffffe000)
......@@ -80,7 +89,7 @@ platforms.SunOS = {
if dir and not dir:find(":$") then dir = dir:gsub("$",":")
else dir = "" end
local libpath = dir.."/lib:/usr/lib:/usr/sfw/lib:/usr/local/lib"
return platforms:search_ldlibpath(file,libpath)
return platforms.search_ldlibpath(self,file,libpath)
end,
-- sample ldd output on Solaris:
-- libcrypto.so.0.9.9 => (file not found)
......@@ -102,7 +111,7 @@ platforms.IRIX = {
if dir and not dir:find(":$") then dir = dir:gsub("$",":")
else dir = "" end
local libpath = dir.."/usr/lib:/usr/lib32:/usr/lib64:/usr/freeware/lib32"
return platforms:search_ldlibpath(file,libpath)
return platforms.search_ldlibpath(self,file,libpath)
end,
missing_libraries = function(self,file)
local str = self.exec("elfdump -Dl ".. file)
......@@ -134,7 +143,7 @@ platforms.Darwin = {
if dir and not dir:find(":$") then dir = dir:gsub("$",":")
else dir = "" end
local libpath = dir.."/usr/lib"
return platforms:search_ldlibpath(file,libpath,"DYLD_LIBRARY_PATH")
return platforms.search_ldlibpath(self,file,libpath,"DYLD_LIBRARY_PATH")
end,
missing_libraries = function(self,file)
local str = self.exec("otool -L ".. file)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment