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-2007 CEA
15 # --- avoid "deprecation" warnings --- #
17 warnings.filterwarnings("ignore", "", DeprecationWarning)
25 # --- global variables --- #
29 # --- XML tags definition --- #
30 __TAG__SOURCES__ = "install sources"
31 __TAG__BINARIES__ = "install binaries"
32 __TAG__NATIVE__ = "use native"
33 __TAG__PREINSTALL__ = "not install"
34 __TAG__BUILDSRC__ = "build sources"
36 # --- product context definition --- #
37 __CTX__SALOME__SRC__ = "salome sources"
38 __CTX__SALOME__BIN__ = "salome binaries"
39 __CTX__PREREQUISITE__ = "prerequisite"
41 #------------------------------------------------------------------#
43 # COMMAND LINE ARGUMENTS PARSER #
45 #------------------------------------------------------------------#
47 #===================================================================
48 # class OptBaseError : base parse error
49 #===================================================================
50 class OptBaseError(Exception):
52 Base option parsing exception class
54 def __init__(self, msg):
59 #===================================================================
60 # class OptError : bad option error
61 #===================================================================
62 class OptError(OptBaseError):
64 Bad option exception class
66 def __init__ (self, msg, option):
72 if self.option.short_opt and self.option.long_opt:
73 opt_prs = "%s/%s"%(self.option.short_opt,self.option.long_opt)
74 elif self.option.short_opt:
75 opt_prs = "%s"%(self.option.short_opt)
76 elif self.option.long_opt:
77 opt_prs = "%s"%(self.option.long_opt)
78 return "option %s: %s"%(opt_prs, self.msg)
81 #===================================================================
82 # class ArgError : bad option argument error
83 #===================================================================
84 class ArgError(OptBaseError):
86 Bad argument exception class
90 #===================================================================
91 # class ValError : bad command line parameter error
92 #===================================================================
93 class ValError(OptBaseError):
95 Bad parameter exception class
99 #===================================================================
100 # class ArgOption : command line option
101 #===================================================================
106 attrs = ["short_opt", "long_opt", "dest", "action", "type", "default", "metavar", "help"]
107 actions = ["store", "store_true", "store_false"]
108 types = ["string", "int", "float", "bool"]
109 def __init__(self, *args, **kwargs):
111 for attr in self.attrs: setattr(self, attr, None)
113 for i in range(len(args)):
114 if i > len(self.attrs)-1:
115 msg = "Wrong number of parameters is given (maximum is %d)" % len(self.attrs)
116 raise OptBaseError(msg)
117 setattr(self, self.attrs[i], args[i])
119 if arg not in self.attrs:
120 msg = "Invalid argument: %s" % arg
121 raise OptBaseError(msg)
122 setattr(self, arg, kwargs[arg])
123 # check short option key
124 if self.short_opt and \
125 not re.match("^-[a-zA-Z]$",self.short_opt):
126 msg = "invalid short option key; "
127 msg += "should be of the form -x (x is letter)"
128 raise OptError(msg, self)
129 # check long option key
130 if self.long_opt and \
131 not re.match("^--[a-zA-Z][a-zA-Z0-9]*(-[a-zA-Z0-9]+)*$",self.long_opt):
132 msg = "invalid long option key; "
133 msg += "should be of the form --word[[-word]...] "
134 msg += "(word is letters and digits sequence)"
135 raise OptError(msg, self)
136 # check that at least one option key is defined
137 if not self.short_opt and not self.long_opt:
138 msg = "invalid option; neither short nor long option key is defined"
139 raise OptError(msg, self)
141 if not self.dest and self.long_opt:
142 self.dest = self.long_opt[2:].replace('-','_')
143 if not self.dest and self.short_opt:
144 self.dest = self.short_opt[1:]
147 self.action = "store"
148 if self.action not in self.actions:
149 msg = "invalid action: %s" % self.action
150 raise OptError(msg, self)
153 if self.action in ["store_true","store_false"]: self.type = "bool"
154 else: self.type = "string"
155 if self.type not in self.types:
156 msg = "invalid type: %s" % self.type
157 raise OptError(msg, self)
158 if self.action in ["store_true","store_false"] and self.type != "bool":
159 msg = "invalid type: %s : should be 'bool' or None" % self.type
160 raise OptError(msg, self)
164 if self.type == "string": self.default = str(self.default)
165 if self.type == "int": self.default = int(self.default)
166 if self.type == "float": self.default = float(self.default)
167 if self.type == "bool": self.default = boolean(self.default)
169 msg = "invalid default value type: should be %s" % self.type
170 raise OptError(msg, self)
174 self.metavar = self.dest.upper()
182 Returns string representation of the option
186 if opt and self.action == "store" and self.metavar: opt += " %s" % self.metavar
187 if opt: opts.append(opt)
189 if opt and self.action == "store" and self.metavar: opt += "=%s" % self.metavar
190 if opt: opts.append(opt)
191 return (", ").join(opts)
193 #===================================================================
194 # class Values : resulting option values
195 #===================================================================
203 #===================================================================
204 # class ArgParser : command line arguments parser
205 #===================================================================
208 Arguments parser class
214 def add_option(self, *args, **kwargs):
215 """Register an option"""
216 o = ArgOption(*args, **kwargs)
217 self._check_option(o)
218 self.options.append(o)
221 def parse_args(self, args = None):
222 """Parse an arguments"""
223 if not args: args = sys.argv[1:]
225 for o in self.options:
227 setattr(values, o.dest, o.default)
228 elif not hasattr(values,o.dest):
229 setattr(values, o.dest, None)
231 (values, args) = self._process_args(values, args)
232 except (ArgError, ValError), e:
235 return (values, args)
237 def print_usage(self):
239 print "usage: %s [options]" % os.path.basename(sys.argv[0])
242 def print_help(self):
247 _maxwidth, _indent = 79, 2
248 if len(self.options):
249 for option in self.options:
250 if olen < len(option.to_string()): olen = len(option.to_string())
252 for option in self.options:
254 for hs in option.help.split("\n"):
257 if len("%s %s" % (s,w)) > _maxwidth:
258 strings.append(s.strip()); s = ""
260 if s.strip(): strings.append(s.strip())
261 if not strings: strings[:0] = [""]
262 print "%s%s%s" % (option.to_string(), " "*(_indent+olen-len(option.to_string())), strings[0])
263 for i in range(1, len(strings)):
264 print "%s%s" % (" "*(olen+_indent), strings[i])
267 def _check_option(self, option):
268 o = self._get_option(option.short_opt)
269 if not o: o = self._get_option(option.long_opt)
271 msg = "option conflicts with previously defined option(s)"
272 raise OptError(msg, option)
275 def _get_option(self, opt_key):
277 for o in self.options:
278 if opt_key in [o.short_opt, o.long_opt]: return o
281 def _error(self, msg):
283 sys.exit("\n%s: error: %s\n" % (os.path.basename(sys.argv[0]), msg))
286 def _check_value(self, option, value):
287 o = self._get_option(option)
289 if o.type == "string": return str(value)
290 if o.type == "int": return int(value)
291 if o.type == "float": return float(value)
292 if o.type == "bool": return boolean(value)
294 msg = "invalid value type for option %s: %s; " % (option, value)
295 msg += "should be %s" % o.type
297 raise OptBaseError("unknown error")
299 def _process_args(self, values, args):
303 for index in range(len(args)):
305 if cur_opt and cur_opt[1].action == "store":
306 setattr(values, cur_opt[1].dest, self._check_value(cur_opt[0], a))
310 rargs = args[index+1:]
312 elif re.match("^-[a-zA-Z].*", a):
313 for i in range(1,len(a)):
314 if cur_opt and cur_opt[1].action == "store":
315 setattr(values, cur_opt[1].dest, self._check_value(cur_opt[0], a[i:]))
318 o = self._get_option("-%s"%a[i])
320 raise ArgError("no such option: -%s"%a[i])
321 if o.action == "store_true":
322 setattr(values, o.dest, True)
323 elif o.action == "store_false":
324 setattr(values, o.dest, False)
326 cur_opt = ("-%s"%a[i], o)
328 elif re.match("^--[a-zA-Z][a-zA-Z0-9]*(-[a-zA-Z0-9]+)*", a):
329 oname = ("%s="%a).split("=")[0]
330 ovalue = ("%s="%a).split("=")[1]
331 o = self._get_option(oname)
333 raise ArgError("no such option: %s" % oname)
334 if o.action == "store_true":
336 raise ValError("option %s does not take a value" % oname)
337 setattr(values, o.dest, True)
338 elif o.action == "store_false":
340 raise ValError("option %s does not take a value" % oname)
341 setattr(values, o.dest, False)
344 setattr(values, o.dest, self._check_value(oname, ovalue))
348 elif a.startswith("-"):
349 raise ArgError("bad formatted option: %s" % a)
353 if cur_opt and cur_opt[1].action == "store":
354 raise ValError("option %s requires value" % cur_opt[0])
355 return (values, rargs)
357 #------------------------------------------------------------------#
359 # XML CONFIGURATION FILES PARSER #
361 #------------------------------------------------------------------#
363 #===================================================================
364 # class Config : general configuration options : version, OS, etc...
365 #===================================================================
368 General configuration file options:
369 - Install Wizard window caption
370 - SALOME platform version
371 - Copyright and libcense info
372 - Target Linux OS version
380 self.version = strip(theVersion)
381 self.caption = strip(theCaption)
382 self.copyright = strip(theCopyright)
383 self.license = strip(theLicense)
384 self.os = strip(theOS)
386 #===================================================================
387 # class Path : default target, temporary directories options
388 #===================================================================
392 - default target directory
393 - default temporary directory
398 self.targetdir = strip(theTargetdir)
399 self.tmpdir = strip(theTmpdir)
401 #==============================================================
402 # class Product : pre-requisite product options
403 #==============================================================
408 - supported installation modes and the default one
410 - required disk space
411 - installation script
418 theSupportred = None,
419 theDependencies = None,
420 theInstalldiskspace = None,
421 theTemporarydiskspace = None,
423 thePickUpEnvironment = None,
425 self.name = strip(theName)
426 self.version = strip(theVersion)
427 self.install = strip(theInstall)
428 self.supported = strip(theSupportred)
429 self.dependencies = strip(theDependencies)
430 self.installdiskspace = strip(theInstalldiskspace)
431 self.temporarydiskspace = strip(theTemporarydiskspace)
432 self.script = strip(theScript)
433 self.pickupEnv = strip(thePickUpEnvironment)
434 self.context = strip(theContext)
435 self.whattodo = self.install
437 def hasContext(self, ctx):
439 return ctx in [ strip(s) for s in self.context.split(",") ]
444 def setMode(self, mode):
445 if mode not in [__TAG__SOURCES__, __TAG__BINARIES__, __TAG__NATIVE__, __TAG__PREINSTALL__]:
448 supported = [ strip(s) for s in self.supported.split(",") ]
449 if mode in supported or mode == __TAG__PREINSTALL__:
451 self.whattodo = self.install
452 salbin = self.hasContext(__CTX__SALOME__BIN__)
453 salsrc = self.hasContext(__CTX__SALOME__SRC__)
454 if mode == __TAG__SOURCES__:
455 if salbin and not salsrc:
456 self.install = __TAG__PREINSTALL__
457 self.whattodo = self.install
459 self.whattodo = __TAG__BUILDSRC__
464 #===================================================================
465 # class ConfigParser : XML files parser implementation
466 #===================================================================
467 class ConfigParser(xmllib.XMLParser):
469 XML configuration files parser
471 def __init__(self, is_force_src=False):
472 xmllib.XMLParser.__init__(self)
474 self.currentdata = []
477 self.is_force_src = is_force_src
479 def handle_data(self, data):
480 self.currentdata.append(data)
482 def start_product(self, attrs):
483 if not attrs.get('name', '').strip(): return
484 if check_bool(attrs.get('disable', 'false')): return
485 aProduct = Product(attrs.get('name'),
486 attrs.get('version', None),
487 attrs.get('install', None),
488 attrs.get('supported', None),
489 attrs.get('dependancies', None),
490 attrs.get('installdiskspace', None),
491 attrs.get('temporarydiskspace', None),
492 attrs.get('script', None),
493 attrs.get('pickupenv', None),
494 attrs.get('context', None))
495 if self.is_force_src:
496 aProduct.setMode(__TAG__SOURCES__)
497 self.products.append(aProduct)
500 def end_product(self):
503 def start_config(self, attrs):
504 self.config = Config(attrs.get('version', None),
505 attrs.get('caption', None),
506 attrs.get('copyright', None),
507 attrs.get('license', None),
508 attrs.get('os', None))
511 def end_config(self):
514 def start_path (self, attrs):
515 self.path = Path(attrs.get('targetdir', None),
516 attrs.get('tempdir', None))
522 def getProduct(self, prod):
523 for product in self.products:
524 if product.name == prod:
528 #------------------------------------------------------------------#
530 # SERVICE FUNCTIONS #
532 #------------------------------------------------------------------#
534 #==============================================================
535 # message: prints diagnostic information
536 #==============================================================
539 Prints diagnostic information.
545 #==============================================================
546 # warning: prints warning
547 #==============================================================
558 #==============================================================
559 # error_exit : prints (optionally) error string, then prints
560 # help information and quits
561 #==============================================================
562 def error_exit(msg = "", print_help = True):
564 Prints (optionally) error string,
565 then prints help information and quits.
567 # print error message
572 # print help information
576 opt_parser.print_help()
584 #==============================================================
585 # boolean : Converts string to boolean value.
586 #==============================================================
589 Converts string to boolean value if possible.
590 Raises exception if wrong string is used.
592 if isinstance(val, types.StringType):
593 if val.strip().lower() in ["true", "yes", "ok"] : return True
594 elif val.strip().lower() in ["false", "no", "cancel"] : return False
595 else: raise TypeError("invalid boolean value")
598 #=================================================================
599 # check_bool : checks boolean value: yes/no, true/false, 1/0
600 #=================================================================
603 Checks boolean value.
611 #==============================================================
612 # clean_all : performs system cleaning before exiting
613 #==============================================================
616 Performs system cleaning before exiting.
619 remove_dir(root_path)
622 #==============================================================
623 # parse_parameters : parses command line arguments
624 #==============================================================
625 def parse_parameters():
627 Parses command line arguments.
630 opt_parser = ArgParser()
632 help_str = "Runs the Installation Wizard in the GUI mode [default].\n"
633 opt_parser.add_option("-g",
639 help_str = "Runs the Installation Wizard in the TUI mode."
640 opt_parser.add_option("-b",
642 action="store_false",
645 help_str = "The configuration xml file.\n"
646 help_str += "If this parameter is missing, then the program tries to define the "
647 help_str += "Linux platform and use the corresponding xml file. For example, "
648 help_str += "for Red Hat 8.0 config_RedHat_8.0.xml file is used in this case. "
649 help_str += "If program fails to define target Linux platform or the corresponding "
650 help_str += "xml file is not provided with the Installation Wizard, then default "
651 help_str += "config.xml file is used."
652 opt_parser.add_option("-f",
658 help_str = "The target directory the products to be installed to.\n"
659 help_str += "When used this parameter overrides the default target directory "
660 help_str += "defined in the configuration xml file."
661 opt_parser.add_option("-d",
667 help_str = "The directory to be used for temporary files.\n"
668 help_str += "When used this parameter overrides the default temporary directory "
669 help_str += "defined in the configuration xml file."
670 opt_parser.add_option("-t",
676 help_str = "Force all products to be installed from sources\n"
677 help_str += "including SALOME modules."
678 help_str += "If this option is used all the default installation modes are ignored."
679 opt_parser.add_option("-a",
680 "--all-from-sources",
682 dest="force_sources",
685 help_str = "Prints version information and quits."
686 opt_parser.add_option("-v",
690 help_str = "Prints this help and quits."
691 opt_parser.add_option("-h",
695 (options, args) = opt_parser.parse_args()
697 # print help info and quit
698 print "\nSALOME Installation Wizard\n"
699 opt_parser.print_help()
703 # print version info and quit
705 cmd = "./bin/SALOME_InstallWizard --version"
709 return [options.xmlfile, options.target_dir, options.tmp_dir, options.gui, options.force_sources]
711 #=================================================================
712 # strip : removes spaces at the beginning and at the end of the
713 # <param> if it is of string type
714 #=================================================================
717 Removes spaces at the beginning and at the end
718 of the given parameter.
720 if type(param) == types.StringType:
724 #=================================================================
725 # get_dependencies : extract products dependencies
726 #=================================================================
727 def get_dependencies(prods):
729 Gets full list of pre-requisite products.
732 for product in prods:
733 deps = product.dependencies.split(",")
735 if dep and not dep in list:
738 if product and not product in list:
739 list.append( product.name )
741 return " ".join( list )
743 #==============================================================
744 # create_dir : creates a directory with (optional) permissions,
745 # returns the part of path that existed before
746 # directory creation; exits with error if access
748 #==============================================================
749 def create_dir(directory, access = 0777):
751 Creates a directory with (optional) permissions,
752 returns the part of path that existed before
753 directory creation; exits with error if access
756 dirs = directory.split("/")
761 if len(subdir) == 0: continue
762 dir = "%s/%s"%(dir, subdir)
763 if os.path.exists(dir):
767 os.mkdir(dir, access)
769 error_exit("Can't create directory: %s.\nAccess is denied."%directory)
770 if dir == "%s/%s"%(existing, subdir):
774 #==============================================================
775 # substituteVars : performes environment variables substistution
776 # the given string; if varibale is not defined
777 # it is substituted by the empty string
778 #==============================================================
779 def substituteVars(str):
781 Performes environment variables substistution.
783 str = os.path.expanduser(str)
784 str = os.path.expandvars(str)
787 #================================================================
788 # get_program_path : gets program's directory path
789 # (and performs 'cd' command there)
790 #================================================================
791 def get_program_path():
793 Returns the program directory path
794 (and make this directory current).
796 path = os.path.dirname(sys.argv[0])
801 #================================================================
802 # check_dir : checks directory existence
803 #================================================================
806 Checks directory existence.
808 if (os.path.islink(dir)):
809 realpath = os.path.realpath(dir)
810 if not os.path.exists(realpath):
811 msg = "Invalid link %s.\nThe directory %s a link points to does not exist. Stopped..."%(dir,realpath)
812 error_exit(msg, False)
814 if not os.path.exists(dir):
815 msg = "Directory %s does not exist. Stopped..."%dir
816 error_exit(msg, False)
819 #===============================================================
820 # check_disk_space : checks the disk space;
821 # quits if there is no enough disk space
822 #===============================================================
823 def check_disk_space(products, scripts_dir, target_dir, tmp_dir, is_force_src=False):
825 Checks if there is enough disk space to install products.
826 Quits with error if there is no enough disk space.
830 for product in products:
831 if product.install in [__TAG__NATIVE__, __TAG__PREINSTALL__]:
835 spaces = product.installdiskspace.split(',')
836 prod_space = int( spaces[0] )
837 if len( spaces ) > 1 and product.install == __TAG__SOURCES__ and not is_force_src:
838 prod_space = int( spaces[1] )
841 install_space = install_space + prod_space
842 if product.install == __TAG__SOURCES__:
845 tmp_space = int( product.temporarydiskspace )
848 temporary_space = max( temporary_space, tmp_space )
851 res = os.system("%s/%s %s %d"%(scripts_dir, "checkSize.sh", target_dir, install_space))
853 msg = "There is no enough space to install the products. Stopped..."
854 error_exit(msg, False)
856 res = os.system("%s/%s %s %d"%(scripts_dir, "checkSize.sh", tmp_dir, temporary_space))
858 msg = "There is no enough space for temporary directory. Stopped..."
859 error_exit(msg, False)
862 #===============================================================
863 # remove_dir : removes temporary directory
864 #===============================================================
865 def remove_dir(path):
867 Removes temporary directory.
869 if path and os.path.exists(path):
870 os.system("rm -rf " + path)
873 #==============================================================
874 # has_binaries : returns True if some product is installed from
876 #===============================================================
877 def has_binaries(products):
879 Returns True if some product is installed in 'binaries' mode.
881 for product in products:
882 if product.install == __TAG__BINARIES__:
886 #==============================================================
887 # has_sources : returns True if some product is installed from
889 #===============================================================
890 def has_sources(products):
892 Returns True if some product is installed in 'sources' mode.
894 for product in products:
895 if product.install == __TAG__SOURCES__:
899 #==============================================================
900 # get_tmp_dir : gets temporary directory name
901 #===============================================================
902 def get_tmp_dir(dir):
904 Gets temporary directory path.
907 dir_prefix="INSTALLWORK"
908 range_bottom = 0; range_top = 999999
909 for i in xrange(max_attempts):
910 tmp_dir = "%s/%s%d"%(dir, dir_prefix, random.randint(range_bottom,range_top))
911 if not os.path.exists( tmp_dir ):
913 return "%s/%s%d"%(dir, dir_prefix, random.randint(range_bottom,range_top))
915 #------------------------------------------------------------------#
917 # EXECUTION STARTS HERE #
919 #------------------------------------------------------------------#
921 if __name__ == "__main__":
923 [xml_file, target_dir, tmp_dir, is_gui, is_force_src] = parse_parameters()
924 if xml_file: xml_file = os.path.abspath(xml_file)
925 if target_dir: target_dir = os.path.abspath(target_dir)
926 if tmp_dir: tmp_dir = os.path.abspath(tmp_dir)
928 cur_dir = get_program_path()
930 # define xml file to be used
931 if (xml_file is None):
935 xml_file_name = "config.xml"
936 if os.path.exists("/etc/fedora-release"):
937 # - Fedora Core 4,5,6
939 data = open("/etc/fedora-release").readline()
940 res = re.search(r'Fedora.*release\s+([\d.]*)', data)
942 plt_ver = res.group(1)
943 elif os.path.exists("/etc/redhat-release"):
944 # - Red Hat Linux 8.0
946 # - Mandrake Linux 10.1
947 # - Scientific Linux 3.0.5
948 # - Mandriva 2006.0 32bit/64bit
949 data = open("/etc/redhat-release").readline()
950 res = re.search(r'(.*)[L|l]inux.*release\s+([\d.]*)', data)
952 plt_name = "".join(res.group(1).split())
953 plt_ver = res.group(2)
954 if re.search(r'x86_64', data):
956 elif os.path.exists("/etc/debian_version"):
959 plt_ver = open("/etc/debian_version").readline().strip()
960 elif os.path.exists("/etc/mandriva-release"):
961 # - Mandriva 2006 (an additional check if above check fails)
962 data = open("/etc/mandriva-release").readline()
963 res = re.search(r'(.*)[L|l]inux.*release\s+([\d.]*)', data)
965 plt_name = "".join(res.group(1).split())
966 plt_ver = res.group(2)
967 if re.search(r'x86_64', data):
970 _xml_file_name = "config_%s_%s%s.xml"%(plt_name, plt_ver, plt_bit)
971 if plt_name and plt_ver and os.path.exists("%s/%s"%(cur_dir, _xml_file_name)):
972 xml_file_name = _xml_file_name
974 msg = "Not supported Linux platform!\n"
975 msg += "Trying to use default configuration file!"
978 xml_file = "%s/%s"%(cur_dir, xml_file_name)
980 if not xml_file or not os.path.exists(xml_file):
981 msg = "Configuration file %s is not found!"%xml_file
984 if not os.access(xml_file, os.R_OK):
985 msg = "There is no read access for %s file!"%xml_file
988 #---- GUI ----------------
992 if not env.has_key("PATH") :
994 if not env.has_key("LD_LIBRARY_PATH") :
995 env["LD_LIBRARY_PATH"] = ""
997 env["LD_LIBRARY_PATH"] = ".:" + env["LD_LIBRARY_PATH"]
998 env["PATH"] = ".:" + env["PATH"]
1000 cmd = "./bin/SALOME_InstallWizard --file %s"%xml_file
1001 if target_dir is not None:
1002 cmd += " --target %s"%target_dir
1003 if tmp_dir is not None:
1004 cmd += " --tmp %s"%tmp_dir
1006 cmd += " --all-from-sources"
1008 sys.exit(os.system(cmd))
1010 #----- TUI ---------------------
1012 # parse XML file -----------
1013 message("Parsing XML configuration file: %s"%xml_file)
1014 filehandle = open(xml_file)
1015 data = filehandle.read()
1017 parser = ConfigParser(is_force_src)
1022 what_to_do = { __TAG__SOURCES__ : "install_source",
1023 __TAG__BINARIES__ : "install_binary",
1024 __TAG__NATIVE__ : "try_native",
1025 __TAG__PREINSTALL__ : "try_preinstalled",
1026 __TAG__BUILDSRC__ : "install_source_and_build"}
1027 # source directory map
1029 if parser.config.os:
1030 bin_dir += "/%s"%parser.config.os
1031 subdir = { __TAG__SOURCES__ : "SOURCES",
1032 __TAG__BINARIES__ : "BINARIES" + bin_dir,
1033 __TAG__NATIVE__ : "",
1034 __TAG__PREINSTALL__ : ""}
1036 # check scripts directory -----------
1037 scripts_dir = "%s/%s"%(cur_dir, "config_files")
1038 check_dir(scripts_dir)
1040 # check products archives directories -----------
1041 has_bin = has_binaries(parser.products)
1042 has_src = has_sources(parser.products)
1043 source_dir = "%s/%s"%(cur_dir, "Products")
1045 if has_src or has_bin:
1046 check_dir(source_dir)
1049 check_dir("%s/%s"%(source_dir,subdir[__TAG__SOURCES__]))
1052 check_dir("%s/%s"%(source_dir,subdir[__TAG__BINARIES__]))
1054 # check/create target dir -----------
1055 if target_dir is None:
1056 target_dir = parser.path.targetdir
1057 target_dir = substituteVars(target_dir)
1059 message("Creating target directory: " + target_dir)
1060 create_dir(target_dir, 0755)
1062 if not os.path.exists(target_dir):
1063 error_exit("Invalid target directory: " + target_dir)
1065 if not os.access(target_dir, os.W_OK) :
1066 error_exit("There is no write permissions for the directory: " + target_dir)
1068 # check/create temporary dir -----------
1070 tmp_dir = parser.path.tmpdir
1073 tmp_dir = substituteVars(tmp_dir)
1074 tmp_dir = get_tmp_dir(tmp_dir)
1076 message("Creating temporary directory: " + tmp_dir)
1077 root_path = create_dir(tmp_dir, 0755)
1079 if not os.path.exists(tmp_dir):
1080 error_exit("Invalid temporary directory: " + tmp_dir)
1082 if not os.access(tmp_dir, os.W_OK) :
1083 error_exit("There is no write permissions for the directory: " + tmp_dir)
1085 # check available disk space -----------
1086 message("Checking available disk space")
1087 check_disk_space(parser.products, scripts_dir, target_dir, tmp_dir, is_force_src)
1089 # change current directory -----------
1090 os.chdir(scripts_dir)
1092 # get dependencies list -----------
1093 list_of_dep = get_dependencies(parser.products)
1095 # starting -----------
1096 message("Starting ...")
1098 # install products -----------
1099 for product in parser.products:
1100 message("... processing %s ..."%product.name)
1101 cmd = '%s/%s %s %s %s/%s %s "%s" %s'%(scripts_dir,
1103 what_to_do[product.whattodo],
1106 subdir[product.install],
1110 res = os.system(cmd)
1112 # pickup environment -----------
1113 message("Creating environment files")
1114 for product in parser.products :
1115 if check_bool(product.pickupEnv):
1116 cmd = '%s/%s pickup_env %s %s/%s %s "%s" %s'%(scripts_dir,
1120 subdir[product.install],
1124 res = os.system(cmd)
1126 # clean temporary directory -----------
1127 message("Cleaning temporary directory")
1130 # finishing -----------
1131 message("Finished!")