4 Installation Wizard launching script.
6 This script is the part of the SALOME installation procedure.
7 Author : Vadim SANDLER, Open CASCADE SAS (vadim.sandler@opencascade.com)
8 Created : Thu Dec 18 12:01:00 2002
9 Copyright : 2002-2008 CEA
15 # --- avoid "deprecation" warnings --- #
17 warnings.filterwarnings("ignore", "", DeprecationWarning)
20 import xml.sax, xml.dom.minidom
25 # --- global variables --- #
29 # --- actions definition --- #
30 __BINARIES__ = "install_binary"
31 __BUILDSRC__ = "install_source_and_build"
32 __PREINSTALL__ = "try_preinstalled"
34 # --- product type definition --- #
35 __CTX__COMPONENT__ = "component"
36 __CTX__PREREQUISITE__ = "prerequisite"
38 #------------------------------------------------------------------#
40 # COMMAND LINE ARGUMENTS PARSER #
42 #------------------------------------------------------------------#
44 #===================================================================
45 # class OptBaseError : base parse error
46 #===================================================================
47 class OptBaseError(Exception):
49 Base option parsing exception class
51 def __init__(self, msg):
56 #===================================================================
57 # class OptError : bad option error
58 #===================================================================
59 class OptError(OptBaseError):
61 Bad option exception class
63 def __init__ (self, msg, option):
69 if self.option.short_opt and self.option.long_opt:
70 opt_prs = "%s/%s"%(self.option.short_opt,self.option.long_opt)
71 elif self.option.short_opt:
72 opt_prs = "%s"%(self.option.short_opt)
73 elif self.option.long_opt:
74 opt_prs = "%s"%(self.option.long_opt)
75 return "option %s: %s"%(opt_prs, self.msg)
78 #===================================================================
79 # class ArgError : bad option argument error
80 #===================================================================
81 class ArgError(OptBaseError):
83 Bad argument exception class
87 #===================================================================
88 # class ValError : bad command line parameter error
89 #===================================================================
90 class ValError(OptBaseError):
92 Bad parameter exception class
96 #===================================================================
97 # class ArgOption : command line option
98 #===================================================================
103 attrs = ["short_opt", "long_opt", "dest", "action", "type", "default", "metavar", "help"]
104 actions = ["store", "store_true", "store_false"]
105 types = ["string", "int", "float", "bool"]
106 def __init__(self, *args, **kwargs):
108 for attr in self.attrs: setattr(self, attr, None)
110 for i in range(len(args)):
111 if i > len(self.attrs)-1:
112 msg = "Wrong number of parameters is given (maximum is %d)" % len(self.attrs)
113 raise OptBaseError(msg)
114 setattr(self, self.attrs[i], args[i])
116 if arg not in self.attrs:
117 msg = "Invalid argument: %s" % arg
118 raise OptBaseError(msg)
119 setattr(self, arg, kwargs[arg])
120 # check short option key
121 if self.short_opt and \
122 not re.match("^-[a-zA-Z]$",self.short_opt):
123 msg = "invalid short option key; "
124 msg += "should be of the form -x (x is letter)"
125 raise OptError(msg, self)
126 # check long option key
127 if self.long_opt and \
128 not re.match("^--[a-zA-Z][a-zA-Z0-9]*(-[a-zA-Z0-9]+)*$",self.long_opt):
129 msg = "invalid long option key; "
130 msg += "should be of the form --word[[-word]...] "
131 msg += "(word is letters and digits sequence)"
132 raise OptError(msg, self)
133 # check that at least one option key is defined
134 if not self.short_opt and not self.long_opt:
135 msg = "invalid option; neither short nor long option key is defined"
136 raise OptError(msg, self)
138 if not self.dest and self.long_opt:
139 self.dest = self.long_opt[2:].replace('-','_')
140 if not self.dest and self.short_opt:
141 self.dest = self.short_opt[1:]
144 self.action = "store"
145 if self.action not in self.actions:
146 msg = "invalid action: %s" % self.action
147 raise OptError(msg, self)
150 if self.action in ["store_true","store_false"]: self.type = "bool"
151 else: self.type = "string"
152 if self.type not in self.types:
153 msg = "invalid type: %s" % self.type
154 raise OptError(msg, self)
155 if self.action in ["store_true","store_false"] and self.type != "bool":
156 msg = "invalid type: %s : should be 'bool' or None" % self.type
157 raise OptError(msg, self)
159 if self.default is not None:
161 if self.type == "string": self.default = str(self.default)
162 if self.type == "int": self.default = int(self.default)
163 if self.type == "float": self.default = float(self.default)
164 if self.type == "bool": self.default = boolean(self.default)
166 msg = "invalid default value type: should be %s" % self.type
167 raise OptError(msg, self)
171 self.metavar = self.dest.upper()
179 Returns string representation of the option
183 if opt and self.action == "store" and self.metavar: opt += " %s" % self.metavar
184 if opt: opts.append(opt)
186 if opt and self.action == "store" and self.metavar: opt += "=%s" % self.metavar
187 if opt: opts.append(opt)
188 return (", ").join(opts)
190 #===================================================================
191 # class Values : resulting option values
192 #===================================================================
200 #===================================================================
201 # class ArgParser : command line arguments parser
202 #===================================================================
205 Arguments parser class
211 def add_option(self, *args, **kwargs):
212 """Register an option"""
213 o = ArgOption(*args, **kwargs)
214 self._check_option(o)
215 self.options.append(o)
218 def parse_args(self, args = None):
219 """Parse an arguments"""
220 if not args: args = sys.argv[1:]
222 for o in self.options:
223 if o.default is not None:
224 setattr(values, o.dest, o.default)
225 elif not hasattr(values,o.dest):
226 setattr(values, o.dest, None)
228 (values, args) = self._process_args(values, args)
229 except (ArgError, ValError), e:
232 return (values, args)
234 def print_usage(self):
236 print "usage: %s [options]" % os.path.basename(sys.argv[0])
239 def print_help(self):
244 _maxwidth, _indent = 79, 2
245 if len(self.options):
246 for option in self.options:
247 if olen < len(option.to_string()): olen = len(option.to_string())
249 for option in self.options:
251 for hs in option.help.split("\n"):
254 if len("%s %s" % (s,w)) > _maxwidth:
255 strings.append(s.strip()); s = ""
257 if s.strip(): strings.append(s.strip())
258 if not strings: strings[:0] = [""]
259 print "%s%s%s" % (option.to_string(), " "*(_indent+olen-len(option.to_string())), strings[0])
260 for i in range(1, len(strings)):
261 print "%s%s" % (" "*(olen+_indent), strings[i])
264 def _check_option(self, option):
265 o = self._get_option(option.short_opt)
266 if not o: o = self._get_option(option.long_opt)
268 msg = "option conflicts with previously defined option(s)"
269 raise OptError(msg, option)
272 def _get_option(self, opt_key):
274 for o in self.options:
275 if opt_key in [o.short_opt, o.long_opt]: return o
278 def _error(self, msg):
280 sys.exit("\n%s: error: %s\n" % (os.path.basename(sys.argv[0]), msg))
283 def _check_value(self, option, value):
284 o = self._get_option(option)
286 if o.type == "string": return str(value)
287 if o.type == "int": return int(value)
288 if o.type == "float": return float(value)
289 if o.type == "bool": return boolean(value)
291 msg = "invalid value type for option %s: %s; " % (option, value)
292 msg += "should be %s" % o.type
294 raise OptBaseError("unknown error")
296 def _process_args(self, values, args):
300 for index in range(len(args)):
302 if cur_opt and cur_opt[1].action == "store":
303 setattr(values, cur_opt[1].dest, self._check_value(cur_opt[0], a))
307 rargs = args[index+1:]
309 elif re.match("^-[a-zA-Z].*", a):
310 for i in range(1,len(a)):
311 if cur_opt and cur_opt[1].action == "store":
312 setattr(values, cur_opt[1].dest, self._check_value(cur_opt[0], a[i:]))
315 o = self._get_option("-%s"%a[i])
317 raise ArgError("no such option: -%s"%a[i])
318 if o.action == "store_true":
319 setattr(values, o.dest, True)
320 elif o.action == "store_false":
321 setattr(values, o.dest, False)
323 cur_opt = ("-%s"%a[i], o)
325 elif re.match("^--[a-zA-Z][a-zA-Z0-9]*(-[a-zA-Z0-9]+)*", a):
326 oname = ("%s="%a).split("=")[0]
327 ovalue = ("%s="%a).split("=")[1]
328 o = self._get_option(oname)
330 raise ArgError("no such option: %s" % oname)
331 if o.action == "store_true":
333 raise ValError("option %s does not take a value" % oname)
334 setattr(values, o.dest, True)
335 elif o.action == "store_false":
337 raise ValError("option %s does not take a value" % oname)
338 setattr(values, o.dest, False)
341 setattr(values, o.dest, self._check_value(oname, ovalue))
345 elif a.startswith("-"):
346 raise ArgError("bad formatted option: %s" % a)
350 if cur_opt and cur_opt[1].action == "store":
351 raise ValError("option %s requires value" % cur_opt[0])
352 return (values, rargs)
354 #------------------------------------------------------------------#
356 # XML CONFIGURATION FILES PARSER #
358 #------------------------------------------------------------------#
360 #===================================================================
361 # class Config : general configuration options : version, target and
362 # temporary directories, etc...
363 #===================================================================
366 General configuration file options:
367 - Install Wizard window caption
368 - SALOME platform version
369 - Copyright and license info
370 - Default target and temporary directories
380 self.version = strip(theVersion)
381 self.caption = strip(theCaption)
382 self.copyright = strip(theCopyright)
383 self.license = strip(theLicense)
384 self.platforms = strip(thePlatforms)
385 self.targetdir = strip(theTargetdir)
386 self.tmpdir = strip(theTmpdir)
388 #==============================================================
389 # class Product : pre-requisite product options
390 #==============================================================
395 - target Linux OS version
397 - required disk space
398 - installation script
406 theDependencies = None,
407 theWoGuiInstallation = None,
408 theInstalldiskspace = None,
410 thePickUpEnvironment = None):
411 self.name = strip(theName)
412 self.type = strip(theType)
413 self.os = strip(theOS)
414 self.version = strip(theVersion)
415 self.dependencies = strip(theDependencies)
416 self.woguiinst = strip(theWoGuiInstallation)
417 self.installdiskspace = strip(theInstalldiskspace)
418 self.script = strip(theScript)
419 self.pickupEnv = strip(thePickUpEnvironment)
420 self.whattodo = __BINARIES__
422 def setMode(self, mode):
423 if mode not in [__BINARIES__, __BUILDSRC__, __PREINSTALL__]:
428 #===================================================================
429 # class ConfigParser : XML files parser implementation
430 #===================================================================
433 XML configuration files parser
435 def __init__(self, is_force_src=False):
437 self.products = list()
438 self.full_prods_list = list()
440 self.is_force_src = is_force_src
443 def parse_config(self):
444 # Parse 'config' part of the XML file
445 configElem = self.docElem.getElementsByTagName('config')[0]
447 self.config = Config(configElem.getAttribute('version').strip(),
448 configElem.getAttribute('caption').strip(),
449 configElem.getAttribute('copyright').strip(),
450 configElem.getAttribute('license').strip(),
451 configElem.getAttribute('platforms').strip(),
452 configElem.getAttribute('targetdir').strip(),
453 configElem.getAttribute('tempdir').strip())
456 def parse_dependencies(self):
457 # Parse 'dependencies' part of the XML file
459 depsElem = self.docElem.getElementsByTagName('dependencies')[0]
460 for prodElem in depsElem.getElementsByTagName('product'):
461 prodName = prodElem.getAttribute('name').strip()
462 if not prodName: continue
464 for depElem in prodElem.getElementsByTagName('dep'):
465 depsList.append(depElem.firstChild.data)
467 depsMap[prodName] = depsList
471 def parse_product(self):
472 # Parse 'products' part of the XML file
473 depsMap = self.parse_dependencies()
474 prodsElem = self.docElem.getElementsByTagName('products')[0]
475 sal_prods_list = list(); req_prods_list = list()
476 modules_list = list(); prereqs_list = list()
477 for prodElem in prodsElem.getElementsByTagName('product'):
478 prodName = prodElem.getAttribute('name').strip()
479 if not prodName: continue
480 instElem = prodElem.getElementsByTagName('installation')[0]
481 if check_bool(str(instElem.getAttribute('disable').strip())): continue
483 if prodName in depsMap: depsList = depsMap[prodName]
484 aProduct = Product(prodName,
485 prodElem.getAttribute('type').strip(),
486 instElem.getAttribute('os').strip(),
487 instElem.getAttribute('version').strip(),
489 instElem.getAttribute('woguimode').strip(),
490 instElem.getAttribute('installdiskspace').strip(),
491 instElem.getAttribute('script').strip(),
492 instElem.getAttribute('pickupenv').strip())
493 if self.is_force_src:
494 aProduct.setMode(__BUILDSRC__)
496 if prodElem.getAttribute('type').strip() == "component":
497 sal_prods_list.append(aProduct)
498 # fill an ordered modules list -----------
499 modules_list.append(prodName)
500 modules_list.append(prodName + "_src")
503 req_prods_list.append(aProduct)
504 # fill an ordered prerequisites list -----------
505 prereqs_list.append(prodName)
506 #AKL: prerequisite sources and temp files are removed, by default.
507 # So, there is no need to make sources environment
508 #if aProduct.whattodo == __BUILDSRC__: prereqs_list.append(prodName + "_src")
511 self.products.extend( req_prods_list )
512 self.products.extend( sal_prods_list )
513 if len(self.products) != 0:
514 gcc_product = Product("gcc",
515 __CTX__PREREQUISITE__,
523 gcc_product.setMode(__PREINSTALL__)
524 self.products.insert(0, gcc_product)
525 prereqs_list.insert(0, gcc_product.name)
527 self.full_prods_list.extend( prereqs_list )
528 self.full_prods_list.extend( modules_list )
531 def parse(self, xml_file):
532 filehandle = open(xml_file)
533 sax_parser = xml.sax.make_parser()
534 doc = xml.dom.minidom.parse(filehandle, sax_parser)
537 self.docElem = doc.documentElement
542 def getProduct(self, prod):
543 for product in self.products:
544 if product.name == prod:
549 #------------------------------------------------------------------#
551 # SERVICE FUNCTIONS #
553 #------------------------------------------------------------------#
555 #==============================================================
556 # message: prints diagnostic information
557 #==============================================================
560 Prints diagnostic information.
566 #==============================================================
567 # warning: prints warning
568 #==============================================================
579 #==============================================================
580 # error_exit : prints (optionally) error string, then prints
581 # help information and quits
582 #==============================================================
583 def error_exit(msg = "", print_help = True):
585 Prints (optionally) error string,
586 then prints help information and quits.
588 # print error message
593 # print help information
597 opt_parser.print_help()
605 #==============================================================
606 # boolean : Converts string to boolean value.
607 #==============================================================
610 Converts string to boolean value if possible.
611 Raises exception if wrong string is used.
613 if isinstance(val, types.StringType):
614 if val.strip().lower() in ["true", "yes", "ok"] : return True
615 elif val.strip().lower() in ["false", "no", "cancel"] : return False
616 else: raise TypeError("invalid boolean value")
619 #=================================================================
620 # check_bool : checks boolean value: yes/no, true/false, 1/0
621 #=================================================================
624 Checks boolean value.
632 #==============================================================
633 # clean_all : performs system cleaning before exiting
634 #==============================================================
637 Performs system cleaning before exiting.
640 remove_dir(root_path)
643 #==============================================================
644 # parse_parameters : parses command line arguments
645 #==============================================================
646 def parse_parameters():
648 Parses command line arguments.
651 opt_parser = ArgParser()
653 help_str = "Runs the Installation Wizard in the GUI mode [default].\n"
654 opt_parser.add_option("-g",
660 help_str = "Runs the Installation Wizard in the TUI mode."
661 opt_parser.add_option("-b",
663 action="store_false",
666 help_str = "The configuration xml file.\n"
667 help_str += "If this parameter is missing, then the program tries to define the "
668 help_str += "Linux platform and use the corresponding xml file. For example, "
669 help_str += "for Red Hat 8.0 config_RedHat_8.0.xml file is used in this case. "
670 opt_parser.add_option("-f",
676 help_str = "The target directory the products to be installed to.\n"
677 help_str += "When used this parameter overrides the default target directory "
678 help_str += "defined in the configuration xml file."
679 opt_parser.add_option("-d",
685 help_str = "The directory to be used for temporary files.\n"
686 help_str += "When used this parameter overrides the default temporary directory "
687 help_str += "defined in the configuration xml file."
688 opt_parser.add_option("-t",
694 help_str = "Force all products to be installed from sources \n"
695 help_str += "including SALOME modules.\n"
696 help_str += "If this option is used all the default installation modes are ignored."
697 opt_parser.add_option("-a",
698 "--all-from-sources",
700 dest="force_sources",
703 help_str = "Prints version information and quits."
704 opt_parser.add_option("-v",
708 help_str = "Prints this help and quits."
709 opt_parser.add_option("-h",
713 (options, args) = opt_parser.parse_args()
715 # print help info and quit
716 print "\nSALOME Installation Wizard\n"
717 opt_parser.print_help()
721 # print version info and quit
723 cmd = "./bin/SALOME_InstallWizard --version"
727 return [options.xmlfile, options.target_dir, options.tmp_dir, options.gui, options.force_sources]
729 #=================================================================
730 # strip : removes spaces at the beginning and at the end of the
731 # <param> if it is of string type
732 #=================================================================
735 Removes spaces at the beginning and at the end
736 of the given parameter.
738 if type(param) == types.StringType:
742 #=================================================================
743 # get_dependencies : extract products dependencies
744 #=================================================================
745 def get_dependencies(prods):
747 Gets a list of installed and required products.
750 for product in prods:
751 for dep in product.dependencies:
752 if dep and dep not in prods_list:
753 prods_list.append( dep )
755 if product.whattodo == __BUILDSRC__:
756 dep_name = dep + "_src"
757 if dep_name not in parser.full_prods_list:
758 msg = "Prerequisite '%s' is required for '%s' product,\n"%(dep, product.name)
759 msg += "but the first one is absent in the list of products to be installed!\n"
760 msg += "Please check your XML file."
763 if product.name and product.name not in prods_list:
764 prods_list.append( product.name )
766 return " ".join( prods_list )
768 #==============================================================
769 # create_dir : creates a directory with (optional) permissions,
770 # returns the part of path that existed before
771 # directory creation; exits with error if access
773 #==============================================================
774 def create_dir(directory, access = 0777):
776 Creates a directory with (optional) permissions,
777 returns the part of path that existed before
778 directory creation; exits with error if access
781 dirs = directory.split("/")
786 if len(subdir) == 0: continue
787 dir = "%s/%s"%(dir, subdir)
788 if os.path.exists(dir):
792 os.mkdir(dir, access)
794 error_exit("Can't create directory: %s.\nAccess is denied."%directory)
795 if dir == "%s/%s"%(existing, subdir):
799 #==============================================================
800 # substituteVars : performes environment variables substistution
801 # the given string; if varibale is not defined
802 # it is substituted by the empty string
803 #==============================================================
804 def substituteVars(str):
806 Performes environment variables substistution.
808 str = os.path.expanduser(str)
809 str = os.path.expandvars(str)
812 #================================================================
813 # get_program_path : gets program's directory path
814 # (and performs 'cd' command there)
815 #================================================================
816 def get_program_path():
818 Returns the program directory path
819 (and make this directory current).
821 path = os.path.dirname(sys.argv[0])
826 #================================================================
827 # check_dir : checks directory existence
828 #================================================================
831 Checks directory existence.
833 if (os.path.islink(dir)):
834 realpath = os.path.realpath(dir)
835 if not os.path.exists(realpath):
836 msg = "Invalid link %s.\nThe directory %s a link points to does not exist. Stopped..."%(dir,realpath)
837 error_exit(msg, False)
839 if not os.path.exists(dir):
840 msg = "Directory %s does not exist. Stopped..."%dir
841 error_exit(msg, False)
844 #===============================================================
845 # check_disk_space : checks the disk space;
846 # quits if there is no enough disk space
847 #===============================================================
848 def check_disk_space(products, scripts_dir, target_dir, tmp_dir, is_force_src=False):
850 Checks if there is enough disk space to install products.
851 Quits with error if there is no enough disk space.
855 for product in products:
858 spaces = product.installdiskspace.split(',')
859 prod_space = int( spaces[0] )
860 if product.whattodo == __BINARIES__:
861 prod_space = int( spaces[0] )
862 if product.type == __CTX__COMPONENT__:
863 prod_space += int( spaces[1] )
865 if product.type == __CTX__PREREQUISITE__:
866 prod_space = int( spaces[0] )
868 prod_space = int( spaces[2] )
871 install_space = install_space + prod_space
874 res = os.system("%s/%s %s %d"%(scripts_dir, "checkSize.sh", target_dir, install_space))
876 msg = "There is no enough space to install the products. Stopped..."
877 error_exit(msg, False)
880 #===============================================================
881 # remove_dir : removes temporary directory
882 #===============================================================
883 def remove_dir(path):
885 Removes temporary directory.
887 if path and os.path.exists(path):
888 os.system("rm -rf " + path)
891 #==============================================================
892 # has_binaries : returns True if some product is installed from
894 #===============================================================
895 def has_binaries(products):
897 Returns True if some product is installed in 'binaries' mode.
899 for product in products:
900 if product.whattodo == __BINARIES__:
904 #==============================================================
905 # has_sources : returns True if some product is installed from
907 #===============================================================
908 def has_sources(products):
910 Returns True if some product is installed in 'sources' mode.
912 for product in products:
913 if product.whattodo == __BUILDSRC__:
917 #==============================================================
918 # get_tmp_dir : gets temporary directory name
919 #===============================================================
920 def get_tmp_dir(dir):
922 Gets temporary directory path.
925 dir_prefix="INSTALLWORK"
926 range_bottom = 0; range_top = 999999
927 for i in xrange(max_attempts):
928 tmp_dir = "%s/%s%d"%(dir, dir_prefix, random.randint(range_bottom,range_top))
929 if not os.path.exists( tmp_dir ):
931 return "%s/%s%d"%(dir, dir_prefix, random.randint(range_bottom,range_top))
933 #==============================================================
934 # get_os_release : gets OS release; the OS name, version and
937 # RedHat, 8.0; Mandriva, 2006.0, 64
938 #===============================================================
939 def get_os_release():
940 filename = "/etc/issue"
945 if os.path.exists(filename):
948 lines = f.readlines()
951 regvar = re.compile("(.*)\s+[^\s]*[R|r]elease[^\s]*\s+([\d.]*)")
952 regvar1 = re.compile("(.*)\s+[^\s]*[L|l][I|i][N|n][U|u][X|x][^\s]*(.*)\s+([\d.]*)\s+")
954 res = re.search(regvar, l)
956 res = re.search(regvar1, l)
958 plt_name = "".join("".join(res.groups()[:len(res.groups())-1]).split())
959 # workaround for Mandrake and other platforms
960 plt_name = plt_name.replace("Linux", "").replace("linux", "").replace("LINUX", "").strip()
961 # workaround for SuSe
962 plt_name = plt_name.replace("Welcometo", "").strip()
964 plt_ver = res.group(len(res.groups()))
965 if re.search(r'x86_64', l):
968 # workaround for Red Hat Enterprise
972 if platform.machine() == "x86_64":
983 return plt_name, plt_ver, plt_arch
985 #==============================================================
986 # check_xml_file : checks XML file existence and readability
987 #===============================================================
988 def check_xml_file(xml_file):
990 Checks XML file existence and readability.
992 if not os.path.isfile(xml_file):
993 msg = "Configuration file %s is not found!"%xml_file
994 error_exit(msg, False)
996 if not os.access(xml_file, os.R_OK):
997 msg = "There is no read access for %s file!"%xml_file
998 error_exit(msg, False)
1001 #==============================================================
1002 # get_supported_plts : gets map of supported Linux platforms and
1003 # corresponding configuration files
1004 #===============================================================
1005 def get_supported_platforms(xml_file=None):
1007 Gets map of supported Linux platforms and
1008 corresponding configuration files.
1011 xml_file_list = list()
1013 xml_file_list = [ xml_file ]
1015 entry_list = os.listdir(get_program_path())
1016 for entry in entry_list:
1017 if re.search(r'(.*).xml', entry):
1018 xml_file_list.append(os.path.abspath(entry))
1019 for an_xml_file in xml_file_list: # XML files parsing
1020 check_xml_file(an_xml_file)
1021 filehandle = open(an_xml_file)
1022 data = filehandle.read()
1024 parser = ConfigParser()
1027 if parser.config.platforms is not None:
1028 for plt in parser.config.platforms.split(","):
1029 if not plt or plt in platforms_map.keys(): continue
1030 ## print "plt = %s, xml = %s"%(strip(plt), an_xml_file)
1031 platforms_map[strip(plt)] = an_xml_file
1032 return platforms_map
1034 #------------------------------------------------------------------#
1036 # EXECUTION STARTS HERE #
1038 #------------------------------------------------------------------#
1040 if __name__ == "__main__":
1041 # parse command line
1042 [xml_file, target_dir, tmp_dir, is_gui, is_force_src] = parse_parameters()
1043 if xml_file: xml_file = os.path.abspath(xml_file)
1044 if target_dir: target_dir = os.path.abspath(target_dir)
1045 if tmp_dir: tmp_dir = os.path.abspath(tmp_dir)
1047 cur_dir = get_program_path()
1049 #---- GUI ----------------
1053 if not env.has_key("PATH") :
1055 if not env.has_key("LD_LIBRARY_PATH") :
1056 env["LD_LIBRARY_PATH"] = ""
1058 env["LD_LIBRARY_PATH"] = "./bin/lib:" + ".:" + env["LD_LIBRARY_PATH"]
1059 env["PATH"] = ".:" + env["PATH"]
1061 cmd = "./bin/SALOME_InstallWizard"
1062 if xml_file is not None:
1063 cmd += " --file %s"%xml_file
1064 if target_dir is not None:
1065 cmd += " --target %s"%target_dir
1066 if tmp_dir is not None:
1067 cmd += " --tmp %s"%tmp_dir
1069 cmd += " --all-from-sources"
1071 sys.exit(os.system(cmd))
1073 #----- TUI ---------------------
1075 # define xml file to be used
1077 # get current Linux platform
1078 plt_name = ""; plt_ver = ""; plt_arch = ""
1079 plt_name, plt_ver, plt_arch = get_os_release()
1081 for i in plt_name, plt_ver, plt_arch:
1082 if i: data.append(i)
1083 full_plt_name = "_".join(data)
1084 xml_file_name = "config_%s.xml" % full_plt_name
1085 if not plt_name or not plt_ver or not os.path.exists("%s/%s"%(cur_dir, xml_file_name)):
1086 msg = "Not supported Linux platform: %s!" % full_plt_name
1090 xml_file= "%s/%s"%(cur_dir, xml_file_name)
1093 check_xml_file(xml_file)
1095 # parse XML file -----------
1096 message("Parsing XML configuration file: %s"%xml_file)
1097 parser = ConfigParser(is_force_src)
1098 parser.parse(xml_file)
1100 # source directory map
1102 if parser.config.platforms:
1103 bin_dir += "/%s"%parser.config.platforms
1104 subdir = { __BINARIES__ : "BINARIES" + bin_dir,
1105 __BUILDSRC__ : "SOURCES",
1106 __PREINSTALL__ : ""}
1108 # check scripts directory -----------
1109 scripts_dir = "%s/%s"%(cur_dir, "config_files")
1110 check_dir(scripts_dir)
1112 # check products archives directories -----------
1113 has_bin = has_binaries(parser.products)
1114 has_src = has_sources(parser.products)
1115 source_dir = "%s/%s"%(cur_dir, "Products")
1117 if has_src or has_bin:
1118 check_dir(source_dir)
1121 check_dir("%s/%s"%(source_dir,subdir[__BUILDSRC__]))
1124 check_dir("%s/%s"%(source_dir,subdir[__BINARIES__]))
1126 # check/create target dir -----------
1127 if target_dir is None:
1128 target_dir = parser.config.targetdir
1129 target_dir = substituteVars(target_dir)
1131 message("Creating target directory: " + target_dir)
1132 create_dir(target_dir, 0755)
1134 if not os.path.exists(target_dir):
1135 error_exit("Invalid target directory: " + target_dir)
1137 if not os.access(target_dir, os.W_OK) :
1138 error_exit("There is no write permissions for the directory: " + target_dir)
1140 # check/create temporary dir -----------
1142 tmp_dir = parser.config.tmpdir
1145 tmp_dir = substituteVars(tmp_dir)
1146 tmp_dir = get_tmp_dir(tmp_dir)
1148 message("Creating temporary directory: " + tmp_dir)
1149 root_path = create_dir(tmp_dir, 0755)
1151 if not os.path.exists(tmp_dir):
1152 error_exit("Invalid temporary directory: " + tmp_dir)
1154 if not os.access(tmp_dir, os.W_OK) :
1155 error_exit("There is no write permissions for the directory: " + tmp_dir)
1157 # check available disk space -----------
1158 message("Checking available disk space")
1159 check_disk_space(parser.products, scripts_dir, target_dir, tmp_dir, is_force_src)
1161 # change current directory -----------
1162 os.chdir(scripts_dir)
1164 # get dependencies list -----------
1165 list_of_dep = get_dependencies(parser.products)
1166 products_string = " ".join(parser.full_prods_list)
1168 # don't remove sources and tmp files, by default -----------
1169 rm_src_tmp = "FALSE"
1171 # starting -----------
1172 message("Starting ...")
1174 # install products -----------
1175 for product in parser.products:
1176 # remove only prerequisites temporary files
1177 if product.type == __CTX__PREREQUISITE__ or \
1178 (product.type == __CTX__COMPONENT__ and product.whattodo == __BUILDSRC__):
1180 message("... processing %s ..."%product.name)
1181 cmd = '%s/%s %s %s %s/%s %s "%s" %s "%s" %s/%s %s %s/%s' % (
1182 scripts_dir, product.script,
1185 source_dir, subdir[product.whattodo],
1190 source_dir, subdir[__BUILDSRC__],
1192 source_dir, subdir[__BINARIES__]
1194 if product.woguiinst is not None and product.woguiinst != "": cmd += ' TRUE'
1195 res = os.system(cmd)
1196 rm_src_tmp = "FALSE"
1199 # pickup environment -----------
1200 message("Creating environment files")
1201 for product in parser.products :
1202 if check_bool(product.pickupEnv):
1203 cmd = '%s/%s pickup_env %s %s/%s %s "%s" %s "%s" %s/%s %s %s/%s' % (
1204 scripts_dir, product.script,
1206 source_dir, subdir[product.whattodo],
1211 source_dir, subdir[__BUILDSRC__],
1213 source_dir, subdir[__BINARIES__]
1215 if product.woguiinst is not None and product.woguiinst != "": cmd += ' TRUE'
1216 res = os.system(cmd)
1220 # clean temporary directory -----------
1221 message("Cleaning temporary directory")
1224 # finishing -----------
1225 message("Finished!")