+def produce_install_bin_file(config,
+ logger,
+ file_dir,
+ d_sub,
+ file_name):
+ '''Create a bash shell script which do substitutions in BIRARIES dir
+ in order to use it for extra compilations.
+
+ :param config Config: The global configuration.
+ :param logger Logger: the logging instance
+ :param file_dir str: the directory where to put the files
+ :param d_sub, dict: the dictionnary that contains the substitutions to be done
+ :param file_name str: the name of the install script file
+ :return: the produced file
+ :rtype: str
+ '''
+ # Write
+ filepath = os.path.join(file_dir, file_name)
+ # open the file and write into it
+ # use codec utf-8 as sat variables are in unicode
+ with codecs.open(filepath, "w", 'utf-8') as installbin_file:
+ installbin_template_path = os.path.join(config.VARS.internal_dir,
+ "INSTALL_BIN.template")
+
+ # build the name of the directory that will contain the binaries
+ binaries_dir_name = "BINARIES-" + config.VARS.dist
+ # build the substitution loop
+ loop_cmd = "for f in $(grep -RIl"
+ for key in d_sub:
+ loop_cmd += " -e "+ key
+ loop_cmd += ' INSTALL); do\n sed -i "\n'
+ for key in d_sub:
+ loop_cmd += " s?" + key + "?$(pwd)/" + d_sub[key] + "?g\n"
+ loop_cmd += ' " $f\ndone'
+
+ d={}
+ d["BINARIES_DIR"] = binaries_dir_name
+ d["SUBSTITUTION_LOOP"]=loop_cmd
+
+ # substitute the template and write it in file
+ content=src.template.substitute(installbin_template_path, d)
+ installbin_file.write(content)
+ # change the rights in order to make the file executable for everybody
+ os.chmod(filepath,
+ stat.S_IRUSR |
+ stat.S_IRGRP |
+ stat.S_IROTH |
+ stat.S_IWUSR |
+ stat.S_IXUSR |
+ stat.S_IXGRP |
+ stat.S_IXOTH)
+
+ return filepath
+
+def product_appli_creation_script(config,
+ logger,
+ file_dir,
+ binaries_dir_name):
+ '''Create a script that can produce an application (EDF style) in the binary
+ package.
+
+ :param config Config: The global configuration.
+ :param logger Logger: the logging instance
+ :param file_dir str: the directory where to put the file
+ :param binaries_dir_name str: the name of the repository where the binaries
+ are, in the archive.
+ :return: the path of the produced script file
+ :rtype: Str
+ '''
+ template_name = "create_appli.py.for_bin_packages.template"
+ template_path = os.path.join(config.VARS.internal_dir, template_name)
+ text_to_fill = open(template_path, "r").read()
+ text_to_fill = text_to_fill.replace("TO BE FILLED 1",
+ '"' + binaries_dir_name + '"')
+
+ text_to_add = ""
+ for product_name in get_SALOME_modules(config):
+ product_info = src.product.get_product_config(config, product_name)
+
+ if src.product.product_is_smesh_plugin(product_info):
+ continue
+
+ if 'install_dir' in product_info and bool(product_info.install_dir):
+ if src.product.product_is_cpp(product_info):
+ # cpp module
+ for cpp_name in src.product.get_product_components(product_info):
+ line_to_add = ("<module name=\"" +
+ cpp_name +
+ "\" gui=\"yes\" path=\"''' + "
+ "os.path.join(dir_bin_name, \"" +
+ cpp_name + "\") + '''\"/>")
+ else:
+ # regular module
+ line_to_add = ("<module name=\"" +
+ product_name +
+ "\" gui=\"yes\" path=\"''' + "
+ "os.path.join(dir_bin_name, \"" +
+ product_name + "\") + '''\"/>")
+ text_to_add += line_to_add + "\n"
+
+ filled_text = text_to_fill.replace("TO BE FILLED 2", text_to_add)
+
+ tmp_file_path = os.path.join(file_dir, "create_appli.py")
+ ff = open(tmp_file_path, "w")
+ ff.write(filled_text)
+ ff.close()
+
+ # change the rights in order to make the file executable for everybody
+ os.chmod(tmp_file_path,
+ stat.S_IRUSR |
+ stat.S_IRGRP |
+ stat.S_IROTH |
+ stat.S_IWUSR |
+ stat.S_IXUSR |
+ stat.S_IXGRP |
+ stat.S_IXOTH)
+
+ return tmp_file_path