X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=runInstall;h=d3d2725a73206617ef4bc7cddfa7d693f88e475f;hb=8f56e02b700f61972353d2110063e92af7c5b09b;hp=50aaa59c6838ad31e1733940a2776e5a1fa53f1b;hpb=62540823fb4cbe7f6e6402c1eb1fb3c24aaaca85;p=tools%2Finstall.git diff --git a/runInstall b/runInstall index 50aaa59..d3d2725 100755 --- a/runInstall +++ b/runInstall @@ -1,5 +1,8 @@ #!/usr/bin/env python +import warnings +warnings.filterwarnings("ignore", "", DeprecationWarning) + import xmllib import sys, os, string, re @@ -7,12 +10,12 @@ import sys, os, string, re # get_help_info #============================================================== def get_help_info() : - str = "\nPAL/SALOME Installation Wizard\n\n" + str = "\nSALOME2 Installation Wizard\n\n" str = str + "\tUsage : \n\tInstall [-g|b] [-f ] [-t ] [-tmp ]\n" str = str + "\n" str = str + " -g Runs the Installation Wizard in the GUI mode.\n" str = str + " In this case only is taken into account \n" - str = str + " from the parameters list. This key is default.\n" + str = str + " from the parameters list. This key is used by default.\n" str = str + "\n" str = str + " -b Runs the Installation Wizard in the batch mode.\n" str = str + " All the found parameters are taken in to account.\n" @@ -32,9 +35,15 @@ def get_help_info() : str = str + " This parameter overloads the temporary directory described in the\n" str = str + " configuration file.\n" str = str + "\n" - str = str + " -h Prints help information.\n" + str = str + " -h Prints this help information.\n" return str +#============================================================== +# message finction +#============================================================== +def message(msg): + print ">>>", msg + #============================================================== # error_exit #============================================================== @@ -143,6 +152,12 @@ def parse_parameters (args) : return [xmlfile, target_dir, tmp_dir, is_gui] +#================================================================= +# Checks boolean value: yes/no, true/false, 1/0 +#================================================================= +def check_bool(val): + return str(val).strip() in ["yes","true", "1"] + #================================================================= # The first algorithm to create the dependencies list by their level #================================================================= @@ -248,6 +263,24 @@ def get_dependencies_set(prods) : return deps +#================================================================= +# The third algorithm (same as SALOME_InstallWizard.cxx uses) +#================================================================= +def get_dependencies(prods) : + list = [] + for product in prods: + if check_bool(product.disable): continue + + deps = product.dependencies.split(",") + for dep in deps: + if dep and not dep in list: + list.append( dep ) + + if product and not product in list: + list.append( product.name ) + + return " ".join( list ) + #============================================================== # Creates dir, returns the part of path that existed early. # Access may be defined. @@ -284,7 +317,8 @@ class Product : theDependencies = None, theInstalldiskspace = None, theTemporarydiskspace = None, - theScript = None): + theScript = None, + thePickUpEnvironment = None): self.name = theName @@ -296,6 +330,7 @@ class Product : self.installdiskspace = theInstalldiskspace self.temporarydiskspace = theTemporarydiskspace self.script = theScript + self.pickupEnv = thePickUpEnvironment #=================================================================== # class Config @@ -343,6 +378,9 @@ class ConfigParser(xmllib.XMLParser): attrs['temporarydiskspace'], attrs['script']) + if attrs.has_key( 'pickupenv' ): + aProduct.pickupEnv = attrs['pickupenv'] + self.products.append(aProduct) def end_product(self): @@ -360,7 +398,6 @@ class ConfigParser(xmllib.XMLParser): def start_path (self, attrs): self.path = Path(attrs['targetdir'], attrs['tempdir']) - print self.path.tmpdir def end_path(self): pass @@ -389,7 +426,7 @@ def check_dir(dir): if (os.path.islink(dir)) : native_dir = os.readlink(dir) if not os.path.exists(native_dir) : - print "Bad link " + native_dir + " to directory " + native_dir + ". The last does not exist." + print "Invalid link " + dir + ". The directory " + native_dir + " a link points to does not exist." return 0 # problem else : if not os.path.exists(dir): @@ -409,7 +446,7 @@ def check_disk_space(products, script_dir, target_dir, tmp_dir): product.install = re.sub(r'^\s+', "", product.install) product.install = re.sub(r'\s+$', "", product.install) - if product.disable == "true" or product.install == "use native": + if check_bool(product.disable) or product.install == "use native" or product.install == "not install": continue spaces = string.split( product.installdiskspace,',') prod_space = spaces[0] @@ -429,7 +466,14 @@ def check_disk_space(products, script_dir, target_dir, tmp_dir): return 1 - +#=============================================================== +# Removes temporary directory +#=============================================================== +def remove_dir( rem_path = "" ): + if len( rem_path ) and os.path.exists( rem_path ): + os.system( "rm -rf " + rem_path ) + pass + #================================================================ # main #================================================================ @@ -443,21 +487,28 @@ if __name__ == "__main__": # define xml file ----------------- if (xml_file is None) : xml_file_name = "config.xml" - if os.path.exists("/proc/version"): - data = open("/proc/version").readline() - res = re.search(r'Red\s+Hat\s+\w+(\s+)?(\d[.]\d)', data) + if os.path.exists("/etc/redhat-release"): + data = open("/etc/redhat-release").readline() + res = re.search(r'Red\s+Hat\s+Linux\s+release\s+([\d.]*)', data) if res is not None: - num = re.sub("[.]", "_", (res.groups())[1]) + num = re.sub("[.]", "_", (res.groups())[0]) filename = "config_RedHat" + num+ ".xml" if (os.path.exists(cur_dir + filename)): xml_file_name = filename - + else: + res = re.search(r'Mandrakelinux\s+release\s+([\d.]*)', data) + if res is not None: + num = re.sub("[.]", "_", (res.groups())[0]) + filename = "config_Mandrake" + num+ ".xml" + if (os.path.exists(cur_dir + filename)): + xml_file_name = filename xml_file = cur_dir + xml_file_name + if xml_file is None or not os.path.exists(xml_file): - error_exit("No xml file is found try to run with options -f ") + error_exit("No xml file is found, try to run with options -f ") if not os.access(xml_file, os.R_OK): - print "There is no acceess to read "+ xml_file + print "There is no read access for "+ xml_file sys.exit(1) #---- GUI ---------------- @@ -478,7 +529,8 @@ if __name__ == "__main__": #----- TUI --------------------- #print xml_file, target_dir, tmp_dir, is_gui - + + message("Parsing xml config file: " + xml_file) filehandle = open(xml_file) data = filehandle.read() filehandle.close() @@ -488,23 +540,25 @@ if __name__ == "__main__": # definitions : # map - what_to_do = { "install sources":"install_source", - "install binaries":"install_binary", - "use native":"try_native"} + what_to_do = { "install sources" : "install_source", + "install binaries" : "install_binary", + "use native" : "try_native", + "not install" : "try_preinstalled"} # define tmp dir ----------- if tmp_dir is None: tmp_dir = parser.path.tmpdir + if tmp_dir is None or tmp_dir == "": + tmp_dir = "/tmp" + import random + tmp_dir = tmp_dir + "/INSTALLWORK" + str(random.randint(10000,100000)) root_path = "" if not os.path.exists(tmp_dir): - print "Creating " + tmp_dir; root_path = create_dir(tmp_dir) ; - import random - tmp_dir = tmp_dir + "/INSTALLWORK" + str(random.randint(10000,100000)) - create_dir(tmp_dir,0755) - if not os.path.exists(tmp_dir): - error_exit("There is no tmp directory " + tmp_dir + ". Use -tmp key to set directory or correct xml file\n\n") + 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 + ". Use -tmp key to set directory or correct xml file\n\n") if not os.access(tmp_dir, os.W_OK) : - str = "We have no write permissions for directory " + tmp_dir + ". Use -tmp key to set directory or correct xml file" + str = "There is no write permissions for directory " + tmp_dir + ". Use -tmp key to set temporary directory or correct xml file" error_exit(str) # define target dir -------- @@ -512,44 +566,47 @@ if __name__ == "__main__": target_dir = parser.path.targetdir if not os.path.exists(target_dir): - print "Creating " + target_dir; create_dir(target_dir, 0755) - if not os.path.exists(target_dir): - error_exit("There is no target directory " + target_dir + ". Use -t key to set directory or correct xml file\n\n") + message("Creating target directory: " + target_dir); create_dir(target_dir, 0755) + if not os.path.exists(target_dir): + error_exit("Invalid target directory " + target_dir + ". Use -t key to set directory or correct xml file\n\n") if not os.access(target_dir, os.W_OK) : - str = "We have no write permissions for directory " + target_dir + ". Use -t key to set directory or correct xml file" + str = "There is no write permissions for directory " + target_dir + ". Use -t key to set target directory or correct xml file." error_exit(str) - # define products dir ------------ source_dir = cur_dir + "Products" ; if not check_dir(source_dir): - if len(root_path) and os.path.exists(root_path): - os.system("rm -r -f "+ root_path) + remove_dir(root_path) sys.exit(1) subdir = {"install sources" : "SOURCES", "install binaries" : "BINARIES/"+parser.config.os, - "use native": ""} + "use native" : "", + "not install" : ""} # define scripts dir ------------ scripts_dir = cur_dir + "config_files/" if not check_dir(scripts_dir): - if len(root_path) and os.path.exists(root_path): - os.system("rm -r -f "+ root_path) + remove_dir(root_path) sys.exit(1) os.chdir(scripts_dir) - list_of_dep = create_levels(parser.products) + #list_of_dep = create_levels(parser.products) #list_of_dep = get_dependencies_set(parser.products) + list_of_dep = get_dependencies(parser.products) + message("Checking available disk space") if check_disk_space(parser.products, scripts_dir, target_dir, tmp_dir) : - + + message("Starting...") + # install products for product in parser.products : - if product.disable == "true": continue + if check_bool(product.disable): continue + message("Processing " + product.name + "...") cmd = scripts_dir + product.script + " " + \ what_to_do[product.install]+ " " + \ tmp_dir + " " + \ @@ -559,22 +616,25 @@ if __name__ == "__main__": product.name res = os.system(cmd) - if res : break; - - shFile = target_dir + "/env_products.sh" - cshFile = target_dir + "/env_products.csh" - binProduct = parser.getProduct("KERNEL-Bin") - srcProduct = parser.getProduct("KERNEL-Src") - if binProduct: - if os.path.exists(shFile): - os.system( "cp " + shFile + " " + target_dir + "/KERNEL_" + binProduct.version + "/salome.sh" ) - if os.path.exists(cshFile): - os.system( "cp " + cshFile + " " + target_dir + "/KERNEL_" + binProduct.version + "/salome.csh" ) - if srcProduct: - if os.path.exists(shFile): - os.system( "cp " + shFile + " " + target_dir + "/KERNEL_SRC_" + binProduct.version + "/salome.sh" ) - if os.path.exists(cshFile): - os.system( "cp " + cshFile + " " + target_dir + "/KERNEL_SRC_" + binProduct.version + "/salome.csh" ) - - if len(root_path) and os.path.exists(root_path): - os.system("rm -r -f "+ root_path) + #if res : break; # try_preinstalled can return 1 + + # pickup environment + message("Creating environment files") + for product in parser.products : + + if check_bool(product.disable): continue + + if check_bool(product.pickupEnv): + cmd = scripts_dir + product.script + " " + \ + "pickup_env " + \ + tmp_dir + " " + \ + source_dir + "/" + subdir[product.install] + " " + \ + target_dir + " " + \ + '"' + list_of_dep + '"' + " " + \ + product.name + + res = os.system(cmd) + + message("Cleaning temporary directory") + remove_dir(root_path) + message("Finished!")