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

Adicionando os scripts para automatizar a compilação e empacotamento do OpenBUS

e de suas dependências externas. A forma de usar esses scripts está descrita no
ticket OPENBUS-64 no JIRA.

Os arquivos .desc são de descrição dos pacotes, tanto aqueles baseados em
autotools (basesoft.desc) quanto aqueles baseados em tecmake (packages.desc).

Os arquivos do diretório 'profile' contém a listagem dos pacotes que formam um
"perfil" de instalação do OpenBUS.

Os scripts run_*_tests.sh lançam os serviços básicos e rodam os testes
específicos. Em caso de mudança dos diretórios é preciso alterar paths dentro
deles.

Os arquivos compile.lua e makepack.lua precisam de parâmetros para funcionarem,
veja o '-h' deles.

Para uso desses scripts é recomendado adicionar ao LUA_PATH o diretório base da
pasta tools, ex:
  tendo o dir ~/work/trunk/tools 
  aponte LUA_PATH para "$HOME/work/trunk/?.lua;$LUA_PATH"

O arquivo config.lua contém a maioria das definições de variáveis sobre os
caminhos relativos que o compile.lua e makepack.lua usam. Caso sejam usados
diretórios personalizados é preciso editar apenas config.lua.

Assumi o seguinte cenário de diretórios:

$HOME/
$HOME/work
$HOME/work/trunk - checkout svn
$HOME/work/pkgfiles - arquivos por plataforma contendo a listagem de arquivos
                      que formam um pacote
$HOME/work/install - árvore de instalação, sobre a qual o makepack vai buscar
                      os arquivos para gerar os .tar.gz de cada perfil

$HOME/prodapp - em http://www.tecgraf.puc-rio.br/~amadeu/tarballs/prodapp.tar.gz
$HOME/prodapp/lib - libs lua
$HOME/prodapp/{openssl-0.9.9,openldap,...} - libs não-lua

$HOME/tools - pode ser um link para work/trunk/tools ou mesmo uma pasta
	      separada, considerando que precisaremos ter esses scripts antes
              mesmo de termos um checkout do svn = útil para usar binários lua
              pré-compilados


