]> SALOME platform Git repositories - tools/sat.git/commitdiff
Salome HOME
Merge branch 'nct/jan21' of https://codev-tuleap.cea.fr/plugins/git/salome/sat into...
authorcrouzet <nicolas.crouzet@cea.fr>
Tue, 9 Mar 2021 15:13:04 +0000 (16:13 +0100)
committercrouzet <nicolas.crouzet@cea.fr>
Tue, 9 Mar 2021 15:13:04 +0000 (16:13 +0100)
commands/package.py
complete_sat.sh
src/product.py

index da5fe6f01b2b0bf70e05b88424311db79d81f31c..5cc26e6933f176bd40c44781e3ec4489b190f713 100644 (file)
@@ -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',
@@ -233,8 +235,8 @@ def produce_relative_launcher(config,
     # get KERNEL installation path 
     kernel_info = src.product.get_product_config(config, "KERNEL")
     kernel_base_name=os.path.basename(kernel_info.install_dir)
-    if kernel_base_name.startswith("config"):
-        # case of kernel installed in base. We remove "config-i"
+    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)
@@ -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,9 +379,18 @@ 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
     '''  
+
+    # set base mode to "no" for the archive - save current mode to restore it at the end
+    if "base" in config.APPLICATION:
+        base_setting=config.APPLICATION.base 
+    else:
+        base_setting="maybe"
+    config.APPLICATION.base="no"
+
     # create an environment file writer
     writer = src.environment.FileEnvWriter(config,
                                            logger,
@@ -392,6 +404,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 +422,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 |
@@ -417,6 +440,9 @@ def produce_relative_env_files(config,
              stat.S_IXGRP |
              stat.S_IXOTH)
     
+    # restore modified setting by its initial value
+    config.APPLICATION.base=base_setting
+
     return filepath
 
 def produce_install_bin_file(config,
@@ -576,6 +602,8 @@ def binary_package(config, logger, options, tmp_working_dir):
         config.APPLICATION.properties.mesa_launcher_in_package == "yes") :
             generate_mesa_launcher=True
 
+    # first loop on products : filter products, analyse properties,
+    # and store the information that will be used to create the archive in the second loop 
     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":
@@ -596,11 +624,12 @@ def binary_package(config, logger, options, tmp_working_dir):
                 or not src.product.product_compiles(prod_info)):
             continue
         # 
-        # products with single_fir property will be installed in the PRODUCTS directory of the archive
+        # 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"))
         if src.product.check_installation(config, prod_info):
-            l_install_dir.append((prod_name, prod_info.name, prod_info.install_dir, is_single_dir))
+            l_install_dir.append((prod_name, prod_info.name, prod_info.install_dir,
+                                  is_single_dir, prod_info.install_mode))
         else:
             l_not_installed.append(prod_name)
         
@@ -612,7 +641,7 @@ def binary_package(config, logger, options, tmp_working_dir):
                                            config.INTERNAL.config.install_dir,
                                            name_cpp) 
                 if os.path.exists(install_dir):
-                    l_install_dir.append((name_cpp, name_cpp, install_dir, False))
+                    l_install_dir.append((name_cpp, name_cpp, install_dir, False, "value"))
                 else:
                     l_not_installed.append(name_cpp)
         
@@ -675,11 +704,12 @@ WARNING: existing binaries directory from previous detar installation:
     # construct the correlation table between the product names, there 
     # actual install directories and there install directory in archive
     d_products = {}
-    for prod_name, prod_info_name, install_dir, is_single_dir in l_install_dir:
+    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 prod_base_name.startswith("config"):
-            # case of a products installed in base. Because the archive is in base:no mode, 
-            # we replace "config-i" by the product name or by PRODUCTS if single-dir
+        if install_mode == "base":
+            # case of a products installed in 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:
                 prod_base_name=config.INTERNAL.config.single_install_dir
             else:
@@ -757,6 +787,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):
index 53dbdb4271ff9cf3f1cbc1a2a358e61a1b2e0570..7470b1bbc7763b398767fea08c134409dd4a3b7f 100755 (executable)
@@ -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
             ;;
index c5e956bb8c7203658a1238b425be43910b10af1c..5bb0c16153a09b983554f4dc9029d2ae45c0fdc2 100644 (file)
@@ -204,6 +204,7 @@ def get_product_config(config, product_name, with_install_dir=True):
            # message to the user in case of non existing path.)
             prod_info.install_dir = version
             prod_info.get_source = "fixed"
+            prod_info.install_mode = "fixed"
         
         # Check if the product is defined as native in the application
         if prod_info is not None:
@@ -367,7 +368,7 @@ Please provide a 'compil_script' key in its definition.""") % product_name
             prod_info.install_dir = prod_info.install_dir_save
         
         # Set the install_dir key
-        prod_info.install_dir = get_install_dir(config, version, prod_info)
+        prod_info.install_dir,prod_info.install_mode = get_install_dir(config, version, prod_info)
                 
     return prod_info
 
@@ -493,11 +494,12 @@ def get_install_dir(config, version, prod_info):
     :param product_info Config: The configuration specific to 
                                the product
     
-    :return: The path of the product installation
-    :rtype: str
+    :return: The path of the product installation and the mode of the install directory (base/implicit/fixed/value)
+    :rtype: str,str
     """
     install_dir = ""
     in_base = False
+    
     # prod_info.base : corresponds to what is specified in application pyconf (either from the global key base, or from a product dict)
     # prod_info.install_dir : corresponds to what is specified in product pyconf (usually "base" for prerequisites)
     if ( ("install_dir" in prod_info and prod_info.install_dir == "base") # product is declared as base in its own config 
@@ -511,9 +513,15 @@ def get_install_dir(config, version, prod_info):
 
     if in_base:
         install_dir = get_base_install_dir(config, prod_info, version)
+        install_mode = "base"
     else:
-        if "install_dir" not in prod_info or prod_info.install_dir == "base":
+        if ("install_mode" in prod_info and prod_info.install_mode in ["implicit", "base"]) or\
+           ("install_dir" not in prod_info or prod_info.install_dir == "base"):
+            # the check to "base" comes from the package case were base mode is changed dynamically 
+            # to create a package launcher.
+
             # Set it to the default value (in application directory)
+            install_mode = "implicit"
             if ( src.appli_test_property(config,"single_install_dir", "yes") and 
                  src.product.product_test_property(prod_info,"single_install_dir", "yes")):
                 # when single_install_dir mode is activated in tha application
@@ -537,8 +545,9 @@ def get_install_dir(config, version, prod_info):
                                            prod_info.name)
         else:
             install_dir = prod_info.install_dir
+            install_mode = "value"
 
-    return install_dir
+    return install_dir,install_mode
 
 def get_base_install_dir(config, prod_info, version):
     """Compute the installation directory of a product in base