parser.add_option('', 'bin_products', 'boolean', 'bin_products',
_('Optional: Create binary archives for all products.'), False)
parser.add_option('', 'with_vcs', 'boolean', 'with_vcs',
parser.add_option('', 'bin_products', 'boolean', 'bin_products',
_('Optional: Create binary archives for all products.'), False)
parser.add_option('', 'with_vcs', 'boolean', 'with_vcs',
'Sat prepare will use VCS mode instead to retrieve them.'
'\n Also, when combined with "--bin_products" option, restrict the building of product archives to VCS products.'),
False)
parser.add_option('', 'ftp', 'boolean', 'ftp',
'Sat prepare will use VCS mode instead to retrieve them.'
'\n Also, when combined with "--bin_products" option, restrict the building of product archives to VCS products.'),
False)
parser.add_option('', 'ftp', 'boolean', 'ftp',
'Sat prepare will use ftp instead to retrieve them'),
False)
parser.add_option('e', 'exe', 'string', 'exe',
'Sat prepare will use ftp instead to retrieve them'),
False)
parser.add_option('e', 'exe', 'string', 'exe',
def add_files(tar, name_archive, d_content, logger, f_exclude=None):
'''Create an archive containing all directories and files that are given in
the d_content argument.
def add_files(tar, name_archive, d_content, logger, f_exclude=None):
'''Create an archive containing all directories and files that are given in
the d_content argument.
:param tar tarfile: The tarfile instance used to make the archive.
:param name_archive str: The name of the archive to make.
:param d_content dict: The dictionary that contain all directories and files
to add in the archive.
:param tar tarfile: The tarfile instance used to make the archive.
:param name_archive str: The name of the archive to make.
:param d_content dict: The dictionary that contain all directories and files
to add in the archive.
(path_on_local_machine, path_in_archive)
:param logger Logger: the logging instance
:param f_exclude Function: the function that filters
(path_on_local_machine, path_in_archive)
:param logger Logger: the logging instance
:param f_exclude Function: the function that filters
'''
# get the max length of the messages in order to make the display
max_len = len(max(d_content.keys(), key=len))
'''
# get the max length of the messages in order to make the display
max_len = len(max(d_content.keys(), key=len))
success = 0
# loop over each directory or file stored in the d_content dictionary
names = sorted(d_content.keys())
DBG.write("add tar names", names)
# used to avoid duplications (for pip install in python, or single_install_dir cases)
success = 0
# loop over each directory or file stored in the d_content dictionary
names = sorted(d_content.keys())
DBG.write("add tar names", names)
# used to avoid duplications (for pip install in python, or single_install_dir cases)
for name in names:
# display information
len_points = max_len - len(name) + 3
local_path, archive_path = d_content[name]
in_archive = os.path.join(name_archive, archive_path)
logger.write(name + " " + len_points * "." + " "+ in_archive + " ", 3)
for name in names:
# display information
len_points = max_len - len(name) + 3
local_path, archive_path = d_content[name]
in_archive = os.path.join(name_archive, archive_path)
logger.write(name + " " + len_points * "." + " "+ in_archive + " ", 3)
VCS repositories (like .git) (only for python 2.6)
:param filename Str: The filname to exclude (or not).
VCS repositories (like .git) (only for python 2.6)
:param filename Str: The filname to exclude (or not).
:param config Config: The global configuration.
:param logger Logger: the logging instance
:param file_dir str: the directory where to put the launcher
:param config Config: The global configuration.
:param logger Logger: the logging instance
:param file_dir str: the directory where to put the launcher
# set base mode to "no" for the archive - save current mode to restore it at the end
if "base" in config.APPLICATION:
# set base mode to "no" for the archive - save current mode to restore it at the end
if "base" in config.APPLICATION:
kernel_info = src.product.get_product_config(config, "KERNEL")
kernel_base_name=os.path.basename(kernel_info.install_dir)
if kernel_info.install_mode == "base":
# case of kernel installed in base. the kernel install dir name is different in the archive
kernel_base_name=os.path.basename(os.path.dirname(kernel_info.install_dir))
kernel_info = src.product.get_product_config(config, "KERNEL")
kernel_base_name=os.path.basename(kernel_info.install_dir)
if kernel_info.install_mode == "base":
# case of kernel installed in base. the kernel install dir name is different in the archive
kernel_base_name=os.path.basename(os.path.dirname(kernel_info.install_dir))
kernel_root_dir = os.path.join(binaries_dir_name, kernel_base_name)
# set kernel bin dir (considering fhs property)
kernel_cfg = src.product.get_product_config(config, "KERNEL")
if src.get_property_in_product_cfg(kernel_cfg, "fhs"):
kernel_root_dir = os.path.join(binaries_dir_name, kernel_base_name)
# set kernel bin dir (considering fhs property)
kernel_cfg = src.product.get_product_config(config, "KERNEL")
if src.get_property_in_product_cfg(kernel_cfg, "fhs"):
# in this case get its licence file name
l_product_info = src.product.get_products_infos(config.APPLICATION.products.keys(), config)
# in this case get its licence file name
l_product_info = src.product.get_products_infos(config.APPLICATION.products.keys(), config)
distene_licence_file_name=False
for prod_name, prod_info in l_product_info:
# look for a "salome application" and a distene product
if src.get_property_in_product_cfg(prod_info, "is_distene") == "yes":
distene_licence_file_name=False
for prod_name, prod_info in l_product_info:
# look for a "salome application" and a distene product
if src.get_property_in_product_cfg(prod_info, "is_distene") == "yes":
- distene_licence_file_name = src.product.product_has_licence(prod_info,
- config.PATHS.LICENCEPATH)
+ distene_licence_file_name = src.product.product_has_licence(prod_info,
+ config.PATHS.LICENCEPATH)
if src.get_property_in_product_cfg(prod_info, "is_salome_application") == "yes":
salome_application_name=prod_info.name
if src.get_property_in_product_cfg(prod_info, "is_salome_application") == "yes":
salome_application_name=prod_info.name
filepath = os.path.join(file_dir, file_name)
# Write
writer.write_env_file(filepath,
filepath = os.path.join(file_dir, file_name)
# Write
writer.write_env_file(filepath,
additional_env=additional_env,
no_path_init=False,
for_package = binaries_dir_name)
additional_env=additional_env,
no_path_init=False,
for_package = binaries_dir_name)
# Little hack to put out_dir_Path outside the strings
src.replace_in_file(filepath, 'r"out_dir_Path', 'out_dir_Path + r"' )
src.replace_in_file(filepath, "r'out_dir_Path + ", "out_dir_Path + r'" )
# Little hack to put out_dir_Path outside the strings
src.replace_in_file(filepath, 'r"out_dir_Path', 'out_dir_Path + r"' )
src.replace_in_file(filepath, "r'out_dir_Path + ", "out_dir_Path + r'" )
# A hack to put a call to a file for distene licence.
# It does nothing to an application that has no distene product
if distene_licence_file_name:
logger.write("Application has a distene licence file! We use it in package launcher", 5)
hack_for_distene_licence(filepath, distene_licence_file_name)
# A hack to put a call to a file for distene licence.
# It does nothing to an application that has no distene product
if distene_licence_file_name:
logger.write("Application has a distene licence file! We use it in package launcher", 5)
hack_for_distene_licence(filepath, distene_licence_file_name)
def hack_for_distene_licence(filepath, licence_file):
'''Replace the distene licence env variable by a call to a file.
def hack_for_distene_licence(filepath, licence_file):
'''Replace the distene licence env variable by a call to a file.
shutil.move(filepath, filepath + "_old")
fileout= filepath
filein = filepath + "_old"
shutil.move(filepath, filepath + "_old")
fileout= filepath
filein = filepath + "_old"
:param config Config: The global configuration.
:param logger Logger: the logging instance
:param file_dir str: the directory where to put the files
:param config Config: The global configuration.
:param logger Logger: the logging instance
:param file_dir str: the directory where to put the files
:param exe_name str: if given generate a launcher executing exe_name
:return: the list of path of the produced environment files
:rtype: List
:param exe_name str: if given generate a launcher executing exe_name
:return: the list of path of the produced environment files
:rtype: List
# set base mode to "no" for the archive - save current mode to restore it at the end
if "base" in config.APPLICATION:
# set base mode to "no" for the archive - save current mode to restore it at the end
if "base" in config.APPLICATION:
:param config Config: The global configuration.
:param logger Logger: the logging instance
:param file_dir str: the directory where to put the files
:param config Config: The global configuration.
:param logger Logger: the logging instance
:param file_dir str: the directory where to put the files
# Write
filepath = os.path.join(file_dir, file_name)
# open the file and write into it
# Write
filepath = os.path.join(file_dir, file_name)
# open the file and write into it
with codecs.open(filepath, "w", 'utf-8') as installbin_file:
installbin_template_path = os.path.join(config.VARS.internal_dir,
"INSTALL_BIN.template")
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 = config.INTERNAL.config.binary_dir + config.VARS.dist
# build the substitution loop
# build the name of the directory that will contain the binaries
binaries_dir_name = config.INTERNAL.config.binary_dir + config.VARS.dist
# build the substitution loop
d["BINARIES_DIR"] = binaries_dir_name
d["SUBSTITUTION_LOOP"]=loop_cmd
d["INSTALL_DIR"]=config.INTERNAL.config.install_dir
d["BINARIES_DIR"] = binaries_dir_name
d["SUBSTITUTION_LOOP"]=loop_cmd
d["INSTALL_DIR"]=config.INTERNAL.config.install_dir
# substitute the template and write it in file
content=src.template.substitute(installbin_template_path, d)
installbin_file.write(content)
# substitute the template and write it in file
content=src.template.substitute(installbin_template_path, d)
installbin_file.write(content)
:param config Config: The global configuration.
:param logger Logger: the logging instance
:param file_dir str: the directory where to put the file
:param config Config: The global configuration.
:param logger Logger: the logging instance
:param file_dir str: the directory where to put the file
text_to_fill = open(template_path, "r").read()
text_to_fill = text_to_fill.replace("TO BE FILLED 1",
'"' + binaries_dir_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)
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_cpp(product_info):
# cpp module
for cpp_name in src.product.get_product_components(product_info):
if src.product.product_is_cpp(product_info):
# cpp module
for cpp_name in src.product.get_product_components(product_info):
tmp_file_path = os.path.join(file_dir, "create_appli.py")
ff = open(tmp_file_path, "w")
ff.write(filled_text)
ff.close()
tmp_file_path = os.path.join(file_dir, "create_appli.py")
ff = open(tmp_file_path, "w")
ff.write(filled_text)
ff.close()
l_product_info = src.product.get_products_infos(l_products_name,
config)
# first loop on products : filter products, analyse properties,
l_product_info = src.product.get_products_infos(l_products_name,
config)
# first loop on products : filter products, analyse properties,
l_not_installed=[] # store not installed products for warning at the end
for prod_name, prod_info in l_product_info:
# ignore the native and fixed products for install directories
if (src.get_property_in_product_cfg(prod_info, "not_in_package") == "yes"
l_not_installed=[] # store not installed products for warning at the end
for prod_name, prod_info in l_product_info:
# ignore the native and fixed products for install directories
if (src.get_property_in_product_cfg(prod_info, "not_in_package") == "yes"
bytes = f.read() # read file as bytes
readable_hash = hashlib.md5(bytes).hexdigest();
with open(path_targz_prod+".md5", "w") as md5sum:
bytes = f.read() # read file as bytes
readable_hash = hashlib.md5(bytes).hexdigest();
with open(path_targz_prod+".md5", "w") as md5sum:
def binary_package(config, logger, options, tmp_working_dir):
'''Prepare a dictionary that stores all the needed directories and files to
add in a binary package.
def binary_package(config, logger, options, tmp_working_dir):
'''Prepare a dictionary that stores all the needed directories and files to
add in a binary package.
:param config Config: The global configuration.
:param logger Logger: the logging instance
:param options OptResult: the options of the launched command
:param config Config: The global configuration.
:param logger Logger: the logging instance
:param options OptResult: the options of the launched command
- :param tmp_working_dir str: The temporary local directory containing some
- specific directories or files needed in the
+ :param tmp_working_dir str: The temporary local directory containing some
+ specific directories or files needed in the
generate_mesa_launcher=True
# first loop on products : filter products, analyse properties,
generate_mesa_launcher=True
# first loop on products : filter products, analyse properties,
for prod_name, prod_info in l_product_info:
# skip product with property not_in_package set to yes
if src.get_property_in_product_cfg(prod_info, "not_in_package") == "yes":
for prod_name, prod_info in l_product_info:
# skip product with property not_in_package set to yes
if src.get_property_in_product_cfg(prod_info, "not_in_package") == "yes":
# sources_in_package : "yes"
if src.get_property_in_product_cfg(prod_info,
"sources_in_package") == "yes":
# sources_in_package : "yes"
if src.get_property_in_product_cfg(prod_info,
"sources_in_package") == "yes":
l_sources_not_present.append(prod_name)
# ignore the native and fixed products for install directories
l_sources_not_present.append(prod_name)
# ignore the native and fixed products for install directories
# products with single_dir property will be installed in the PRODUCTS directory of the archive
is_single_dir=(src.appli_test_property(config,"single_install_dir", "yes") and \
src.product.product_test_property(prod_info,"single_install_dir", "yes"))
# products with single_dir property will be installed in the PRODUCTS directory of the archive
is_single_dir=(src.appli_test_property(config,"single_install_dir", "yes") and \
src.product.product_test_property(prod_info,"single_install_dir", "yes"))
is_single_dir, prod_info.install_mode))
else:
l_not_installed.append(prod_name)
is_single_dir, prod_info.install_mode))
else:
l_not_installed.append(prod_name)
# Add also the cpp generated modules (if any)
if src.product.product_is_cpp(prod_info):
# cpp module
for name_cpp in src.product.get_product_components(prod_info):
install_dir = os.path.join(config.APPLICATION.workdir,
config.INTERNAL.config.install_dir,
# Add also the cpp generated modules (if any)
if src.product.product_is_cpp(prod_info):
# cpp module
for name_cpp in src.product.get_product_components(prod_info):
install_dir = os.path.join(config.APPLICATION.workdir,
config.INTERNAL.config.install_dir,
if os.path.exists(install_dir):
l_install_dir.append((name_cpp, name_cpp, install_dir, False, "value"))
else:
l_not_installed.append(name_cpp)
if os.path.exists(install_dir):
l_install_dir.append((name_cpp, name_cpp, install_dir, False, "value"))
else:
l_not_installed.append(name_cpp)
# from previous detar
binaries_from_detar = os.path.join(
config.APPLICATION.workdir,
# from previous detar
binaries_from_detar = os.path.join(
config.APPLICATION.workdir,
- To make new package from this, you have to:
- 1) install binaries in INSTALL directory with the script "install_bin.sh"
+ To make new package from this, you have to:
+ 1) install binaries in INSTALL directory with the script "install_bin.sh"
- 2) or recompile everything in INSTALL with "sat compile" command
- this step is long, and requires some linux packages to be installed
+ 2) or recompile everything in INSTALL with "sat compile" command
+ this step is long, and requires some linux packages to be installed
# construct the name of the directory that will contain the binaries
if src.architecture.is_windows():
binaries_dir_name = config.INTERNAL.config.binary_dir
else:
binaries_dir_name = config.INTERNAL.config.binary_dir + config.VARS.dist
# construct the name of the directory that will contain the binaries
if src.architecture.is_windows():
binaries_dir_name = config.INTERNAL.config.binary_dir
else:
binaries_dir_name = config.INTERNAL.config.binary_dir + config.VARS.dist
# actual install directories and there install directory in archive
d_products = {}
for prod_name, prod_info_name, install_dir, is_single_dir, install_mode in l_install_dir:
prod_base_name=os.path.basename(install_dir)
if install_mode == "base":
# actual install directories and there install directory in archive
d_products = {}
for prod_name, prod_info_name, install_dir, is_single_dir, install_mode in l_install_dir:
prod_base_name=os.path.basename(install_dir)
if install_mode == "base":
# because the archive is in base:no mode, the name of the install dir is different inside archive
# we set it to the product name or by PRODUCTS if single-dir
if is_single_dir:
# because the archive is in base:no mode, the name of the install dir is different inside archive
# we set it to the product name or by PRODUCTS if single-dir
if is_single_dir:
prod_base_name=prod_info_name
path_in_archive = os.path.join(binaries_dir_name, prod_base_name)
d_products[prod_name + " (bin)"] = (install_dir, path_in_archive)
prod_base_name=prod_info_name
path_in_archive = os.path.join(binaries_dir_name, prod_base_name)
d_products[prod_name + " (bin)"] = (install_dir, path_in_archive)
for prod_name, source_dir in l_source_dir:
path_in_archive = os.path.join("SOURCES", prod_name)
d_products[prod_name + " (sources)"] = (source_dir, path_in_archive)
for prod_name, source_dir in l_source_dir:
path_in_archive = os.path.join("SOURCES", prod_name)
d_products[prod_name + " (sources)"] = (source_dir, path_in_archive)
tar_log.add(logpath, arcname="LOGS")
tar_log.close()
d_products["LOGS"] = (path_targz_logs, "logs.tgz")
tar_log.add(logpath, arcname="LOGS")
tar_log.close()
d_products["LOGS"] = (path_targz_logs, "logs.tgz")
# we produce a salome launcher or a virtual application (depending on salome version)
if 'KERNEL' in config.APPLICATION.products:
VersionSalome = src.get_salome_version(config)
# Case where SALOME has the launcher that uses the SalomeContext API
# we produce a salome launcher or a virtual application (depending on salome version)
if 'KERNEL' in config.APPLICATION.products:
VersionSalome = src.get_salome_version(config)
# Case where SALOME has the launcher that uses the SalomeContext API
# create the relative launcher and add it to the files to add
launcher_name = src.get_launcher_name(config)
launcher_package = produce_relative_launcher(config,
# create the relative launcher and add it to the files to add
launcher_name = src.get_launcher_name(config)
launcher_package = produce_relative_launcher(config,
- # if the application contains mesa products, we generate in addition to the
- # classical salome launcher a launcher using mesa and called mesa_salome
+ # if the application contains mesa products, we generate in addition to the
+ # classical salome launcher a launcher using mesa and called mesa_salome
# (the mesa launcher will be used for remote usage through ssh).
if generate_mesa_launcher:
#if there is one : store the use_mesa property
restore_use_mesa_option=None
# (the mesa launcher will be used for remote usage through ssh).
if generate_mesa_launcher:
#if there is one : store the use_mesa property
restore_use_mesa_option=None
'use_mesa' in config.APPLICATION.properties):
restore_use_mesa_option = config.APPLICATION.properties.use_mesa
'use_mesa' in config.APPLICATION.properties):
restore_use_mesa_option = config.APPLICATION.properties.use_mesa
# prefixed with "bin",in order to avoid clashes
launcher_copy_name="bin"+launcher_name
launcher_package_copy = produce_relative_launcher(config,
# prefixed with "bin",in order to avoid clashes
launcher_copy_name="bin"+launcher_name
launcher_package_copy = produce_relative_launcher(config,
d_products["appli script"] = (appli_script, "create_appli.py")
# Put also the environment file
d_products["appli script"] = (appli_script, "create_appli.py")
# Put also the environment file
if src.architecture.is_windows():
filename = os.path.basename(options.exe) + ".bat"
else:
filename = os.path.basename(options.exe) + ".sh"
if src.architecture.is_windows():
filename = os.path.basename(options.exe) + ".bat"
else:
filename = os.path.basename(options.exe) + ".sh"
return d_products
def source_package(sat, config, logger, options, tmp_working_dir):
'''Prepare a dictionary that stores all the needed directories and files to
add in a source package.
return d_products
def source_package(sat, config, logger, options, tmp_working_dir):
'''Prepare a dictionary that stores all the needed directories and files to
add in a source package.
:param config Config: The global configuration.
:param logger Logger: the logging instance
:param options OptResult: the options of the launched command
:param config Config: The global configuration.
:param logger Logger: the logging instance
:param options OptResult: the options of the launched command
- :param tmp_working_dir str: The temporary local directory containing some
- specific directories or files needed in the
+ :param tmp_working_dir str: The temporary local directory containing some
+ specific directories or files needed in the
binary package
:return: the dictionary that stores all the needed directories and files to
add in a source package.
{label : (path_on_local_machine, path_in_archive)}
:rtype: dict
'''
binary package
:return: the dictionary that stores all the needed directories and files to
add in a source package.
{label : (path_on_local_machine, path_in_archive)}
:rtype: dict
'''
d_archives={}
# Get all the products that are prepared using an archive
# unless ftp mode is specified (in this case the user of the
d_archives={}
# Get all the products that are prepared using an archive
# unless ftp mode is specified (in this case the user of the
# Add salomeTools
tmp_sat = add_salomeTools(config, tmp_working_dir)
d_sat = {"salomeTools" : (tmp_sat, "sat")}
# Add salomeTools
tmp_sat = add_salomeTools(config, tmp_working_dir)
d_sat = {"salomeTools" : (tmp_sat, "sat")}
-
- d_sat["sat archive link"] = (os.path.join(tmp_working_dir,"PROJECT", "ARCHIVES"),
+
+ d_sat["sat archive link"] = (os.path.join(tmp_working_dir,"PROJECT", "ARCHIVES"),
d_source = src.merge_dicts(d_archives, d_archives_vcs, d_project, d_sat)
return d_source
def get_archives(config, logger):
'''Find all the products that are get using an archive and all the products
that are get using a vcs (git, cvs, svn) repository.
d_source = src.merge_dicts(d_archives, d_archives_vcs, d_project, d_sat)
return d_source
def get_archives(config, logger):
'''Find all the products that are get using an archive and all the products
that are get using a vcs (git, cvs, svn) repository.
for p_name, p_info in l_product_info:
# skip product with property not_in_package set to yes
if src.get_property_in_product_cfg(p_info, "not_in_package") == "yes":
for p_name, p_info in l_product_info:
# skip product with property not_in_package set to yes
if src.get_property_in_product_cfg(p_info, "not_in_package") == "yes":
archive_name = os.path.basename(archive_path)
d_archives[p_name] = (archive_path,
os.path.join(ARCHIVE_DIR, archive_name))
archive_name = os.path.basename(archive_path)
d_archives[p_name] = (archive_path,
os.path.join(ARCHIVE_DIR, archive_name))
src.product.product_test_property(p_info,"pip", "yes")):
# if pip mode is activated, and product is managed by pip
pip_wheels_dir=os.path.join(config.LOCAL.archive_dir,"wheels")
src.product.product_test_property(p_info,"pip", "yes")):
# if pip mode is activated, and product is managed by pip
pip_wheels_dir=os.path.join(config.LOCAL.archive_dir,"wheels")
"%s-%s*" % (p_info.name, p_info.version))
pip_wheel_path=glob.glob(pip_wheel_pattern)
msg_pip_not_found="Error in get_archive, pip wheel for "\
"%s-%s*" % (p_info.name, p_info.version))
pip_wheel_path=glob.glob(pip_wheel_pattern)
msg_pip_not_found="Error in get_archive, pip wheel for "\
(p_info.name, p_info.version, pip_wheels_dir))
pip_wheel_name=os.path.basename(pip_wheel_path[0])
(p_info.name, p_info.version, pip_wheels_dir))
pip_wheel_name=os.path.basename(pip_wheel_path[0])
return d_archives, l_pinfo_vcs
def add_salomeTools(config, tmp_working_dir):
return d_archives, l_pinfo_vcs
def add_salomeTools(config, tmp_working_dir):
- :param tmp_working_dir str: The temporary local directory containing some
- specific directories or files needed in the
+ :param tmp_working_dir str: The temporary local directory containing some
+ specific directories or files needed in the
sat_tmp_path = src.Path(os.path.join(tmp_working_dir, "salomeTools"))
sat_running_path = src.Path(config.VARS.salometoolsway)
sat_running_path.copy(sat_tmp_path)
sat_tmp_path = src.Path(os.path.join(tmp_working_dir, "salomeTools"))
sat_running_path = src.Path(config.VARS.salometoolsway)
sat_running_path.copy(sat_tmp_path)
# Update the local.pyconf file that contains the path to the project
local_pyconf_name = "local.pyconf"
local_pyconf_dir = os.path.join(tmp_working_dir, "salomeTools", "data")
local_pyconf_file = os.path.join(local_pyconf_dir, local_pyconf_name)
# Remove the .pyconf file in the root directory of salomeTools if there is
# Update the local.pyconf file that contains the path to the project
local_pyconf_name = "local.pyconf"
local_pyconf_dir = os.path.join(tmp_working_dir, "salomeTools", "data")
local_pyconf_file = os.path.join(local_pyconf_dir, local_pyconf_name)
# Remove the .pyconf file in the root directory of salomeTools if there is
- # any. (For example when launching jobs, a pyconf file describing the jobs
- # can be here and is not useful)
+ # any. (For example when launching jobs, a pyconf file describing the jobs
+ # can be here and is not useful)
files_or_dir_SAT = os.listdir(os.path.join(tmp_working_dir, "salomeTools"))
for file_or_dir in files_or_dir_SAT:
if file_or_dir.endswith(".pyconf") or file_or_dir.endswith(".txt"):
files_or_dir_SAT = os.listdir(os.path.join(tmp_working_dir, "salomeTools"))
for file_or_dir in files_or_dir_SAT:
if file_or_dir.endswith(".pyconf") or file_or_dir.endswith(".txt"):
return sat_tmp_path.path
def get_archives_vcs(l_pinfo_vcs, sat, config, logger, tmp_working_dir):
return sat_tmp_path.path
def get_archives_vcs(l_pinfo_vcs, sat, config, logger, tmp_working_dir):
archive, one has to create some archive for the vcs products.
So this method calls the clean and source command of sat and then create
the archives.
archive, one has to create some archive for the vcs products.
So this method calls the clean and source command of sat and then create
the archives.
- :param tmp_working_dir str: The temporary local directory containing some
- specific directories or files needed in the
+ :param tmp_working_dir str: The temporary local directory containing some
+ specific directories or files needed in the
# command and thus construct an archive that will not contain the patches
l_prod_names = [pn for pn, __ in l_pinfo_vcs]
if False: # clean is dangerous in user/SOURCES, fixed in tmp_local_working_dir
# command and thus construct an archive that will not contain the patches
l_prod_names = [pn for pn, __ in l_pinfo_vcs]
if False: # clean is dangerous in user/SOURCES, fixed in tmp_local_working_dir
# sat.source(args_source, batch=True, verbose=5, logger_add_link = logger)
import source
source.run(args_source, sat, logger) #use this mode as runner.cfg reference
# sat.source(args_source, batch=True, verbose=5, logger_add_link = logger)
import source
source.run(args_source, sat, logger) #use this mode as runner.cfg reference
'''Create an archive of a product by searching its source directory.
:param prod_name str: The name of the product.
'''Create an archive of a product by searching its source directory.
:param prod_name str: The name of the product.
bin_path = prod_info.install_dir
tar_prod.add(bin_path, arcname=path_targz_prod)
tar_prod.close()
bin_path = prod_info.install_dir
tar_prod.add(bin_path, arcname=path_targz_prod)
tar_prod.close()
def make_archive(prod_name, prod_info, where):
'''Create an archive of a product by searching its source directory.
:param prod_name str: The name of the product.
def make_archive(prod_name, prod_info, where):
'''Create an archive of a product by searching its source directory.
:param prod_name str: The name of the product.
def create_project_for_src_package(config, tmp_working_dir, with_vcs, with_ftp):
'''Create a specific project for a source package.
:param config Config: The global configuration.
def create_project_for_src_package(config, tmp_working_dir, with_vcs, with_ftp):
'''Create a specific project for a source package.
:param config Config: The global configuration.
- :param tmp_working_dir str: The temporary local directory containing some
- specific directories or files needed in the
+ :param tmp_working_dir str: The temporary local directory containing some
+ specific directories or files needed in the
transformed into archive products)
:param with_ftp boolean: True if the package use ftp servers to get archives
transformed into archive products)
:param with_ftp boolean: True if the package use ftp servers to get archives
project_pyconf_file = os.path.join(project_tmp_dir, project_pyconf_name)
ff = open(project_pyconf_file, "w")
ff.write(PROJECT_TEMPLATE)
project_pyconf_file = os.path.join(project_tmp_dir, project_pyconf_name)
ff = open(project_pyconf_file, "w")
ff.write(PROJECT_TEMPLATE)
licence_path='LICENCEPATH : "'+config.PATHS.LICENCEPATH[0]
for path in config.PATHS.LICENCEPATH[1:]:
licence_path=licence_path+":"+path
licence_path+='"'
ff.write("\n# Where to search for licences\n")
ff.write(licence_path)
licence_path='LICENCEPATH : "'+config.PATHS.LICENCEPATH[0]
for path in config.PATHS.LICENCEPATH[1:]:
licence_path=licence_path+":"+path
licence_path+='"'
ff.write("\n# Where to search for licences\n")
ff.write(licence_path)
# (compilation, environment, patches)
# and create the pyconf file to add to the project
lproducts_name = config.APPLICATION.products.keys()
# (compilation, environment, patches)
# and create the pyconf file to add to the project
lproducts_name = config.APPLICATION.products.keys()
for p_name, p_info in l_products:
# skip product with property not_in_package set to yes
if src.get_property_in_product_cfg(p_info, "not_in_package") == "yes":
for p_name, p_info in l_products:
# skip product with property not_in_package set to yes
if src.get_property_in_product_cfg(p_info, "not_in_package") == "yes":
# for the application pyconf, we write directly the config
# don't search for the original pyconf file
# to avoid problems with overwrite sections and rm_products key
write_application_pyconf(config, application_tmp_dir)
# for the application pyconf, we write directly the config
# don't search for the original pyconf file
# to avoid problems with overwrite sections and rm_products key
write_application_pyconf(config, application_tmp_dir)
script, its compilation script and patches and put it in the temporary
working directory. This method is used in the source package in order to
construct the specific project.
:param p_name str: The name of the product.
script, its compilation script and patches and put it in the temporary
working directory. This method is used in the source package in order to
construct the specific project.
:param p_name str: The name of the product.
# save git repositories for vcs products, even if archive is not in VCS mode
# in this case the user will be able to change get_source flag and work with git
if src.product.product_is_vcs(p_info):
# save git repositories for vcs products, even if archive is not in VCS mode
# in this case the user will be able to change get_source flag and work with git
if src.product.product_is_vcs(p_info):
directory containing the specific project of a source package.
:param config Config: The global configuration.
directory containing the specific project of a source package.
:param config Config: The global configuration.
'LOCAL.workdir')
res.addMapping("APPLICATION", app, "")
res.__save__(f, evaluated=False)
'LOCAL.workdir')
res.addMapping("APPLICATION", app, "")
res.__save__(f, evaluated=False)
def sat_package(config, tmp_working_dir, options, logger):
'''Prepare a dictionary that stores all the needed directories and files to
add in a salomeTool package.
def sat_package(config, tmp_working_dir, options, logger):
'''Prepare a dictionary that stores all the needed directories and files to
add in a salomeTool package.
:param options OptResult: the options of the launched command
:return: the dictionary that stores all the needed directories and files to
add in a salomeTool package.
:param options OptResult: the options of the launched command
:return: the dictionary that stores all the needed directories and files to
add in a salomeTool package.
os.path.basename(options.project_file_path))
local_cfg.PROJECTS.project_file_paths.append(project_arch_path, "")
os.path.basename(options.project_file_path))
local_cfg.PROJECTS.project_file_paths.append(project_arch_path, "")
def project_package(config, name_project, project_file_path, ftp_mode, tmp_working_dir, embedded_in_sat, logger):
'''Prepare a dictionary that stores all the needed directories and files to
add in a project package.
def project_package(config, name_project, project_file_path, ftp_mode, tmp_working_dir, embedded_in_sat, logger):
'''Prepare a dictionary that stores all the needed directories and files to
add in a project package.
:param project_file_path str: The path to the local project.
:param ftp_mode boolean: Do not embed archives, the archive will rely on ftp mode to retrieve them.
:param project_file_path str: The path to the local project.
:param ftp_mode boolean: Do not embed archives, the archive will rely on ftp mode to retrieve them.
- :param tmp_working_dir str: The temporary local directory containing some
- specific directories or files needed in the
+ :param tmp_working_dir str: The temporary local directory containing some
+ specific directories or files needed in the
project package
:param embedded_in_sat boolean : the project package is embedded in a sat package
:return: the dictionary that stores all the needed directories and files to
project package
:param embedded_in_sat boolean : the project package is embedded in a sat package
:return: the dictionary that stores all the needed directories and files to
project_pyconf_cfg = config.PROJECTS.projects.__getattr__(name_project)
except:
logger.write("""
WARNING: inexisting config.PROJECTS.projects.%s, try to read now from:\n%s\n""" % (name_project, project_file_path))
project_pyconf_cfg = src.pyconf.Config(project_file_path)
project_pyconf_cfg.PWD = os.path.dirname(project_file_path)
project_pyconf_cfg = config.PROJECTS.projects.__getattr__(name_project)
except:
logger.write("""
WARNING: inexisting config.PROJECTS.projects.%s, try to read now from:\n%s\n""" % (name_project, project_file_path))
project_pyconf_cfg = src.pyconf.Config(project_file_path)
project_pyconf_cfg.PWD = os.path.dirname(project_file_path)
paths = {"APPLICATIONPATH" : "applications",
"PRODUCTPATH" : "products",
"JOBPATH" : "jobs",
paths = {"APPLICATIONPATH" : "applications",
"PRODUCTPATH" : "products",
"JOBPATH" : "jobs",
# Modify some values
if "project_path" not in project_pyconf_cfg:
project_pyconf_cfg.addMapping("project_path",
# Modify some values
if "project_path" not in project_pyconf_cfg:
project_pyconf_cfg.addMapping("project_path",
# Write the project pyconf file
project_pyconf_tmp_path = os.path.join(tmp_working_dir, project_file_name)
ff = open(project_pyconf_tmp_path, 'w')
# Write the project pyconf file
project_pyconf_tmp_path = os.path.join(tmp_working_dir, project_file_name)
ff = open(project_pyconf_tmp_path, 'w')
project_pyconf_cfg.__save__(ff, 1)
ff.close()
d_project["Project hat file"] = (project_pyconf_tmp_path, project_file_dest)
project_pyconf_cfg.__save__(ff, 1)
ff.close()
d_project["Project hat file"] = (project_pyconf_tmp_path, project_file_dest)
if 'KERNEL' in config.APPLICATION.products:
VersionSalome = src.get_salome_version(config)
# Case where SALOME has the launcher that uses the SalomeContext API
if 'KERNEL' in config.APPLICATION.products:
VersionSalome = src.get_salome_version(config)
# Case where SALOME has the launcher that uses the SalomeContext API
d['launcher'] = config.APPLICATION.profile.launcher_name
else:
d['virtual_app'] = 'runAppli' # this info is not used now)
d['launcher'] = config.APPLICATION.profile.launcher_name
else:
d['virtual_app'] = 'runAppli' # this info is not used now)
return readme_path
def update_config(config, logger, prop, value):
'''Remove from config.APPLICATION.products the products that have the property given as input.
return readme_path
def update_config(config, logger, prop, value):
'''Remove from config.APPLICATION.products the products that have the property given as input.
:param config Config: The global config.
:param prop str: The property to filter
:param value str: The value of the property to filter
:param config Config: The global config.
:param prop str: The property to filter
:param value str: The value of the property to filter
The package command creates a tar file archive of a product.
There are four kinds of archive, which can be mixed:
The package command creates a tar file archive of a product.
There are four kinds of archive, which can be mixed:
def run(args, runner, logger):
'''method that is called when salomeTools is called with package parameter.
'''
def run(args, runner, logger):
'''method that is called when salomeTools is called with package parameter.
'''
# Check that a type of package is called, and only one
all_option_types = (options.binaries,
options.sources,
# Check that a type of package is called, and only one
all_option_types = (options.binaries,
options.sources,
# The repository where to put the package if not Binary or Source
package_default_path = runner.cfg.LOCAL.workdir
# The repository where to put the package if not Binary or Source
package_default_path = runner.cfg.LOCAL.workdir
# Display information
logger.write(_("Packaging application %s\n") % src.printcolors.printcLabel(
runner.cfg.VARS.application), 1)
# Display information
logger.write(_("Packaging application %s\n") % src.printcolors.printcLabel(
runner.cfg.VARS.application), 1)
# Get the default directory where to put the packages
package_default_path = os.path.join(runner.cfg.APPLICATION.workdir, "PACKAGE")
src.ensure_path_exists(package_default_path)
# Get the default directory where to put the packages
package_default_path = os.path.join(runner.cfg.APPLICATION.workdir, "PACKAGE")
src.ensure_path_exists(package_default_path)
else:
options.project_file_path = foundProject
src.printcolors.print_value(logger, "Project path", options.project_file_path, 2)
else:
options.project_file_path = foundProject
src.printcolors.print_value(logger, "Project path", options.project_file_path, 2)
# Remove the products that are filtered by the --without_properties option
if options.without_properties:
prop, value = options.without_properties
# Remove the products that are filtered by the --without_properties option
if options.without_properties:
prop, value = options.without_properties
dir_name = package_default_path
else:
archive_name = os.path.basename(options.name)
dir_name = os.path.dirname(options.name)
dir_name = package_default_path
else:
archive_name = os.path.basename(options.name)
dir_name = os.path.dirname(options.name)
# suppress extension
if archive_name[-len(".tgz"):] == ".tgz":
archive_name = archive_name[:-len(".tgz")]
if archive_name[-len(".tar.gz"):] == ".tar.gz":
archive_name = archive_name[:-len(".tar.gz")]
# suppress extension
if archive_name[-len(".tgz"):] == ".tgz":
archive_name = archive_name[:-len(".tgz")]
if archive_name[-len(".tar.gz"):] == ".tar.gz":
archive_name = archive_name[:-len(".tar.gz")]
msg = _("Error: Cannot name the archive\n"
" check if at least one of the following options was "
"selected : --binaries, --sources, --project or"
msg = _("Error: Cannot name the archive\n"
" check if at least one of the following options was "
"selected : --binaries, --sources, --project or"
src.printcolors.print_value(logger, "Package path", path_targz, 2)
# Create a working directory for all files that are produced during the
src.printcolors.print_value(logger, "Package path", path_targz, 2)
# Create a working directory for all files that are produced during the
src.ensure_path_exists(tmp_working_dir)
logger.write("\n", 5)
logger.write(_("The temporary working directory: %s\n" % tmp_working_dir),5)
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)
msg = _("Preparation of files to add to the archive")
logger.write(src.printcolors.printcLabel(msg), 2)
logger.write("\n", 2)
logger.write("\n", 3)
msg = _("Preparation of files to add to the archive")
logger.write(src.printcolors.printcLabel(msg), 2)
logger.write("\n", 2)
d_files_to_add={} # content of the archive
# a dict to hold paths that will need to be substitute for users recompilations
d_files_to_add={} # content of the archive
# a dict to hold paths that will need to be substitute for users recompilations
runner.cfg.INTERNAL.config.binary_dir + runner.cfg.VARS.dist,
runner.cfg.INTERNAL.config.install_dir)
if os.path.basename(source_dir)==os.path.basename(path_in_archive):
runner.cfg.INTERNAL.config.binary_dir + runner.cfg.VARS.dist,
runner.cfg.INTERNAL.config.install_dir)
if os.path.basename(source_dir)==os.path.basename(path_in_archive):
# install binaries for compilation
file_install_bin=produce_install_bin_file(runner.cfg,logger,
tmp_working_dir,
# install binaries for compilation
file_install_bin=produce_install_bin_file(runner.cfg,logger,
tmp_working_dir,
# --salomeTool option is not considered when --sources is selected, as this option
# already brings salomeTool!
if options.sat:
# --salomeTool option is not considered when --sources is selected, as this option
# already brings salomeTool!
if options.sat:
if options.project:
DBG.write("config for package %s" % options.project, runner.cfg)
d_files_to_add.update(project_package(runner.cfg, options.project, options.project_file_path, options.ftp, tmp_working_dir, options.sat, logger))
if options.project:
DBG.write("config for package %s" % options.project, runner.cfg)
d_files_to_add.update(project_package(runner.cfg, options.project, options.project_file_path, options.ftp, tmp_working_dir, options.sat, logger))
try:
# Creating the object tarfile
tar = tarfile.open(path_targz, mode='w:gz')
try:
# Creating the object tarfile
tar = tarfile.open(path_targz, mode='w:gz')
# case if no application, only package sat as 'sat package -t'
try:
app = runner.cfg.APPLICATION
# case if no application, only package sat as 'sat package -t'
try:
app = runner.cfg.APPLICATION
# remove the tmp directory, unless user has registered as developer
if os.path.isdir(tmp_working_dir) and (not DBG.isDeveloper()):
shutil.rmtree(tmp_working_dir)
# remove the tmp directory, unless user has registered as developer
if os.path.isdir(tmp_working_dir) and (not DBG.isDeveloper()):
shutil.rmtree(tmp_working_dir)
# Print again the path of the package
logger.write("\n", 2)
src.printcolors.print_value(logger, "Package path", path_targz, 2)
# Print again the path of the package
logger.write("\n", 2)
src.printcolors.print_value(logger, "Package path", path_targz, 2)