import datetime
import tarfile
import codecs
+import string
import src
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
- installbin_file = codecs.open(filepath, "w", 'utf-8')
- 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)
- installbin_file.close()
- # 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)
+ 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
binaries_dir_name,
not(options.without_commercial))
- if options.sources:
- # if we mix binaries and sources, prefix launcher name with "bin"
- # to avoid clashes
- launcher_name="bin"+launcher_name
d_products["launcher"] = (launcher_package, launcher_name)
+ if options.sources:
+ # if we mix binaries and sources, we add a copy of the launcher,
+ # prefixed with "bin",in order to avoid clashes
+ d_products["launcher (copy)"] = (launcher_package, "bin"+launcher_name)
else:
# Provide a script for the creation of an application EDF style
appli_script = product_appli_creation_script(config,
return d_project
-def add_readme(config, package_type, where):
+def add_readme(config, options, where):
readme_path = os.path.join(where, "README")
- f = open(readme_path, 'w')
- # prepare substitution dictionary
- d = dict()
- if package_type == BINARY:
- d['application'] = config.VARS.application
+ with codecs.open(readme_path, "w", 'utf-8') as f:
+
+ # templates for building the header
+ readme_header="""
+# This package was generated with sat $version
+# Date: $date
+# User: $user
+# Distribution : $dist
+
+In the following, $$ROOT represents the directory where you have installed
+SALOME (the directory where this file is located).
+
+"""
+ readme_compilation_with_binaries="""
+
+compilation based on the binaries used as prerequisites
+=======================================================
+
+If you fail to compile the the complete application (for example because
+you are not root on your system and cannot install missing packages), you
+may try a partial compilation based on the binaries.
+For that it is necessary to copy the binaries from BINARIES to INSTALL,
+and do some substitutions on cmake and .la files (replace the build directories
+with local paths).
+The procedure to do it is:
+ 1) Remove or rename INSTALL directory if it exists
+ 2) Execute the shell script bin_install.sh:
+ > cd $ROOT
+ > ./bin_install.sh
+ 3) Use SalomeTool (as explained in Sources section) and compile only the
+ modules you need to (with -p option)
+
+"""
+ readme_header_tpl=string.Template(readme_header)
+ readme_template_path_bin_prof = os.path.join(config.VARS.internal_dir,
+ "README_BIN.template")
+ readme_template_path_bin_noprof = os.path.join(config.VARS.internal_dir,
+ "README_BIN_NO_PROFILE.template")
+ readme_template_path_src = os.path.join(config.VARS.internal_dir,
+ "README_SRC.template")
+ readme_template_path_pro = os.path.join(config.VARS.internal_dir,
+ "README_PROJECT.template")
+ readme_template_path_sat = os.path.join(config.VARS.internal_dir,
+ "README_SAT.template")
+
+ # prepare substitution dictionary
+ d = dict()
d['user'] = config.VARS.user
d['date'] = datetime.datetime.now().strftime("%Y-%m-%d %H:%M")
d['version'] = config.INTERNAL.sat_version
d['dist'] = config.VARS.dist
- if 'profile' in config.APPLICATION:
- d['launcher'] = config.APPLICATION.profile.launcher_name
- readme_template_path = os.path.join(config.VARS.internal_dir,
- "README_BIN.template")
- else:
- d['env_file'] = 'env_launch.sh'
- readme_template_path = os.path.join(config.VARS.internal_dir,
- "README_BIN_NO_PROFILE.template")
-
- if package_type == SOURCE:
- d['application'] = config.VARS.application
- d['user'] = config.VARS.user
- d['date'] = datetime.datetime.now().strftime("%Y-%m-%d %H:%M")
- d['version'] = config.INTERNAL.sat_version
- if 'profile' in config.APPLICATION:
- d['profile'] = config.APPLICATION.profile.product
- d['launcher'] = config.APPLICATION.profile.launcher_name
- readme_template_path = os.path.join(config.VARS.internal_dir,
- "README_SRC.template")
+ f.write(readme_header_tpl.substitute(d)) # write the general header (common)
+
+ if options.binaries or options.sources:
+ d['application'] = config.VARS.application
+ f.write("# Application: " + d['application'])
+ if 'profile' in config.APPLICATION:
+ d['launcher'] = config.APPLICATION.profile.launcher_name
+ d['launcher'] = config.APPLICATION.profile.launcher_name
+ else:
+ d['env_file'] = 'env_launch.sh'
- if package_type == PROJECT:
- d['user'] = config.VARS.user
- d['date'] = datetime.datetime.now().strftime("%Y-%m-%d %H:%M")
- d['version'] = config.INTERNAL.sat_version
- readme_template_path = os.path.join(config.VARS.internal_dir,
- "README_PROJECT.template")
+ # write the specific sections
+ if options.binaries:
+ if "env_file" in d:
+ f.write(src.template.substitute(readme_template_path_bin_noprof, d))
+ else:
+ f.write(src.template.substitute(readme_template_path_bin_prof, d))
- if package_type == SAT:
- d['user'] = config.VARS.user
- d['date'] = datetime.datetime.now().strftime("%Y-%m-%d %H:%M")
- d['version'] = config.INTERNAL.sat_version
- readme_template_path = os.path.join(config.VARS.internal_dir,
- "README_SAT.template")
-
- f.write(src.template.substitute(readme_template_path, d))
+ if options.sources:
+ f.write(src.template.substitute(readme_template_path_src, d))
+
+ if options.binaries and options.sources:
+ f.write(readme_compilation_with_binaries)
+
+ if options.project:
+ f.write(src.template.substitute(readme_template_path_pro, d))
+
+ if options.sat:
+ f.write(src.template.substitute(readme_template_path_sat, d))
return readme_path
logger.write("\n", 1)
return 1
-
# The repository where to put the package if not Binary or Source
package_default_path = runner.cfg.USER.workdir
[prop, value] = options.without_property.split(":")
update_config(runner.cfg, prop, value)
- # get the name of the archive or construct it
+ # get the name of the archive or build it
if options.name:
if os.path.basename(options.name) == options.name:
# only a name (not a path)
path_targz = os.path.join(dir_name, archive_name + ".tgz")
- # Print the path of the package
src.printcolors.print_value(logger, "Package path", path_targz, 2)
# Create a working directory for all files that are produced during the
d_files_to_add={} # content of the archive
- # a dict to hold paths that will need to be substitute
- # for users recompilations
+ # a dict to hold paths that will need to be substitute for users recompilations
d_paths_to_substitute={}
if options.binaries:
logger,
options,
tmp_working_dir)
- # for all binaries dir, store the substitution that will be required for extra compilations
+ # for all binaries dir, store the substitution that will be required
+ # for extra compilations
for key in d_bin_files_to_add:
if key.endswith("(bin)"):
source_dir = d_bin_files_to_add[key][0]
logger.write("\n", 1)
return 1
- # CNC revoir la construction de readme
# Add the README file in the package
- #local_readme_tmp_path = add_readme(runner.cfg,
- # package_type,
- # tmp_working_dir)
- #d_files_to_add["README"] = (local_readme_tmp_path, "README")
+ local_readme_tmp_path = add_readme(runner.cfg,
+ options,
+ tmp_working_dir)
+ d_files_to_add["README"] = (local_readme_tmp_path, "README")
# Add the additional files of option add_files
if options.add_files:
-# This package was generated with sat ¤{version}
-# Date: ¤{date}
-# User: ¤{user}
-# Application: ¤{application}
-Important
-=========
-The version of SAlomeTools included in this package is configured to work with
-the application of the package.
+Sources
+=======
-1) Introduction
-===============
+This package includes the sources of the application.
+They are located in the $ROOT/ARCHIVES directory.
-In the following, $ROOT represents the directory where you install your
-application (the directory where this file is located).
-
-The sources of your application are located in the $ROOT/ARCHIVES directory.
-
-This package includes SAlomeTools (sat) a suite of scripts to manage
+It also includes a version of SAlomeTools (sat), a suite of scripts to manage
operations on your application (get sources, compilation, test, packaging ...).
+This version is configured to work with the application of the package.
sat is located in $ROOT and you can read its documentation in
$ROOT/salomeTools/doc or by using:
If you use bash, you can have completion for sat by sourcing $ROOT/salomeTools/complete_sat.sh:
> source $ROOT/salomeTools/complete_sat.sh
-2) Preparing the sources of your application
+
+a) Preparing the sources of your application
============================================
-Tap the following command to get the source and apply the patches:
+Type the following command to get the source and apply the patches:
> $ROOT/sat prepare ¤{application}
-3) Build ¤{application}
+The sources are retrieved from tgz archives located in ARCHIVES directory (or from VCS tools
+if they were included)
+
+
+b) Build ¤{application}
=======================
-Tap the following command to compile and install the products of your application:
-> $ROOT/sat compile ¤{application}
+Type the following command to compile and install the products of your application:
+> $ROOT/sat -t compile ¤{application}
-3) Set environment for libraries inside ¤{application}
+The -t option displays the compilation logs in the terminal.
+
+IMPORTANT :
+This operation may fail if some requiered linux packages are not installed on your system.
+It is also often necessary to install a nvidia driver.
+If you fail to compile and your archive contains pre-compiled binaries,
+and you actually only need to modify a SALOME module, or add an extra one,
+then you may be interrested by a limited compilation based on the binaries used as prerequisites.
+In this case please refer to the instructions after
+(paragraph compilation based on the binaries used as prerequisites).
+
+c) Set environment for libraries inside ¤{application}
======================================================
-Tap the following command to produce the environment files:
+Type the following command to produce the environment files:
> $ROOT/sat environ ¤{application}
-4) Create a SALOME launcher
+d) Create a SALOME launcher
===========================
Create the launcher:
> $ROOT/sat launcher ¤{application}
-5) How to set the Distene license
+IMPORTANT :
+If you package also contains a binary installationn
+this command will overwrite tits launcher.
+In this case, you will still ne able to execute the binary version, wy usig a copy
+of its launcher, called bin¤{launcher}
+
+
+e) How to set the Distene license
=================================
If your application is based on SALOME and embed the SMESH module and MeshGems