From: vsr Date: Tue, 8 Feb 2005 06:55:40 +0000 (+0000) Subject: Fix a batch mode bugs: invalid environment files are created X-Git-Tag: SALOME_V_2_2_0~10 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=423ac1483f4b889944737ccb3a729f14a4d79833;p=tools%2Finstall.git Fix a batch mode bugs: invalid environment files are created --- diff --git a/config_RedHat8_0.xml b/config_RedHat8_0.xml index 623759b..180790a 100644 --- a/config_RedHat8_0.xml +++ b/config_RedHat8_0.xml @@ -141,7 +141,7 @@ description="MED format interface library" install="install binaries" supported="install sources,install binaries" - disable="yes" + disable="true" dependancies="gcc,Hdf" installdiskspace="1067" temporarydiskspace="7971" diff --git a/config_RedHat8_0_with_Mesa.xml b/config_RedHat8_0_with_Mesa.xml index 28a0a49..9d3d7ab 100644 --- a/config_RedHat8_0_with_Mesa.xml +++ b/config_RedHat8_0_with_Mesa.xml @@ -141,7 +141,7 @@ description="MED format interface library" install="install binaries" supported="install sources,install binaries" - disable="yes" + disable="true" dependancies="gcc,Hdf" installdiskspace="1067" temporarydiskspace="7971" diff --git a/runInstall b/runInstall index dcadb34..367320d 100755 --- a/runInstall +++ b/runInstall @@ -7,12 +7,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 +32,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 +149,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 +260,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. @@ -365,7 +395,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 @@ -394,7 +423,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): @@ -414,7 +443,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" or product.install == "not install": + 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] @@ -490,7 +519,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() @@ -513,12 +543,12 @@ if __name__ == "__main__": 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, 0755) ; + 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 = "There is 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 -------- @@ -526,14 +556,13 @@ 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 = "There is 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" ; @@ -554,16 +583,20 @@ if __name__ == "__main__": 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 + " " + \ @@ -576,11 +609,12 @@ if __name__ == "__main__": #if res : break; # try_preinstalled can return 1 # pickup environment + message("Creating environment files") for product in parser.products : - if product.disable == "true": continue + if check_bool(product.disable): continue - if product.pickupEnv == "true": + if check_bool(product.pickupEnv): cmd = scripts_dir + product.script + " " + \ "pickup_env " + \ tmp_dir + " " + \ @@ -591,4 +625,6 @@ if __name__ == "__main__": res = os.system(cmd) + message("Cleaning temporary directory") remove_dir(root_path) + message("Finished!")