From da7478a8b8b5f1bba530d23f9df44c155d070017 Mon Sep 17 00:00:00 2001 From: vsr Date: Mon, 7 Feb 2005 14:35:36 +0000 Subject: [PATCH] Fix a bug: improve a way temporary directory is used (always create tmp dir) --- runInstall | 53 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 30 insertions(+), 23 deletions(-) diff --git a/runInstall b/runInstall index 2f81342..dcadb34 100755 --- a/runInstall +++ b/runInstall @@ -414,7 +414,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 product.disable == "true" or product.install == "use native" or product.install == "not install": continue spaces = string.split( product.installdiskspace,',') prod_space = spaces[0] @@ -434,7 +434,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 #================================================================ @@ -459,10 +466,10 @@ if __name__ == "__main__": 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 ---------------- @@ -493,23 +500,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") + print "Creating " + 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 directory or correct xml file" error_exit(str) # define target dir -------- @@ -522,27 +531,26 @@ if __name__ == "__main__": error_exit("There is no 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 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) @@ -565,7 +573,7 @@ if __name__ == "__main__": product.name res = os.system(cmd) - if res : break; + #if res : break; # try_preinstalled can return 1 # pickup environment for product in parser.products : @@ -583,5 +591,4 @@ if __name__ == "__main__": res = os.system(cmd) - if len(root_path) and os.path.exists(root_path): - os.system("rm -r -f "+ root_path) + remove_dir(root_path) -- 2.39.2