theCaption = None,
theCopyright = None,
theLicense = None,
- thePlatforms = None,
- theTargetdir = None,
- theTmpdir = None):
+ theTargetdir = None):
self.version = strip(theVersion)
self.caption = strip(theCaption)
self.copyright = strip(theCopyright)
self.license = strip(theLicense)
- self.platforms = strip(thePlatforms)
self.targetdir = strip(theTargetdir)
- self.tmpdir = strip(theTmpdir)
#==============================================================
# class Product : pre-requisite product options
def __init__(self,
theName,
theType = None,
- theOS = None,
theVersion = None,
theDependencies = None,
- theWoGuiInstallation = None,
theInstalldiskspace = None,
theScript = None,
thePickUpEnvironment = None):
self.name = strip(theName)
self.type = strip(theType)
- self.os = strip(theOS)
self.version = strip(theVersion)
self.dependencies = strip(theDependencies)
- self.woguiinst = strip(theWoGuiInstallation)
self.installdiskspace = strip(theInstalldiskspace)
self.script = strip(theScript)
self.pickupEnv = strip(thePickUpEnvironment)
- self.whattodo = __BINARIES__
+ self.whattodo = __BUILDSRC__
def setMode(self, mode):
if mode not in [__BINARIES__, __BUILDSRC__, __PREINSTALL__]:
"""
XML configuration files parser
"""
- def __init__(self, is_force_src=False, pltname=None):
+ def __init__(self):
self.docElem = None
self.products = []
self.full_prods_list = []
self.config = None
- self.is_force_src = is_force_src
- self.pltname = pltname
+ self.pltname = None
pass
def parse_config(self):
configElem.getAttribute('caption').strip(),
configElem.getAttribute('copyright').strip(),
configElem.getAttribute('license').strip(),
- configElem.getAttribute('platforms').strip(),
- configElem.getAttribute('targetdir').strip(),
- configElem.getAttribute('tempdir').strip())
- if not self.pltname and self.config.platforms:
- self.pltname = self.config.platforms.split(",")[0].strip()
+ configElem.getAttribute('targetdir').strip())
pass
def parse_dependencies(self):
# Parse 'dependencies' part of the XML file
depsMap = {}
+ if not len(self.docElem.getElementsByTagName('dependencies')):
+ return depsMap;
depsElem = self.docElem.getElementsByTagName('dependencies')[0]
for prodElem in depsElem.getElementsByTagName('product'):
prodName = prodElem.getAttribute('name').strip()
if prodName in depsMap: depsList = depsMap[prodName]
aProduct = Product(prodName,
prodElem.getAttribute('type').strip(),
- instElem.getAttribute('os').strip(),
instElem.getAttribute('version').strip(),
depsList,
- instElem.getAttribute('woguimode').strip(),
instElem.getAttribute('installdiskspace').strip(),
- instElem.getAttribute('script').strip(),
- instElem.getAttribute('pickupenv').strip())
- if self.is_force_src:
- aProduct.setMode(__BUILDSRC__)
- pass
+ instElem.getAttribute('script').strip())
if prodElem.getAttribute('type').strip() == "component":
sal_prods_list.append(aProduct)
# fill an ordered modules list -----------
req_prods_list.append(aProduct)
# fill an ordered prerequisites list -----------
prereqs_list.append(prodName)
- #AKL: prerequisite sources and temp files are removed, by default.
- # So, there is no need to make sources environment
- #if aProduct.whattodo == __BUILDSRC__: prereqs_list.append(prodName + "_src")
pass
pass
self.products.extend( req_prods_list )
self.products.extend( sal_prods_list )
- if len(self.products) != 0:
- gcc_product = Product("gcc",
- __CTX__PREREQUISITE__,
- self.products[0].os,
- "",
- [],
- None,
- "0,0,0",
- "gcc-common.sh",
- "")
- gcc_product.setMode(__PREINSTALL__)
- self.products.insert(0, gcc_product)
- prereqs_list.insert(0, gcc_product.name)
- pass
self.full_prods_list.extend( prereqs_list )
self.full_prods_list.extend( modules_list )
pass
dest="gui",
help=help_str)
help_str = "The configuration xml file.\n"
- help_str += "If this parameter is missing, then the program tries to define the "
- help_str += "Linux platform and use the corresponding xml file. For example, "
- help_str += "for Red Hat 8.0 config_RedHat_8.0.xml file is used in this case. "
+ help_str += "If this parameter is missing, then the default 'config.xml'"
+ help_str += "configuration file will be used."
opt_parser.add_option("-f",
"--file",
action="store",
dest="xmlfile",
metavar="FILE",
help=help_str)
- help_str = "The platform specification.\n"
- help_str += "This option can be used in conjunction with --file option in order"
- help_str += "to specify Linux platform name when XML file contains installation"
- help_str += "options for several platforms."
- opt_parser.add_option("-p",
- "--platform",
- action="store",
- dest="platform",
- metavar="PLT",
- help=help_str)
help_str = "The target directory the products to be installed to.\n"
help_str += "When used this parameter overrides the default target directory "
help_str += "defined in the configuration xml file."
dest="target_dir",
metavar="DIR",
help=help_str)
- help_str = "The directory to be used for temporary files.\n"
- help_str += "When used this parameter overrides the default temporary directory "
- help_str += "defined in the configuration xml file."
- opt_parser.add_option("-t",
- "--tmp",
- action="store",
- dest="tmp_dir",
- metavar="DIR",
- help=help_str)
- help_str = "Force all products to be installed from sources \n"
- help_str += "including SALOME modules.\n"
- help_str += "If this option is used all the default installation modes are ignored."
- opt_parser.add_option("-a",
- "--all-from-sources",
- action="store_true",
- dest="force_sources",
- default=False,
- help=help_str)
- help_str = "Install all SALOME binaries packages to one directory.\n"
- help_str += "This option is ignored when --all-from-sources (-a) option is used."
- opt_parser.add_option("-s",
- "--single-directory",
- action="store_true",
- dest="single_dir",
- default=False,
- help=help_str)
help_str = "Prints version information and quits."
opt_parser.add_option("-v",
"--version",
os.system(cmd)
print ""
sys.exit(0)
- return [options.xmlfile, options.target_dir, options.tmp_dir, options.gui, options.force_sources, options.single_dir, options.platform]
+ return [options.xmlfile, options.target_dir, options.gui]
#=================================================================
# strip : removes spaces at the beginning and at the end of the
# check_disk_space : checks the disk space;
# quits if there is no enough disk space
#===============================================================
-def check_disk_space(products, scripts_dir, target_dir, tmp_dir, is_force_src=False):
+def check_disk_space(products, scripts_dir, target_dir):
"""
Checks if there is enough disk space to install products.
Quits with error if there is no enough disk space.
f = open(filename)
lines = f.readlines()
f.close()
- # ---
- regvar = re.compile("(.*)\s+[^\s]*[R|r]elease[^\s]*\s+([\d.]*)")
+ # --- = re.compile("(.*)\s+[^\s]*[R|r]elease[^\s]*\s+([\d.]*)")
regvar1 = re.compile("(.*)\s+[^\s]*[L|l][I|i][N|n][U|u][X|x][^\s]*(.*)\s+([\d.]*)\s+")
for l in lines:
res = re.search(regvar, l)
#------------------------------------------------------------------#
if __name__ == "__main__":
+ # get program dir
+ cur_dir = get_program_path()
# parse command line
- [xml_file, target_dir, tmp_dir, is_gui, is_force_src, is_single_dir, pltname] = parse_parameters()
+ [xml_file, target_dir, is_gui] = parse_parameters()
if xml_file: xml_file = os.path.abspath(xml_file)
+ else: xml_file = os.path.join(cur_dir, "config.xml")
if target_dir: target_dir = os.path.abspath(target_dir)
- if tmp_dir: tmp_dir = os.path.abspath(tmp_dir)
- # get program dir
- cur_dir = get_program_path()
#---- GUI ----------------
cmd = "./bin/SALOME_InstallWizard"
if xml_file is not None:
cmd += " --file %s"%xml_file
- if pltname is not None:
- cmd += " --platform %s"%pltname
if target_dir is not None:
cmd += " --target %s"%target_dir
- if tmp_dir is not None:
- cmd += " --tmp %s"%tmp_dir
- if is_force_src:
- cmd += " --all-from-sources"
- if is_single_dir:
- cmd += " --single-directory"
cmd += "&"
sys.exit(os.system(cmd))
#----- TUI ---------------------
#
- # define xml file to be used
- #
- # get current Linux platform
- plt_name, plt_ver, plt_arch = get_os_release()
- data = []
- for i in plt_name, plt_ver, plt_arch:
- if i: data.append(i)
- full_plt_name = " ".join(data)
- # get all supported platforms
- all_platforms = get_supported_platforms(xml_file)
- if all_platforms:
- if pltname:
- # platform name is specified in the command line
- if pltname in all_platforms:
- # if specified platform is supported, choose the corresponding XML file for use
- xml_file = all_platforms[pltname]
- else:
- # if specified platform is NOT supported, print warning message
- # and prompt user to choose another platform
- msg = "Specified platform is not supported: %s" % (pltname)
- warning(msg)
- pltname, xml_file = select_platform(all_platforms)
- pass
- pass
- elif full_plt_name in all_platforms:
- # if current platform is supported, choose the corresponding XML file for use
- pltname = full_plt_name
- xml_file = all_platforms[pltname]
- else:
- if xml_file and len(all_platforms) == 1:
- # XML file is specified and contains only one platform definition
- xml_file = all_platforms.values()[0]
- pltname = all_platforms.keys()[0]
- else:
- # current Linux platform is not supported, print warning message
- # and prompt user to choose platform from the list
- warning("Not supported Linux platform: %s."%" ".join(data))
- pltname, xml_file = select_platform(all_platforms)
- pass
- pass
- else:
- # current Linux platform is not supported, exit
- if pltname:
- msg = "Not supported Linux platform: %s."%pltname
- else:
- msg = "Not supported Linux platform: %s."%" ".join(data)
- error_exit(msg, False)
- pass
-
+ # check XML file
+ check_xml_file(xml_file)
# parse XML file -----------
message("Parsing XML configuration file: %s"%xml_file)
- parser = ConfigParser(is_force_src, pltname)
+ parser = ConfigParser()
parser.parse(xml_file)
# source directory map
- bin_dir = ""
- if parser.config.platforms:
- bin_dir += "/%s"%"_".join( parser.pltname.split() )
- subdir = { __BINARIES__ : "BINARIES" + bin_dir,
- __BUILDSRC__ : "SOURCES",
- __PREINSTALL__ : ""}
+ subdir = { __BUILDSRC__ : "SOURCES" }
# check scripts directory -----------
scripts_dir = "%s/%s"%(cur_dir, "config_files")
if not os.access(target_dir, os.W_OK) :
error_exit("There is no write permissions for the directory: " + target_dir)
- # check/create temporary dir -----------
- if tmp_dir is None:
- tmp_dir = parser.config.tmpdir
- if not tmp_dir:
- tmp_dir = "/tmp"
- tmp_dir = substituteVars(tmp_dir)
- tmp_dir = get_tmp_dir(tmp_dir)
-
- message("Creating temporary directory: " + tmp_dir)
- root_path = create_dir(tmp_dir, 0755)
-
- if not os.path.exists(tmp_dir):
- error_exit("Invalid temporary directory: " + tmp_dir)
-
- if not os.access(tmp_dir, os.W_OK) :
- error_exit("There is no write permissions for the directory: " + tmp_dir)
-
# check available disk space -----------
message("Checking available disk space")
- check_disk_space(parser.products, scripts_dir, target_dir, tmp_dir, is_force_src)
+ check_disk_space(parser.products, scripts_dir, target_dir)
# change current directory -----------
os.chdir(scripts_dir)
# get dependencies list -----------
- list_of_dep = get_dependencies(parser.products)
products_string = " ".join(parser.full_prods_list)
# don't remove sources and tmp files, by default -----------
# install products -----------
for product in parser.products:
- # remove only prerequisites temporary files
- if product.type == __CTX__PREREQUISITE__ or \
- (product.type == __CTX__COMPONENT__ and product.whattodo == __BUILDSRC__):
- rm_src_tmp = "TRUE"
message("... processing %s ..."%product.name)
- cmd = '%s/%s %s %s %s/%s %s "%s" %s "%s" %s/%s %s %s/%s' % (
+ cmd = '%s/%s %s %s/%s %s "%s" %s "%s" %s/%s' % (
scripts_dir, product.script,
product.whattodo,
- tmp_dir,
source_dir, subdir[product.whattodo],
target_dir,
products_string,
product.name,
products_string,
source_dir, subdir[__BUILDSRC__],
- rm_src_tmp,
- source_dir, subdir[__BINARIES__]
)
- # install all modules with GUI
- if product.woguiinst is not None and product.woguiinst != "":
- cmd += ' TRUE'
- # use single directory or not
- if product.whattodo == __BINARIES__ and product.type == __CTX__COMPONENT__ and is_single_dir:
- cmd += ' TRUE'
res = os.system(cmd)
- rm_src_tmp = "FALSE"
pass
- # modify *.la files, if --single-directory option was -----------
- if is_single_dir:
- message("Modifying of *.la files of SALOME modules...")
- cmd = '%s/modifyLaFiles.sh modify_la_files %s' % (scripts_dir, target_dir)
- res = os.system(cmd)
-
- # pickup environment -----------
- message("Creating environment files")
- for product in parser.products :
- if check_bool(product.pickupEnv):
- cmd = '%s/%s pickup_env %s %s/%s %s "%s" %s "%s" %s/%s %s %s/%s' % (
- scripts_dir, product.script,
- tmp_dir,
- source_dir, subdir[product.whattodo],
- target_dir,
- products_string,
- product.name,
- products_string,
- source_dir, subdir[__BUILDSRC__],
- rm_src_tmp,
- source_dir, subdir[__BINARIES__]
- )
- # install all modules with GUI
- if product.woguiinst is not None and product.woguiinst != "":
- cmd += ' TRUE'
- # use single directory or not
- if product.whattodo == __BINARIES__ and product.type == __CTX__COMPONENT__ and is_single_dir:
- cmd += ' TRUE'
- res = os.system(cmd)
- pass
- pass
-
- # clean temporary directory -----------
- message("Cleaning temporary directory")
- clean_all()
-
# finishing -----------
message("Finished!")
pass