Salome HOME
fix archive not found in product
[tools/sat.git] / src / product.py
index b1c62ebab71db88dfe3c1dddeb4de2c2a3e7d4bc..fba1c42459cd36d69a4bb93d52582cc4eb7aa3af 100644 (file)
@@ -23,6 +23,7 @@ import os
 import re
 
 import src
+import src.debug as DBG
 
 AVAILABLE_VCS = ['git', 'svn', 'cvs']
 config_expression = "^config-\d+$"
@@ -145,13 +146,18 @@ def get_product_config(config, product_name, with_install_dir=True):
         prod_pyconf_path = src.find_file_in_lpath(product_name + ".pyconf",
                                                   config.PATHS.PRODUCTPATH)
         if not prod_pyconf_path:
-            msg = _("No definition found for the product %s\n"
-               "Please create a %s.pyconf file." % (product_name, product_name))
+            msg = _("""\
+No definition found for the product %(1)s.
+Please create a %(2)s.pyconf file somewhere in:
+%(3)s""") % {
+  "1": product_name, 
+  "2": product_name,
+  "3": config.PATHS.PRODUCTPATH }
         else:
-            msg = _("No definition corresponding to the version %(version)s was"
-                    " found in the file %(prod_file_path)s.\nPlease add a "
-                    "section in it." % {"version" : vv,
-                                        "prod_file_path" : prod_pyconf_path} )
+            msg = _("""\
+No definition corresponding to the version %(1)s was found in the file:
+  %(2)s.
+Please add a section in it.""") % {"1" : vv, "2" : prod_pyconf_path}
         raise src.SatException(msg)
     
     # Set the debug, dev and version keys
@@ -170,11 +176,13 @@ def get_product_config(config, product_name, with_install_dir=True):
             arch_path = src.find_file_in_lpath(arch_name,
                                                config.PATHS.ARCHIVEPATH)
             if not arch_path:
-                msg = _("Archive %(arch_name)s for %(prod_name)s not found:"
-                            "\n" % {"arch_name" : arch_name,
-                                     "prod_name" : prod_info.name}) 
-                raise src.SatException(msg)
-            prod_info.archive_info.archive_name = arch_path
+                msg = _("Archive %(1)s for %(2)s not found in config.PATHS.ARCHIVEPATH") % \
+                       {"1" : arch_name, "2" : prod_info.name}
+                DBG.tofix(msg, config.PATHS.ARCHIVEPATH)
+                prod_info.archive_info.archive_name = arch_name #without path
+                # raise src.SatException(msg) #may be a warning, continue #8646
+            else:
+                prod_info.archive_info.archive_name = arch_path
         else:
             if (os.path.basename(prod_info.archive_info.archive_name) == 
                                         prod_info.archive_info.archive_name):
@@ -183,20 +191,23 @@ def get_product_config(config, product_name, with_install_dir=True):
                                             arch_name,
                                             config.PATHS.ARCHIVEPATH)
                 if not arch_path:
-                    msg = _("Archive %(arch_name)s for %(prod_name)s not found:"
-                                "\n" % {"arch_name" : arch_name,
-                                         "prod_name" : prod_info.name}) 
-                    raise src.SatException(msg)
-                prod_info.archive_info.archive_name = arch_path
+                    msg = _("Archive %(1)s for %(2)s not found in config.PATHS.ARCHIVEPATH") % \
+                           {"1" : arch_name, "2" : prod_info.name}
+                    DBG.tofix(msg, config.PATHS.ARCHIVEPATH) #avoid 2 messages in compile
+                    prod_info.archive_info.archive_name = arch_name #without path
+                    # raise src.SatException(msg) #may be a warning, continue #8646
+                else:
+                    prod_info.archive_info.archive_name = arch_path
+
         
     # If the product compiles with a script, check the script existence
     # and if it is executable
     if product_has_script(prod_info):
         # Check the compil_script key existence
         if "compil_script" not in prod_info:
-            msg = _("No compilation script found for the product %s\n"
-                "Please provide a \"compil_script\" key in its definition." 
-                % (product_name))
+            msg = _("""\
+No compilation script found for the product %s.
+Please provide a 'compil_script' key in its definition.""") % product_name
             raise src.SatException(msg)
         
         # Get the path of the script
@@ -208,35 +219,39 @@ def get_product_config(config, product_name, with_install_dir=True):
                                                  config.PATHS.PRODUCTPATH,
                                                  "compil_scripts")
             if not script_path:
-                raise src.SatException(_("Compilation script not found: %s") % 
-                                   script_name)
+                raise src.SatException(
+                    _("Compilation script not found: %s") % script_name)
             prod_info.compil_script = script_path
             if src.architecture.is_windows():
                 prod_info.compil_script = prod_info.compil_script[:-len(".sh")] + ".bat"
        
         # Check that the script is executable
         if not os.access(prod_info.compil_script, os.X_OK):
