From 92c19115a4571b5c0981ae8edc7382fe6a84339c Mon Sep 17 00:00:00 2001 From: crouzet Date: Tue, 2 Mar 2021 17:14:06 +0100 Subject: [PATCH] =?utf8?q?nouvelle=20option=20sat=20package=20-e=20pour=20?= =?utf8?q?inclure=20dans=20l'archive=20un=20lanceur=20bas=C3=A9=20sur=20un?= =?utf8?q?=20executable?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- commands/package.py | 33 ++++++++++++++++++++++++++++++++- complete_sat.sh | 2 +- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/commands/package.py b/commands/package.py index da5fe6f..1e275cf 100644 --- a/commands/package.py +++ b/commands/package.py @@ -104,6 +104,8 @@ parser.add_option('', 'ftp', 'boolean', 'ftp', _('Optional: Do not embed archives for products in archive mode.' 'Sat prepare will use ftp instead to retrieve them'), False) +parser.add_option('e', 'exe', 'string', 'exe', + _('Optional: Produce an extra launcher based upon the exe given as argument.'), "") parser.add_option('p', 'project', 'string', 'project', _('Optional: Produce an archive that contains a project.'), "") parser.add_option('t', 'salometools', 'boolean', 'sat', @@ -367,7 +369,8 @@ def hack_for_distene_licence(filepath, licence_file): def produce_relative_env_files(config, logger, file_dir, - binaries_dir_name): + binaries_dir_name, + exe_name=None): '''Create some specific environment files for the binary package. These files use relative paths. @@ -376,6 +379,7 @@ def produce_relative_env_files(config, :param file_dir str: the directory where to put the files :param binaries_dir_name str: the name of the repository where the binaries are, in the archive. + :param exe_name str: if given generate a launcher executing exe_name :return: the list of path of the produced environment files :rtype: List ''' @@ -392,6 +396,9 @@ def produce_relative_env_files(config, shell = "bash" filename = "env_launch.sh" + if exe_name: + filename=os.path.basename(exe_name) + # Write filepath = writer.write_env_file(filename, False, # for launch @@ -407,6 +414,14 @@ def produce_relative_env_files(config, src.replace_in_file(filepath, '"out_dir_Path', '"${out_dir_Path}' ) src.replace_in_file(filepath, ':out_dir_Path', ':${out_dir_Path}' ) + if exe_name: + if src.architecture.is_windows(): + cmd="\n\nrem Launch exe with user arguments\n%s " % exe_name + "%*" + else: + cmd='\n\n# Launch exe with user arguments\n%s "$*"' % exe_name + with open(filepath, "a") as exe_launcher: + exe_launcher.write(cmd) + # change the rights in order to make the file executable for everybody os.chmod(filepath, stat.S_IRUSR | @@ -757,6 +772,22 @@ WARNING: existing binaries directory from previous detar installation: else: filename = "env_launch.sh" d_products["environment file"] = (env_file, filename) + + # If option exe, produce an extra launcher based on specified exe + if options.exe: + exe_file = produce_relative_env_files(config, + logger, + tmp_working_dir, + binaries_dir_name, + options.exe) + + if src.architecture.is_windows(): + filename = os.path.basename(options.exe) + ".bat" + else: + filename = os.path.basename(options.exe) + ".sh" + d_products["exe file"] = (exe_file, filename) + + return d_products def source_package(sat, config, logger, options, tmp_working_dir): diff --git a/complete_sat.sh b/complete_sat.sh index 53dbdb4..7470b1b 100755 --- a/complete_sat.sh +++ b/complete_sat.sh @@ -237,7 +237,7 @@ _salomeTools_complete() return 0 ;; package) - opts="--name --binaries --sources --project --salometools --force_creation --add_files --with_vcs --ftp --without_property" + opts="--name --binaries --sources --exe --project --salometools --force_creation --add_files --with_vcs --ftp --without_property" COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) return 0 ;; -- 2.39.2