]> SALOME platform Git repositories - tools/install.git/blobdiff - runInstall
Salome HOME
To print user friendly message at Python modules import error.
[tools/install.git] / runInstall
index bb730125a33213e2d7535e9e4c3dd3581d674ae0..80a3ddd3eaa2abb0b7a1383929c4c64d0dde8f97 100755 (executable)
@@ -12,16 +12,21 @@ Copyright : 2002-2008 CEA
 
 __version__ = "1.1.5"
 
 
 __version__ = "1.1.5"
 
+# --- imports --- #
+import sys
+try:
+    import xml.sax, xml.dom.minidom
+    import os, re
+    import types
+    import random
+    import warnings
+except Exception, an_exc:
+    sys.exit("Error: %s! Please check the installed Python package." % str(an_exc))
+    pass
+
 # --- avoid "deprecation" warnings --- #
 # --- avoid "deprecation" warnings --- #
-import warnings
 warnings.filterwarnings("ignore", "", DeprecationWarning)
 
 warnings.filterwarnings("ignore", "", DeprecationWarning)
 
-# --- imports --- #
-import xml.sax, xml.dom.minidom
-import sys, os, re
-import types
-import random
-
 # --- global variables --- #
 opt_parser = None
 root_path  = None
 # --- global variables --- #
 opt_parser = None
 root_path  = None
@@ -374,16 +379,12 @@ class Config :
                  theCaption   = None,
                  theCopyright = None,
                  theLicense   = None,
                  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.version   = strip(theVersion)
         self.caption   = strip(theCaption)
         self.copyright = strip(theCopyright)
         self.license   = strip(theLicense)
-        self.platforms = strip(thePlatforms)
         self.targetdir = strip(theTargetdir)
         self.targetdir = strip(theTargetdir)
-        self.tmpdir    = strip(theTmpdir)
 
 #==============================================================
 # class Product : pre-requisite product options
 
 #==============================================================
 # class Product : pre-requisite product options
@@ -401,23 +402,19 @@ class Product :
     def __init__(self,
                  theName,
                  theType               = None,
     def __init__(self,
                  theName,
                  theType               = None,
-                 theOS                 = None,
                  theVersion            = None,
                  theDependencies       = None,
                  theVersion            = None,
                  theDependencies       = None,
-                 theWoGuiInstallation  = None,
                  theInstalldiskspace   = None,
                  theScript             = None,
                  thePickUpEnvironment  = None):
         self.name               = strip(theName)
         self.type               = strip(theType)
                  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.version            = strip(theVersion)
         self.dependencies       = strip(theDependencies)
-        self.woguiinst          = strip(theWoGuiInstallation)
         self.installdiskspace   = strip(theInstalldiskspace)
         self.script             = strip(theScript)
         self.pickupEnv          = strip(thePickUpEnvironment)
         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__]:
         
     def setMode(self, mode):
         if mode not in [__BINARIES__, __BUILDSRC__, __PREINSTALL__]:
@@ -432,13 +429,12 @@ class ConfigParser:
     """
     XML configuration files parser
     """
     """
     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.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):
         pass
         
     def parse_config(self):
@@ -449,16 +445,14 @@ class ConfigParser:
                              configElem.getAttribute('caption').strip(),
                              configElem.getAttribute('copyright').strip(),
                              configElem.getAttribute('license').strip(),
                              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 = {}
         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()
         depsElem = self.docElem.getElementsByTagName('dependencies')[0]
         for prodElem in depsElem.getElementsByTagName('product'):
             prodName = prodElem.getAttribute('name').strip()
@@ -493,16 +487,10 @@ class ConfigParser:
             if prodName in depsMap: depsList = depsMap[prodName]
             aProduct = Product(prodName,
                                prodElem.getAttribute('type').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('version').strip(),
                                depsList,
-                               instElem.getAttribute('woguimode').strip(),
                                instElem.getAttribute('installdiskspace').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 -----------
             if prodElem.getAttribute('type').strip() == "component":
                 sal_prods_list.append(aProduct)
                 # fill an ordered modules list -----------
@@ -513,27 +501,10 @@ class ConfigParser:
                 req_prods_list.append(aProduct)
                 # fill an ordered prerequisites list -----------
                 prereqs_list.append(prodName)
                 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 )
                 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
         self.full_prods_list.extend( prereqs_list )
         self.full_prods_list.extend( modules_list )
         pass
@@ -674,25 +645,14 @@ def parse_parameters():
                           dest="gui",
                           help=help_str)
     help_str  = "The configuration xml file.\n"
                           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)
     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."
     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."
@@ -702,32 +662,6 @@ def parse_parameters():
                           dest="target_dir",
                           metavar="DIR",
                           help=help_str)
                           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",
     help_str  = "Prints version information and quits."
     opt_parser.add_option("-v",
                           "--version",
@@ -752,7 +686,7 @@ def parse_parameters():
         os.system(cmd)
         print ""
         sys.exit(0)
         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 
 
 #=================================================================
 # strip : removes spaces at the beginning and at the end of the 
@@ -873,7 +807,7 @@ def check_dir(dir):
 # check_disk_space : checks the disk space;
 #                    quits if there is no enough disk space
 #===============================================================
 # 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.
     """
     Checks if there is enough disk space to install products.
     Quits with error if there is no enough disk space.
@@ -975,8 +909,7 @@ def get_os_release():
         f = open(filename)
         lines = f.readlines()
         f.close()
         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)
         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)
@@ -1100,13 +1033,13 @@ def select_platform(all_platforms):
 #------------------------------------------------------------------#
 
 if __name__ == "__main__":
 #------------------------------------------------------------------#
 
 if __name__ == "__main__":
+    # get program dir
+    cur_dir = get_program_path()
     # parse command line
     # 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)
     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 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 ----------------
 
 
     #---- GUI ----------------
 
@@ -1123,82 +1056,22 @@ if __name__ == "__main__":
         cmd = "./bin/SALOME_InstallWizard"
         if xml_file is not None:
             cmd += " --file %s"%xml_file
         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 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 ---------------------
     #
         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)
     # 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
     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")
 
     # check scripts directory -----------
     scripts_dir = "%s/%s"%(cur_dir, "config_files")
@@ -1232,32 +1105,14 @@ if __name__ == "__main__":
     if not os.access(target_dir, os.W_OK) :
         error_exit("There is no write permissions for the directory: " + target_dir)
 
     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 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 -----------
 
     # 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 -----------
     products_string = " ".join(parser.full_prods_list)
 
     # don't remove sources and tmp files, by default -----------
@@ -1268,70 +1123,20 @@ if __name__ == "__main__":
     
     # install products -----------
     for product in parser.products:
     
     # 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)
         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,
             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__],
             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)
         res = os.system(cmd)
-        rm_src_tmp = "FALSE"
         pass
 
         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
     # finishing -----------
     message("Finished!")
     pass