From: Serge Rehbinder Date: Mon, 24 Oct 2016 14:32:27 +0000 (+0200) Subject: Handle environment file for binary packages X-Git-Tag: 5.0.0a1~65 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=6dd9a07ae3799e59c907de3b8366f7d484283f27;p=tools%2Fsat.git Handle environment file for binary packages --- diff --git a/commands/package.py b/commands/package.py index 26977fe..1c46174 100644 --- a/commands/package.py +++ b/commands/package.py @@ -199,6 +199,49 @@ def produce_relative_launcher(config, return filepath +def produce_relative_env_files(config, + logger, + file_dir, + binaries_dir_name): + '''Create some specific environment files for the binary package. These + files use relative paths. + + :param config Config: The global configuration. + :param logger Logger: the logging instance + :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. + :return: the list of path of the produced environment files + :rtype: List + ''' + # create an environment file writer + writer = src.environment.FileEnvWriter(config, + logger, + file_dir, + src_root=None) + + # Write + filepath = writer.write_env_file("env_launch.sh", + False, # for launch + "bash", + for_package = binaries_dir_name) + + # Little hack to put out_dir_Path as environment variable + src.replace_in_file(filepath, '"out_dir_Path', '"${out_dir_Path}' ) + + # 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 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. @@ -258,7 +301,7 @@ def binary_package(config, logger, options, tmp_working_dir): for prod_name, install_dir in l_install_dir: path_in_archive = os.path.join(binaries_dir_name, prod_name) d_products[prod_name] = (install_dir, path_in_archive) - + # create the relative launcher and add it to the files to add if "profile" in config.APPLICATION: launcher_name = config.APPLICATION.profile.launcher_name @@ -269,6 +312,14 @@ def binary_package(config, logger, options, tmp_working_dir): binaries_dir_name) d_products["launcher"] = (launcher_package, launcher_name) + else: + # No profile, it means that there has to be some environment files + env_file = produce_relative_env_files(config, + logger, + tmp_working_dir, + binaries_dir_name) + + d_products["environment file"] = (env_file, "env_launch.sh") return d_products diff --git a/src/environment.py b/src/environment.py index d295a5a..597a46b 100644 --- a/src/environment.py +++ b/src/environment.py @@ -715,7 +715,7 @@ class FileEnvWriter: self.silent = True self.env_info = env_info - def write_env_file(self, filename, forBuild, shell): + def write_env_file(self, filename, forBuild, shell, for_package = None): """Create an environment file. :param filename str: the file path @@ -733,7 +733,7 @@ class FileEnvWriter: tmp = src.fileEnviron.get_file_environ(env_file, shell, {}) - env = SalomeEnviron(self.config, tmp, forBuild) + env = SalomeEnviron(self.config, tmp, forBuild, for_package=for_package) env.silent = self.silent # Set the environment @@ -829,4 +829,4 @@ def load_environment(config, build, logger): environ = SalomeEnviron(config, Environ(os.environ), build) environ.set_application_env(logger) environ.set_products(logger) - environ.finish(True) \ No newline at end of file + environ.finish(True)