-            raise src.SatException(
-                    _("Compilation script cannot be executed: %s") % 
-                    prod_info.compil_script)
+            #raise src.SatException(
+            #        _("Compilation script cannot be executed: %s") % 
+            #        prod_info.compil_script)
+            DBG.tofix("Compilation script cannot be executed:", prod_info.compil_script)
     
     # Get the full paths of all the patches
     if product_has_patches(prod_info):
         patches = []
-        for patch in prod_info.patches:
-            patch_path = patch
-            # If only a filename, then search for the patch in the PRODUCTPATH
-            if os.path.basename(patch_path) == patch_path:
-                # Search in the PRODUCTPATH/patches
-                patch_path = src.find_file_in_lpath(patch,
-                                                    config.PATHS.PRODUCTPATH,
-                                                    "patches")
-                if not patch_path:
-                    msg = _("Patch %(patch_name)s for %(prod_name)s not found:"
-                            "\n" % {"patch_name" : patch,
-                                     "prod_name" : prod_info.name}) 
-                    raise src.SatException(msg)
-            patches.append(patch_path)
+        try:
+          for patch in prod_info.patches:
+              patch_path = patch
+              # If only a filename, then search for the patch in the PRODUCTPATH
+              if os.path.basename(patch_path) == patch_path:
+                  # Search in the PRODUCTPATH/patches
+                  patch_path = src.find_file_in_lpath(patch,
+                                                      config.PATHS.PRODUCTPATH,
+                                                      "patches")
+                  if not patch_path:
+                      msg = _("Patch %(patch_name)s for %(prod_name)s not found:"
+                              "\n" % {"patch_name" : patch,
+                                       "prod_name" : prod_info.name}) 
+                      raise src.SatException(msg)
+              patches.append(patch_path)
+        except:
+          DBG.tofix("problem in prod_info.patches", prod_info)
         prod_info.patches = patches
 
     # Get the full paths of the environment scripts
@@ -534,33 +549,37 @@ def check_installation(product_info):
                 return False
     return True
 
-def product_is_sample(product_info):
-    '''Know if a product has the sample type
+def check_source(product_info):
+    '''Verify if a sources of product is preset. Checks source directory presence
     
     :param product_info Config: The configuration specific to 
                                the product
-    :return: True if the product has the sample type, else False
+    :return: True if it is well installed
     :rtype: boolean
     '''
-    if 'type' in product_info:
-        ptype = product_info.type
-        return ptype.lower() == 'sample'
-    else:
+    DBG.write("check_source product_info", product_info)
+    source_dir = product_info.source_dir
+    if not os.path.exists(source_dir):
         return False
+    if ("present_files" in product_info and 
+        "source" in product_info.present_files):
+        for file_relative_path in product_info.present_files.source:
+            file_path = os.path.join(source_dir, file_relative_path)
+            if not os.path.exists(file_path):
+                return False
+    return True
 
 def product_is_salome(product_info):
-    '''Know if a product is of type salome
+    '''Know if a product is a SALOME module
     
     :param product_info Config: The configuration specific to 
                                the product
-    :return: True if the product is salome, else False
+    :return: True if the product is a SALOME module, else False
     :rtype: boolean
     '''
-    if 'type' in product_info:
-        ptype = product_info.type
-        return ptype.lower() == 'salome'
-    else:
-        return False
+    return ("properties" in product_info and
+            "is_SALOME_module" in product_info.properties and
+            product_info.properties.is_SALOME_module == "yes")
 
 def product_is_fixed(product_info):
     '''Know if a product is fixed
@@ -593,7 +612,10 @@ def product_is_dev(product_info):
     :rtype: boolean
     '''
     dev = product_info.dev
-    return dev.lower() == 'yes'
+    res = (dev.lower() == 'yes')
+    DBG.write('product_is_dev %s' % product_info.name, res)
+    # if product_info.name == "XDATA": return True #test #10569
+    return res
 
 def product_is_debug(product_info):
     '''Know if a product is in debug mode
@@ -638,18 +660,6 @@ def product_is_vcs(product_info):
     '''
     return product_info.get_source in AVAILABLE_VCS
 
-def product_is_SALOME(product_info):
-    '''Know if a product is a SALOME module
-    
-    :param product_info Config: The configuration specific to 
-                               the product
-    :return: True if the product is a SALOME module, else False
-    :rtype: boolean
-    '''
-    return ("properties" in product_info and
-            "is_SALOME_module" in product_info.properties and
-            product_info.properties.is_SALOME_module == "yes")
-
 def product_is_smesh_plugin(product_info):
     '''Know if a product is a SMESH plugin
     
@@ -718,8 +728,11 @@ def product_has_patches(product_info):
                                the product
     :return: True if the product has one or more patches
     :rtype: boolean
-    '''
-    return "patches" in product_info and len(product_info.patches) > 0
+    '''   
+    res = ( "patches" in product_info and len(product_info.patches) > 0 )
+    DBG.write('product_has_patches %s' % product_info.name, res)
+    # if product_info.name == "XDATA": return True #test #10569
+    return res
 
 def product_has_logo(product_info):
     '''Know if a product has a logo (YACSGEN generate)