git-svn-id: https://subversion.tecgraf.puc-rio.br/engdist/openbus/trunk@84719 ae0415b3-e90b-0410-900d-d0be9363c56b
parent bd38432b
Projeto: OpenBUS
Empacotamento: Amadeu A. B. Jr <amadeu@tecgraf.puc-rio.br>
TecGRAF / PUC-Rio
======== [ Instalar o OpenBUS a partir do pacote final ] =========
1. Escolha um caminho para instalação e defina a variável OPENBUS_HOME:
É preciso manter esta configuração em seu profile!
Por exemplo, em BASH:
export OPENBUS_HOME=/usr/local
Já em CSH:
setenv OPENBUS_HOME /usr/local
2. Também adicione as seguintes linhas ao seu profile:
Se o seu SHELL padrão for BASH:
-----------8<-------------------------------------
. ${OPENBUS_HOME}/tools/shell/kshrc
-------------------------------------->8----------
Se o seu SHELL padrão for CSH:
-----------8<-------------------------------------
. ${OPENBUS_HOME}/tools/shell/cshrc
-------------------------------------->8----------
3. Extraia o pacote diretamente no mesmo caminho apontado por OPENBUS_HOME
4. Pronto! Agora basta usar o OpenBUS:
cd ${OPENBUS_HOME}/core/bin
./run_access_control_server.sh # lançamento do Serviço de Acesso
./run_registry_server.sh # lançamento do Serviço de Registro
./run_session_server.sh # lançamento do Serviço de Sessão
-- Description of basic software, tipical external programs that needs to be
-- compiled and installed with specific methods (like autotools)
basesoft = {
{ name = "cxxtest",
source = "http://www.tecgraf.puc-rio.br/~amadeu/tarballs/cxxtest.tar.gz",
dev_files = {
["cxxtestgen.pl"] = "bin",
["cxxtestgen.py"] = "bin",
["include/cxxtest"] = "incpath/cxxtest/",
},
},
{ name = "e2fsprogs-1.40.8",
source = "http://www.tecgraf.puc-rio.br/~amadeu/tarballs/e2fsprogs-1.40.8.tar.gz",
build = {
type = "autotools",
test_libs = {"libuuid.*"},
-- TIP: o configure dessa versão tem algum problema que dá um erro
-- ao tentar fazer make sem antes fazer um clean
Darwin = "make clean; ./configure --prefix=".. TMPDIR ..
" --enable-bsd-shlibs && cd lib/uuid && make && make install",
Linux = "gmake clean; ./configure --prefix=".. TMPDIR ..
" --enable-elf-shlibs && cd lib/uuid && gmake && gmake install",
SunOS = "gmake clean; ./configure --with-cc=gcc --prefix=".. TMPDIR ..
" --enable-elf-shlibs && cd lib/uuid && gmake && gmake install",
IRIX = "gmake clean; ./configure --prefix=".. TMPDIR ..
" --enable-elf-shlibs && cd lib/uuid && gmake && gmake install",
},
install_files = {
-- ["lib/libuuid*.dll*"] = "libpath/${TEC_UNAME}", --dynamic windows
["lib/libuuid*.so*"] = "libpath/${TEC_UNAME}", --dynamic linux,aix,sunos
["lib/libuuid*.dylib*"] = "libpath/${TEC_UNAME}",--dynamic macos
},
dev_files = {
["lib/libuuid*.a*"] = "libpath/${TEC_UNAME}", --static linux,aix,sunos
-- ["lib/libuuid*.lib*"] = "libpath/${TEC_UNAME}", --static windows
-- ["lib/libuuid*.dll*"] = "libpath/${TEC_UNAME}", --dynamic windows
["lib/libuuid*.so*"] = "libpath/${TEC_UNAME}", --dynamic linux,aix,sunos
["lib/libuuid*.dylib*"] = "libpath/${TEC_UNAME}",--dynamic macos
["lib/uuid/uuid.h"] = "incpath/e2fsprogs-1.40.8/uuid",
},
},
{ name = "openssl-0.9.9",
source = "http://www.tecgraf.puc-rio.br/~amadeu/tarballs/openssl-0.9.9.tar.gz",
build = {
type = "autotools",
test_libs = {"libcrypto*0.9.9*"},
Darwin = "./config no-asm shared --prefix=".. TMPDIR ..
" --openssldir=".. TMPDIR .."/openssl && make && make install_sw",
Linux = "./config shared --prefix=".. TMPDIR ..
" --openssldir=".. TMPDIR .."/openssl && make && make install_sw",
IRIX = "./config shared --prefix=".. TMPDIR ..
" --openssldir=".. TMPDIR .."/openssl && make && make install_sw",
SunOS = "./config shared --prefix=".. TMPDIR ..
" --openssldir=".. TMPDIR .."/openssl && make && make install_sw",
SunOS510x86 = "./config no-asm shared --prefix=".. TMPDIR ..
" --openssldir=".. TMPDIR .."/openssl && make && make install_sw",
},
install_files = {
-- ["libssl*.dll*"] = "libpath/${TEC_UNAME}", --dynamic windows
-- ["libcrypto*.dll*"] = "libpath/${TEC_UNAME}",
[TMPDIR .."/lib/libssl*.so*"] = "libpath/${TEC_UNAME}", --dynamic linux,aix,sunos
[TMPDIR .."/lib/libcrypto*.so*"] = "libpath/${TEC_UNAME}",
[TMPDIR .."/lib/libssl*.dylib*"] = "libpath/${TEC_UNAME}", --dynamic macos
[TMPDIR .."/lib/libcrypto*.dylib*"] = "libpath/${TEC_UNAME}",
[TMPDIR .."/bin/openssl"] = "bin/${TEC_UNAME}",
[TMPDIR .."/bin/c_rehash"] = "bin/${TEC_UNAME}",
[TMPDIR .."/openssl/*"] = "openssl",
},
dev_files = {
[TMPDIR .."/include/openssl"] = "incpath/openssl-0.9.9",
[TMPDIR .."/lib/libssl*.a*"] = "libpath/${TEC_UNAME}", --static linux,aix,sunos
[TMPDIR .."/lib/libcrypto*.a*"] = "libpath/${TEC_UNAME}",
-- ["libssl*.lib*"] = "libpath/${TEC_UNAME}", --static windows
-- ["libcrypto*.lib*"] = "libpath/${TEC_UNAME}",
-- ["libssl*.dll*"] = "libpath/${TEC_UNAME}", --dynamic windows
-- ["libcrypto*.dll*"] = "libpath/${TEC_UNAME}",
[TMPDIR .."/lib/libssl*.so*"] = "libpath/${TEC_UNAME}", --dynamic linux,aix,sunos
[TMPDIR .."/lib/libcrypto*.so*"] = "libpath/${TEC_UNAME}",
[TMPDIR .."/lib/libssl*.dylib*"] = "libpath/${TEC_UNAME}", --dynamic macos
[TMPDIR .."/lib/libcrypto*.dylib*"] = "libpath/${TEC_UNAME}",
[TMPDIR .."/bin/openssl"] = "bin/${TEC_UNAME}",
[TMPDIR .."/bin/c_rehash"] = "bin/${TEC_UNAME}",
[TMPDIR .."/openssl/*"] = "openssl",
},
},
{ name = "db-4.6.21",
source = "http://www.tecgraf.puc-rio.br/~amadeu/tarballs/db-4.6.21.tar.gz",
build = {
type = "autotools",
test_libs = {"libdb.*"},
Darwin = "cd build_unix; make clean; ../dist/configure --prefix=".. TMPDIR ..
" && make && make install",
Linux = "cd build_unix; gmake clean; ../dist/configure --prefix=".. TMPDIR ..
" && gmake && gmake install",
SunOS = "cd build_unix; gmake clean; ../dist/configure --prefix=".. TMPDIR ..
" && gmake && gmake install",
SunOS510x86 = "cd build_unix; gmake clean; ../dist/configure CC=gcc --prefix=".. TMPDIR ..
" && gmake && gmake install",
IRIX = "cd build_unix; gmake clean; ../dist/configure --prefix=".. TMPDIR ..
" && gmake && gmake install",
},
install_files = {
[TMPDIR .."/lib/libdb*.so*"] = "libpath/${TEC_UNAME}", --dynamic linux,aix,sunos
[TMPDIR .."/lib/libdb*.dylib*"] = "libpath/${TEC_UNAME}",--dynamic macos
},
dev_files = {
[TMPDIR .."/lib/libdb*.a*"] = "libpath/${TEC_UNAME}", --static linux,aix,sunos
[TMPDIR .."/lib/libdb*.so*"] = "libpath/${TEC_UNAME}", --dynamic linux,aix,sunos
[TMPDIR .."/lib/libdb*.dylib*"] = "libpath/${TEC_UNAME}",--dynamic macos
[TMPDIR .."/include/db.h"] = "incpath/db-4.6.21",
[TMPDIR .."/include/db_cxx.h"] = "incpath/db-4.6.21",
},
},
{ name = "cyrus-sasl2-2.1.22.dfsg1",
source = "http://www.tecgraf.puc-rio.br/~amadeu/tarballs/cyrus-sasl2-2.1.22.dfsg1.tar.gz",
build = {
type = "autotools",
test_libs = {"libsasl2*.*"},
external_dependencies = {
includes = "db.h",
libs = "libdb.so",
},
Darwin = "./configure --prefix=".. TMPDIR .." --disable-macos-framework --disable-ldap --enable-static=yes"..
" && cd include/ && make && make install "..
" && cd ../lib/ && make && make install ",
Linux = "./configure --prefix=".. TMPDIR .." --disable-ldap --enable-static=yes"..
" && cd include/ && make && make install "..
" && cd ../lib/ && make && make install ",
SunOS = "./configure --prefix=".. TMPDIR .." --disable-ldap --enable-static=yes"..
" && cd include/ && make && make install "..
" && cd ../lib/ && make && make install ",
SunOS510x86 = "env CC=gcc ./configure --prefix=".. TMPDIR .." --disable-ldap --enable-static=yes"..
" && cd include/ && make && make install "..
" && cd ../lib/ && make && make install ",
IRIX = "./configure --prefix=".. TMPDIR .." --disable-ldap --enable-static=yes"..
" && cd include/ && make && make install "..
" && cd ../lib/ && make && make install ",
},
install_files = {
[TMPDIR .."/lib/libsasl2*.*so*"] = "libpath/${TEC_UNAME}", --dynamic linux,aix,sunos
[TMPDIR .."/lib/libsasl2*.*dylib*"] = "libpath/${TEC_UNAME}",--dynamic macos
},
dev_files = {
[TMPDIR .."/lib/libsasl2*.a*"] = "libpath/${TEC_UNAME}", --static linux,aix,sunos
[TMPDIR .."/lib/libsasl2*.*so*"] = "libpath/${TEC_UNAME}", --dynamic linux,aix,sunos
[TMPDIR .."/lib/libsasl2*.*dylib*"] = "libpath/${TEC_UNAME}",--dynamic macos
[TMPDIR .."/include/sasl"] = "incpath/cyrus-sasl2-2.1.22.dfsg1",
},
},
{ name = "openldap-2.1.30",
source = "http://www.tecgraf.puc-rio.br/~amadeu/tarballs/openldap-2.1.30.tar.gz",
build = {
type = "autotools",
test_libs = {"libldap*.*"},
external_dependencies = {
includes = "db.h",
libs = "libdb.so",
},
Darwin = "env LIBS=-lresolv ./configure --prefix=".. TMPDIR .." --disable-slapd --disable-slurpd"..
" && make depend && make && make install",
Linux = "./configure --prefix=".. TMPDIR .." --disable-slapd --disable-slurpd"..
" && make depend && make && make install",
SunOS = "./configure --prefix=".. TMPDIR .." --disable-slapd --disable-slurpd"..
" && make depend && make && make install",
SunOS510x86 = "env CC=gcc ./configure --prefix=".. TMPDIR .." --disable-slapd --disable-slurpd"..
" && make depend && make && make install",
IRIX = "./configure --prefix=".. TMPDIR .." --disable-slapd --disable-slurpd"..
" && make depend && make && make install",
},
install_files = {
[TMPDIR .."/lib/libldap*.so*"] = "libpath/${TEC_UNAME}", --dynamic linux,aix,sunos
[TMPDIR .."/lib/libldap*.dylib*"] = "libpath/${TEC_UNAME}",--dynamic macos
[TMPDIR .."/lib/liblber*.so*"] = "libpath/${TEC_UNAME}", --dynamic linux,aix,sunos
[TMPDIR .."/lib/liblber*.dylib*"] = "libpath/${TEC_UNAME}",--dynamic macos
},
dev_files = {
[TMPDIR .."/lib/libldap*.a*"] = "libpath/${TEC_UNAME}", --static linux,aix,sunos
[TMPDIR .."/lib/libldap*.so*"] = "libpath/${TEC_UNAME}", --dynamic linux,aix,sunos
[TMPDIR .."/lib/libldap*.dylib*"] = "libpath/${TEC_UNAME}",--dynamic macos
[TMPDIR .."/lib/liblber*.a*"] = "libpath/${TEC_UNAME}", --static linux,aix,sunos
[TMPDIR .."/lib/liblber*.so*"] = "libpath/${TEC_UNAME}", --dynamic linux,aix,sunos
[TMPDIR .."/lib/liblber*.dylib*"] = "libpath/${TEC_UNAME}",--dynamic macos
[TMPDIR .."/include/ldap*"] = "incpath/openldap-2.1.30",
[TMPDIR .."/include/lber*"] = "incpath/openldap-2.1.30",
},
},
}
-- Basic variables (global vars are in upper case)
require "tools.config"
local util = require "tools.util"
local copy = require "tools.build.copy"
-- Local scope
local string = require "tools.split"
local platforms = require "tools.platforms"
local myplat = platforms[TEC_SYSNAME]
module("tools.build.autotools",package.seeall)
-- Ensure tempdirs for bogus ./configure
os.execute("mkdir -p ".. TMPDIR)
os.execute("mkdir -p ".. TMPDIR .."/bin")
os.execute("mkdir -p ".. TMPDIR .."/lib")
os.execute("mkdir -p ".. TMPDIR .."/include")
-- Build dependencies check (originaly) to basesoft packages
function check_external_deps(pkgtable)
if pkgtable.external_dependencies then
for category,files in pairs(pkgtable.external_dependencies) do
local var, ok = "", false
if category == "bins" then
-- using generic platform search
ok = platforms:search_ldlibpath(files,"/usr/bin","PATH")
elseif category == "libs" then
-- using platform oriented variables
ok = myplat:search_ldlibpath(files)
elseif category == "includes" then
-- using generic platform search
ok = platforms:search_ldlibpath(files,"/usr/include","CPATH")
end
assert(ok,"Aborting for missing build dependencies. Missing "..
"the following ".. category ..": ".. files)
end
end
end
-- Function that implements the autotools building
function run(t,arguments)
print(" [info] Verifying if needs to compile via autotools: "..t.name)
local plat = TEC_UNAME
if not t.build[plat] then
plat = TEC_SYSNAME
assert(t.build[plat],t.name..[[ on platform ']]..plat..[[', no build method]])
end
-- when '--force' is requested we will rebuild the soft or when any
-- test library is missing on library path
for _,lib in ipairs(t.build.test_libs) do
if arguments["force"] or not myplat:search_ldlibpath(lib) then
-- verifying if all build dependencies are ok, if don't we'll abort
check_external_deps(t)
local build_dir = PRODAPP .."/".. t.name .."/"
-- downloading package just one time
util.fetch_and_unpack(t.name, t.source, build_dir)
-- running the build and install command
local build_cmd = t.build[plat]
-- prepend clean target to makefile if rebuild is setted
if arguments["rebuild"] then
build_cmd = "make distclean || make clean || "..
"gmake distclean || gmake clean; " .. build_cmd
end
-- prepend the command to enter on software directory
build_cmd = "cd ".. build_dir .."; ".. build_cmd
print(" [info] Compiling "..t.name)
local ret = os.execute(build_cmd)
-- assert ensure that we could continue
assert(ret == 0,"ERROR compiling the software ".. t.name .."")
-- re-using copy method to parse install_files, dev_files
copy.run(t,arguments,build_dir)
break
end
end
end
require "tools.config"
local util = require "tools.util"
-- Local scope
local string = require "tools.split"
local platforms = require "tools.platforms"
local myplat = platforms[TEC_SYSNAME]
module("tools.build.copy", package.seeall)
function run(t,arguments,build_dir)
assert(type(t) == "table")
-- we assume a default build_dir pointing to PRODAPP
if not build_dir then
build_dir = PRODAPP .."/".. t.name .."/"
print(" [info] Assuming build_dir as '"..build_dir.."' for pkg: ".. t.name)
end
-- fetching and unpacking
if t.source then
util.fetch_and_unpack(t.name, t.source, build_dir)
end
-- copying files described on packages table
if t.install_files then
for orig, dest in pairs(t.install_files) do
-- if absolute path we assume that you know where get the files
if orig:match("^/") then build_dir = "" end
util.install(t.name, build_dir .. orig, dest)
end
end
-- copying files to special packages with '-dev' suffix
if t.dev_files then
for orig, dest in pairs(t.dev_files) do
-- if absolute path we assume that you know where get the files
if orig:match("^/") then build_dir = "" end
util.install(t.name.."-dev", build_dir.. orig, dest)
end
end
-- linking files described on packages table
if t.symbolic_links then
for orig, linkpath in pairs(t.symbolic_links) do
util.link(t.name, orig, linkpath)
end
end
end
-- Basic variables (global vars are in upper case)
require "tools.config"
local util = require "tools.util"
local copy = require "tools.build.copy"
-- Local scope
local string = require "tools.split"
local platforms = require "tools.platforms"
local myplat = platforms[TEC_SYSNAME]
module("tools.build.tecmake", package.seeall)
function run(t, arguments)
print(" [info] Compiling package via tecmake: ".. t.name)
local build_dir = t.build.src
for _, mf in ipairs(t.build.mf) do
-- compiling all targets
local build_cmd = "cd ".. build_dir .. "; ".. "tecmake MF=".. mf
if arguments["rebuild"] then build_cmd = build_cmd .. " rebuild" end
local ret = os.execute(build_cmd)
assert(ret == 0,"ERROR compiling the software ".. t.name .."")
end
-- installing software compiled previously
-- defaut behaviour is the automatic installation on INSTALL dirs
if #t.build.mf > 0 and not t.install_files and not t.dev_files then
util.install(t.name, build_dir .. "../bin/".. TEC_UNAME .. "/*", INSTALL.BIN )
util.install(t.name, build_dir .. "../lib/".. TEC_UNAME .. "/*".. t.name .."*.so*", INSTALL.LIB )
util.install(t.name, build_dir .. "../lib/".. TEC_UNAME .. "/*".. t.name .."*.dylib*", INSTALL.LIB )
-- util.install(t.name, build_dir .. "../lib/".. TEC_UNAME .. "/*".. t.name .."*.dll*", INSTALL.LIB )
util.install(t.name.."-dev", build_dir .. "../lib/".. TEC_UNAME .. "/*".. t.name .."*.a*", INSTALL.LIB )
util.install(t.name.."-dev", build_dir .. "../lib/".. TEC_UNAME .. "/*".. t.name .."*.so*", INSTALL.LIB )
util.install(t.name.."-dev", build_dir .. "../lib/".. TEC_UNAME .. "/*".. t.name .."*.dylib*", INSTALL.LIB )
-- util.install(t.name.."-dev", build_dir .. "../lib/".. TEC_UNAME .. "/*".. t.name .."*.lib*", INSTALL.LIB )
-- util.install(t.name.."-dev", build_dir .. "../lib/".. TEC_UNAME .. "/*".. t.name .."*.dll*", INSTALL.LIB )
util.install(t.name.."-dev", build_dir .. "../include/*", INSTALL.INC .. t.name )
end
-- re-using copy method to parse install_files, dev_files
copy.run(t,arguments,build_dir)
end
package.path = "?.lua;../?.lua;" .. package.path
local string = require "tools.split"
local platforms = require "tools.platforms"
package.path = ""
local posix = require "posix"
assert(os.getenv("OPENBUS_HOME"), "OPENBUS_HOME env var not defined")
assert(os.getenv("TEC_SYSNAME"), "TEC_SYSNAME env var not defined")
local OPENBUS_HOME = os.getenv("OPENBUS_HOME")
-- how tecmake identifies my platform
local myplat = os.getenv("TEC_SYSNAME")
-- parse plat format to represent the unknown symbols
-- print("DEBUG: all symbols:")
-- s = platforms[myplat]:unknown_symbols(FILE)
-- print(s)
misses = {}
libpath = posix.dir(OPENBUS_HOME.."/libpath")
for _,file in ipairs(libpath) do
if file:find(".so") then
-- check against the dynamic libraries
print("DEBUG: looking for "..file.." dynamic dependencies")
local miss = platforms[myplat]:missing_libraries(file)
if miss then
table.insert(misses,{name = file, miss = miss})
end
end
end
print("DEBUG: missing dependencies")
for name,miss in pairs(misses) do
print(" missing for ",name)
table.foreach(miss,print)
end
#!/bin/ksh
cd $HOME/prodapp/lib/
for each in `ls`
do
rm -rf $each/{bin,lib,obj}/${TEC_UNAME}
done
cd $HOME/work/trunk
rm -rf core/{bin,obj}/${TEC_UNAME}
rm -rf core/services/servicelauncher.dep
rm -rf core/utilities/cppoil/openbus.dep
rm -rf core/utilities/cppoil/lib/${TEC_UNAME}
rm -rf core/utilities/cppoil/obj/${TEC_UNAME}
rm -rf lib/lce/lib/${TEC_UNAME}
rm -rf lib/lce/obj/${TEC_UNAME}
rm -rf lib/lce/src/lce.dep
rm -rf lib/scs/lib/${TEC_UNAME}
rm -rf lib/scs/obj/${TEC_UNAME}
rm -rf lib/scs/src/scsoil.dep
rm -rf lib/scs/src/scsall.dep
rm -rf lib/ftc/lib/${TEC_UNAME}
rm -rf lib/ftc/obj/${TEC_UNAME}
rm -rf lib/ftc/src/ftc.dep
rm -rf lib/ftc/src/ftcwooil.dep
#!/usr/bin/env lua5.1
package.path = "?.lua;../?.lua;" .. package.path
-- Basic variables (global vars are in upper case)
require "tools.config"
local util = require "tools.util"
-- Local scope
local string = require "tools.split"
local platforms = require "tools.platforms"
local myplat = platforms[TEC_SYSNAME]
local default_assert = assert
--------------------------------------------------------------------------------
-- Parsing arguments, filtering descriptions and reaching basic requests -------
--------------------------------------------------------------------------------
-- Parsing arguments
assert(arg,"Table arg missing! This program should be loaded from console.")
local arguments = {}
local patt="%-?%-?(%w+)(=?)(.*)"
local usage_msg=[[ Usage: ]]..arg[0]..[[ OPTIONS
Valid OPTIONS:
--help : show this help
--verbose : turn ON the VERBOSE mode (show the system commands)
--basesoft=filename : use the 'filename' as input for basic
softwares with autotools semantic (i.e: openssl)
--packages=filename : use the 'filename' as input for packages
with tecmake semantic (i.e: lua5.1, openbus-core)
--rebuild : changes the default rule for tecmake rebuild if
already compiled
--force : forces the compile and install (i.e: you want
re-generate some library even it's installed
already = to debug or devel purpose)
--list : list all package names from description files. When
'--select' is used, it'll confirm the selection.
--select="pkg1 pkg2 ..." : choose which packages to compile and install ]]
for i,param in ipairs(arg) do
local opt,_,value = string.match(param,patt)
if opt == "h" or opt == "help" then
print(usage_msg)
os.exit(0)
end
if opt and value then
if opt == "select" then
-- selecting packages to build with multiple '--select' support
if not arguments[opt] then arguments[opt] = {} end
for _,pkg in ipairs({value:split("[^%s]+")}) do
arguments[opt][pkg] = pkg
end
else
arguments[opt] = value
end
end
end
print("\nINFO: We are going to install full openbus dependencies on \
".. INSTALL.TOP .." and temporary install directories \
(for autotools based packages) on ".. TMPDIR .." .\n")
-- Loading basesoft and package descriptions tables
assert(loadfile(arguments["basesoft"] or DEPLOYDIR .."/basesoft.desc"))()
assert(loadfile(arguments["packages"] or DEPLOYDIR .."/packages.desc"))()
-- Filtering the descriptions tables with '--select' arguments
-- preparing the tables to provide t[pkg_name] fields
function rehashByName(mytable)
-- REMEMBER: loop.ordered.set is better but insert loop dependency
for i,t in ipairs(mytable) do
mytable[t.name] = t
end
end
rehashByName(basesoft)
rehashByName(packages)
-- real filtering
local newbasesoft = {}
local newpackages = {}
if arguments["select"] then
for pkg,_ in pairs(arguments["select"]) do
-- cloning the references in new tables
if basesoft[pkg] then
table.insert(newbasesoft,basesoft[pkg])
end
if packages[pkg] then
table.insert(newpackages,packages[pkg])
end
end
-- replace the main references to cloned tables
if #newbasesoft > 0 then basesoft = newbasesoft end
if #newpackages > 0 then packages = newpackages end
end
-- Listing packages when '--list' arguments
if arguments["list"] then
print "INFO: Available basesoft to compile and install:"
for _, t in ipairs(basesoft) do
print("\t"..t.name)
end
print "\nINFO: Available packages to compile and install:"
for _, t in ipairs(packages) do
print("\t"..t.name)
end
os.exit(0)
end
--------------------------------------------------------------------------------
-- Useful functions (overloading, install and link) ----------------------------
--------------------------------------------------------------------------------
-- Setting verbose level if requested
if arguments["verbose"] or arguments["v"] then
util.verbose(1)
end
--------------------------------------------------------------------------------
-- Main code -------------------------------------------------------------------
--------------------------------------------------------------------------------
-- Creating the build environment to create .tar.gz (later) from it
os.execute("mkdir -p ".. INSTALL.TOP)
os.execute("mkdir -p ".. INSTALL.LIB)
os.execute("mkdir -p ".. INSTALL.BIN)
os.execute("mkdir -p ".. INSTALL.INC)
os.execute("mkdir -p ".. TMPDIR)
os.execute("mkdir -p ".. PKGDIR)
os.execute(FETCH_CMD)
-- Cleaning the temp dir to execute install rules of autotools softwares
os.execute("rm -rf "..TMPDIR.."/*")
-- Parsing basesoft and compiling+installing on WORKDIR environment
function parseDescriptions(desc)
for _, t in ipairs(desc) do
print "----------------------------------------------------------------------"
-- hack when no build is provided, to _always_ copy install_files , dev_files
if not t.build then
t.build = { type = "copy" }
end
assert(t.build.type, "ERROR: build.type is missing for package: "..t.name)
-- loading specific build methods
ok, build_type = pcall(require, "tools.build." .. t.build.type)
assert(ok and type(build_type) == "table","ERROR: failed initializing "..
"build back-end for build type: '".. t.build.type ..
"' for package: ".. t.name)
-- starting build methods
build_type.run(t,arguments)
print " [info] Done!"
print "----------------------------------------------------------------------"
end
end
parseDescriptions(basesoft)
parseDescriptions(packages)