]> SALOME platform Git repositories - tools/sat.git/commitdiff
Salome HOME
Handle environment file for binary packages
authorSerge Rehbinder <serge.rehbinder@cea.fr>
Mon, 24 Oct 2016 14:32:27 +0000 (16:32 +0200)
committerSerge Rehbinder <serge.rehbinder@cea.fr>
Mon, 24 Oct 2016 14:32:27 +0000 (16:32 +0200)
commands/package.py
src/environment.py

index 26977febe56304dfcc2cedbd17803c63d8409356..1c461742c8338a10512b0ded223d0a9d4102c359 100644 (file)
@@ -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
 
index d295a5abfacc839cd5c0c7fbe77545c27e854189..597a46b31d963291082fdb2fd4efc05b2273e2a2 100644 (file)
@@ -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)