Salome HOME
for fixed products, use directory to evaluate if dependency is compiled
[tools/sat.git] / src / product.py
index d38241a3f8f19cc83eef8e6a89b9fdc0f6923d22..7d73a505bd31fe727895c647cc6a1ad210372fd6 100644 (file)
@@ -556,6 +556,10 @@ def get_base_install_dir(config, prod_info, version):
     :return: The path of the product installation
     :rtype: str
     """    
+    
+    # get rid of / to avoid create subdirectories cf sat #18546
+    version_wslash=version.replace("/", "_") 
+
     if ( src.appli_test_property(config,"pip", "yes") and 
          src.product.product_test_property(prod_info,"pip", "yes") and
          src.appli_test_property(config,"pip_install_dir", "python") ):
@@ -567,10 +571,10 @@ def get_base_install_dir(config, prod_info, version):
     base_path = src.get_base_path(config) 
     if "base" in prod_info and prod_info.base != "no" and prod_info.base != "yes":
         # we are in the case of a named base
-        prod_dir = os.path.join(base_path, "apps", prod_info.base, prod_info.name, version)
+        prod_dir = os.path.join(base_path, "apps", prod_info.base, prod_info.name, version_wslash)
         return prod_dir
     
-    prod_dir = os.path.join(base_path, prod_info.name + "-" + version)
+    prod_dir = os.path.join(base_path, prod_info.name + "-" + version_wslash)
     if not os.path.exists(prod_dir):
         return os.path.join(prod_dir, "config-1")
     
@@ -604,7 +608,13 @@ def add_compile_config_file(p_info, config):
     res.addMapping(p_info.name, src.pyconf.Mapping(res), "")
     res[p_info.name]= p_info.version
 
-    for prod_name in p_info.depend:
+    depprod=[]
+    for d in p_info.depend:
+        depprod.append(d)
+    if "build_depend" in p_info:
+        for d in p_info.build_depend:
+            depprod.append(d)
+    for prod_name in depprod:
       if prod_name not in res:
         res.addMapping(prod_name, src.pyconf.Mapping(res), "")
       prod_dep_info = src.product.get_product_config(config, prod_name, False)
@@ -654,6 +664,13 @@ def check_config_exists(config, prod_dir, prod_info, verbose=False):
     DBG.write("check_config_exists 000",  (prod_dir, l_dir_and_files), verbose)
     DBG.write("check_config_exists 111",  prod_info, verbose)
 
+    depend_all=[]
+    if "depend" in prod_info:
+        for d in prod_info.depend:
+            depend_all.append(d)
+    if "build_depend" in prod_info:
+        for d in prod_info.build_depend:
+            depend_all.append(d)
     for dir_or_file in l_dir_and_files:
         oExpr = re.compile(config_expression)
         if not(oExpr.search(dir_or_file)):
@@ -672,7 +689,7 @@ def check_config_exists(config, prod_dir, prod_info, verbose=False):
         # dependencies of the product
         config_corresponds = True    
         compile_cfg = src.pyconf.Config(config_file)
-        for prod_dep in prod_info.depend:
+        for prod_dep in depend_all:
             # if the dependency is not in the config, 
             # the config does not correspond
             if prod_dep not in compile_cfg:
@@ -698,7 +715,7 @@ def check_config_exists(config, prod_dir, prod_info, verbose=False):
                 break
             else:
               # as old compatibility without prod_name sat-config.pyconf files
-              if prod_name not in prod_info.depend:
+              if prod_name not in depend_all:
                 # here there is an unexpected depend in an old compilation
                 config_corresponds = False
                 break
@@ -804,10 +821,19 @@ def get_product_dependencies(config, product_info):
     :return: the list of products in dependence
     :rtype: list
     """
-    if "depend" not in product_info or product_info.depend == []:
+    depend_all=[]
+    if "depend" in product_info:
+        for d in product_info.depend:
+            depend_all.append(d)
+    if "build_depend" in product_info:
+        for d in product_info.build_depend:
+            depend_all.append(d)
+
+    if len(depend_all) == 0:
         return []
+
     res = []
-    for prod in product_info.depend:
+    for prod in depend_all:
         if prod == product_info.name:
             continue
         if prod not in res:
@@ -829,23 +855,38 @@ def check_installation(config, product_info):
     :return: True if it is well installed
     :rtype: boolean
     """
-    # don't check native products, or products that are not compiled
-    if (not product_compiles(product_info)) or product_is_native(product_info):
+    # don't check products that are not compiled
+    if not product_compiles(product_info):
         return True
 
+    if product_is_native(product_info):
+        # check a system product
+        check_cmd=src.system.get_pkg_check_cmd(config.VARS.dist_name)
+        run_pkg,build_pkg=src.product.check_system_dep(check_cmd, product_info)
+        build_dep_ko=[]
+        for pkg in build_pkg:
+            if "KO" in build_pkg[pkg]:
+               build_dep_ko.append(pkg) 
+        if build_dep_ko:
+              # the product is not installed : display message and return error status
+              msg="Please install them with %s before compiling salome" % check_cmd[0]
+              print("\nmissing compile time dependencies : ")
+              for md in build_dep_ko: 
+                  print(md)
+              print(msg)
+              return False
+        else:
+            return True    
+
     install_dir = product_info.install_dir
-    if ( (src.appli_test_property(config,"single_install_dir", "yes") and 
-          src.product.product_test_property(product_info,"single_install_dir", "yes")) or
-         (src.appli_test_property(config,"pip", "yes") and 
-          src.product.product_test_property(product_info,"pip", "yes") and
-          src.appli_test_property(config,"pip_install_dir", "python") ) ):
-        # if the product is installed in the single install dir, or in python (for pip managed products)
-        # we check the product file in state of the install directory.
-        filename = CONFIG_FILENAME + product_info.name + ".pyconf"
-        if not os.path.exists(os.path.join(install_dir, filename)): 
+    if src.product.product_is_fixed(product_info):
+        # we check directly the install dir only for fixed products
+        # (there is no pyconf file in that case)
+        if not os.path.exists(install_dir):
             return False
     else:
-        if not os.path.exists(install_dir):
+        filename = CONFIG_FILENAME + product_info.name + ".pyconf"
+        if not os.path.exists(os.path.join(install_dir, filename)): 
             return False
 
     # check extra files if specified in present_files.install section
@@ -1151,6 +1192,19 @@ def product_is_compile_time(product_info):
             "compile_time" in product_info.properties and
             product_info.properties.compile_time == "yes")
 
+def product_is_compile_and_runtime(product_info):
+    """Know if a product is only used at compile time
+    
+    :param product_info Config: The configuration specific to 
+                               the product
+    :return: True if the product is only used at compile time
+    :rtype: boolean
+    """
+    return ("properties" in product_info and
+            "compile_and_runtime" in product_info.properties and
+            product_info.properties.compile_and_runtime == "yes")
+
+
 
 def product_test_property(product_info, property_name, property_value):
     """Generic function to test if a product has a property set to a value