# 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 <xml-file>] [-t <target-dir>] [-tmp <tmp-dir>]\n"
str = str + "\n"
str = str + " -g Runs the Installation Wizard in the GUI mode.\n"
str = str + " In this case only <xmlfile> 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"
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
#==============================================================
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
#=================================================================
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.
def start_path (self, attrs):
self.path = Path(attrs['targetdir'],
attrs['tempdir'])
- print self.path.tmpdir
def end_path(self):
pass
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):
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]
#----- 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()
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 --------
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" ;
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 + " " + \
#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 + " " + \
res = os.system(cmd)
+ message("Cleaning temporary directory")
remove_dir(root_path)
+ message("Finished!")