import os
import stat
import shutil
+import datetime
import tarfile
import src
parser = src.options.Options()
parser.add_option('b', 'binaries', 'boolean', 'binaries',
_('Produce a binary package.'), False)
+parser.add_option('f', 'force_creation', 'boolean', 'force_creation',
+ _('Only binary package: produce the archive even if there are some missing '
+ 'products.'), False)
+parser.add_option('', 'with_sources', 'boolean', 'with_sources',
+ _('Only binary package: produce and and a source archive in the binary '
+ 'package.'), False)
parser.add_option('s', 'sources', 'boolean', 'sources',
_('Produce a compilable archive of the sources of the application.'), False)
+parser.add_option('', 'with_vcs', 'boolean', 'with_vcs',
+ _('Only source package: do not make archive of vcs products.'), False)
parser.add_option('p', 'project', 'string', 'project',
_('Produce an archive that contains a project.'), "")
-parser.add_option('', 'salometools', 'boolean', 'sat',
+parser.add_option('t', 'salometools', 'boolean', 'sat',
_('Produce an archive that contains salomeTools.'), False)
parser.add_option('n', 'name', 'string', 'name',
_('The name or full path of the archive.'), None)
-parser.add_option('', 'with_vcs', 'boolean', 'with_vcs',
- _('Only source package: do not make archive of vcs products.'), False)
def add_files(tar, name_archive, d_content, logger):
'''Create an archive containing all directories and files that are given in
# Get the launcher template
profile_install_dir = os.path.join(binaries_dir_name,
config.APPLICATION.profile.product)
- withProfile = src.fileEnviron.withProfile
+ withProfile = src.fileEnviron.withProfile
withProfile = withProfile.replace(
"ABSOLUTE_APPLI_PATH'] = 'PROFILE_INSTALL_DIR'",
- "ABSOLUTE_APPLI_PATH'] = out_dir_Path + '/" + profile_install_dir + "'")
+ "ABSOLUTE_APPLI_PATH'] = out_dir_Path + '" + config.VARS.sep + profile_install_dir + "'")
withProfile = withProfile.replace(
"os.path.join( 'PROFILE_INSTALL_DIR'",
"os.path.join( out_dir_Path, '" + profile_install_dir + "'")
return d_project
+def add_readme(config, package_type, 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
+ 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")
+ 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")
+
+ 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")
+
+ 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))
+
+ return readme_path
+
+
def description():
'''method that is called when salomeTools is called with --help option.
# Check that a type of package is called, and only one
all_option_types = (options.binaries,
options.sources,
- options.project != "",
+ options.project not in ["", None],
options.sat)
# Check if no option for package type
archive_name = (runner.cfg.APPLICATION.name +
"-" +
"SRC")
+ if options.with_vcs:
+ archive_name = (runner.cfg.APPLICATION.name +
+ "-" +
+ "SRC" +
+ "-" +
+ "VCS")
if package_type == PROJECT:
project_name, __ = os.path.splitext(
tmp_working_dir = os.path.join(runner.cfg.VARS.tmp_root,
runner.cfg.VARS.datehour)
src.ensure_path_exists(tmp_working_dir)
+ logger.write("\n", 5)
+ logger.write(_("The temporary working directory: %s\n" % tmp_working_dir),5)
logger.write("\n", 3)
logger.write(src.printcolors.printcLabel(msg), 2)
logger.write("\n", 2)
- if package_type == BINARY:
+ if package_type == BINARY:
d_files_to_add = binary_package(runner.cfg,
logger,
options,
tmp_working_dir)
if not(d_files_to_add):
return 1
+
+ # Create and add the source package
+ # if the option "with_sources" is called
+ if options.with_sources:
+ logger.write(_("Create a source archive (can be long) ... "), 3)
+ tmp_pkg_src_name = runner.cfg.APPLICATION.name + "-" + "SRC.tgz"
+ tmp_pkg_src_path = os.path.join(tmp_working_dir, tmp_pkg_src_name)
+ package_options = runner.cfg.VARS.application
+ package_options += " --sources --with_vcs --name "
+ package_options += tmp_pkg_src_path
+ # sat package <package_options>
+ runner.package(package_options,
+ batch = True,
+ verbose = 0,
+ logger_add_link = logger)
+ d_files_to_add["SOURCES PACKAGE"] = (tmp_pkg_src_path,
+ tmp_pkg_src_name)
+ logger.write(src.printcolors.printc("OK"), 3)
+ logger.write("\n", 3)
if package_type == SOURCE:
d_files_to_add = source_package(runner,
if package_type == SAT:
d_files_to_add = {"salomeTools" : (runner.cfg.VARS.salometoolsway, "")}
+ # 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")
+
logger.write("\n", 2)
logger.write(src.printcolors.printcLabel(_("Actually do the package")), 2)
logger.write("\n", 2)
- # Creating the object tarfile
- tar = tarfile.open(path_targz, mode='w:gz')
-
- # Add the files to the tarfile object
- res = add_files(tar, archive_name, d_files_to_add, logger)
- tar.close()
+ try:
+ # Creating the object tarfile
+ tar = tarfile.open(path_targz, mode='w:gz')
+
+ # Add the files to the tarfile object
+ res = add_files(tar, archive_name, d_files_to_add, logger)
+ tar.close()
+ except KeyboardInterrupt:
+ logger.write(src.printcolors.printcError("\nERROR: forced interruption\n"), 1)
+ logger.write(_("Removing the temporary working directory ... "), 1)
+ # remove the working directory
+ shutil.rmtree(tmp_working_dir)
+ logger.write(_("OK"), 1)
+ logger.write(_("\n"), 1)
+ return 1
- # remove the working directory
+ # remove the working directory
shutil.rmtree(tmp_working_dir)
# Print again the path of the package
--- /dev/null
+# 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.
+
+1) Introduction
+===============
+
+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
+operations on your application (get sources, compilation, test, packaging ...).
+
+sat is located in $ROOT and you can read its documentation in
+$ROOT/salomeTools/doc or by using:
+> $ROOT/sat --help
+> $ROOT/sat doc
+
+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
+============================================
+Tap the following command to get the source and apply the patches:
+> $ROOT/sat prepare ¤{application}
+
+3) Build ¤{application}
+=======================
+Tap the following command to compile and install the products of your application:
+> $ROOT/sat compile ¤{application}
+
+3) Set environment for libraries inside ¤{application}
+======================================================
+Tap the following command to produce the environment files:
+> $ROOT/sat environ ¤{application}
+
+4) Create a SALOME launcher
+===========================
+
+Create the launcher:
+> $ROOT/sat launcher ¤{application}
+
+5) How to set the Distene license
+=================================
+
+If your application is based on SALOME and embed the SMESH module and MeshGems
+prerequisite, you may want to set the Distene license.
+To do so, edit the following file:
+
+> $ROOT/INSTALL/¤{profile}/bin/salome/¤{launcher}
+
+Then, find the lines that begin with:
+
+ #[MeshGems]
+ # Here you can define your license parameters for MeshGems
+
+Set the variables corresponding to your licence after these lines.