Salome HOME
fix #8576 #8646
authorChristian Van Wambeke <christian.van-wambeke@cea.fr>
Tue, 20 Mar 2018 09:44:05 +0000 (10:44 +0100)
committerChristian Van Wambeke <christian.van-wambeke@cea.fr>
Tue, 20 Mar 2018 09:44:05 +0000 (10:44 +0100)
commands/check.py
commands/compile.py
commands/config.py
commands/package.py
commands/source.py
src/product.py

index cfa2c822946fdb60fbadfc2fc34c2e140fb96476..4a490a41c934863c97dd832aa14ff99c4e1c1775 100644 (file)
@@ -23,8 +23,8 @@ import src
 # Define all possible option for the check command :  sat check <options>
 parser = src.options.Options()
 parser.add_option('p', 'products', 'list2', 'products',
-    _('Optional: products to configure. This option can be'
-    ' passed several time to configure several products.'))
+    _('Optional: products to check. This option can be'
+    ' passed several time to check several products.'))
 
 CHECK_PROPERTY = "has_unit_tests"
 
@@ -245,4 +245,4 @@ def run(args, runner, logger):
           'valid_result': nb_products - res,
           'nb_products': nb_products }, 1)    
     
-    return res 
\ No newline at end of file
+    return res 
index 5f15b83f19144fc9ea58f79e3639f3a3e53ac368..2859abdd02ae4cbc65057811190bb3e4825d1168 100644 (file)
@@ -19,6 +19,7 @@
 import os
 
 import src
+import src.debug as DBG
 
 # Compatibility python 2/3 for input function
 # input stays input for python 3 and input = raw_input for python 2
@@ -30,8 +31,8 @@ except NameError:
 # Define all possible option for the compile command :  sat compile <options>
 parser = src.options.Options()
 parser.add_option('p', 'products', 'list2', 'products',
-    _('Optional: products to configure. This option can be'
-    ' passed several time to configure several products.'))
+    _('Optional: products to compile. This option can be'
+    ' passed several time to compile several products.'))
 parser.add_option('', 'with_fathers', 'boolean', 'fathers',
     _("Optional: build all necessary products to the given product (KERNEL is "
       "build before building GUI)."), False)
@@ -313,7 +314,7 @@ def compile_all_products(sat, config, options, products_infos, logger):
         # Clean the build and the install directories 
         # if the corresponding options was called
         if options.clean_all:
-            log_step(logger, header, "CLEAN BUILD AND INSTALL")
+            log_step(logger, header, "CLEAN BUILD AND INSTALL ")
             sat.clean(config.VARS.application + 
                       " --products " + p_name + 
                       " --build --install",
@@ -324,7 +325,7 @@ def compile_all_products(sat, config, options, products_infos, logger):
         # Clean the the install directory 
         # if the corresponding option was called
         if options.clean_install and not options.clean_all:
-            log_step(logger, header, "CLEAN INSTALL")
+            log_step(logger, header, "CLEAN INSTALL ")
             sat.clean(config.VARS.application + 
                       " --products " + p_name + 
                       " --install",
@@ -336,6 +337,13 @@ def compile_all_products(sat, config, options, products_infos, logger):
         # (it could change if there is a clean of the install directory)
         p_info = src.product.get_product_config(config, p_name)
         
+        # Check if sources was already successfully installed
+        check_source = src.product.check_source(p_info)
+        if not check_source:
+            logger.write(_("Sources of product not found (try 'sat -h prepare')\n"))
+            res += 1 #BUG
+            continue
+        
         # Check if it was already successfully installed
         if src.product.check_installation(p_info):
             logger.write(_("Already installed\n"))
@@ -358,13 +366,8 @@ def compile_all_products(sat, config, options, products_infos, logger):
             continue
         
         # Call the function to compile the product
-        res_prod, len_end_line, error_step = compile_product(sat,
-                                                             p_name_info,
-                                                             config,
-                                                             options,
-                                                             logger,
-                                                             header,
-                                                             len_end_line)
+        res_prod, len_end_line, error_step = compile_product(
+             sat, p_name_info, config, options, logger, header, len_end_line)
         
         if res_prod != 0:
             res += 1
@@ -635,7 +638,7 @@ def description():
 def run(args, runner, logger):
     '''method that is called when salomeTools is called with compile parameter.
     '''
-    
+    # DBG.write("compile runner.cfg", runner.cfg, True)
     # Parse the options
     (options, args) = parser.parse_args(args)
 
index 5d48be5da9ecd2d6ca95eac7303bdefc6583048e..f048db390f433910ba7f417d1d92124116ad7f99 100644 (file)
@@ -24,6 +24,7 @@ import gettext
 import sys
 
 import src
+import src.debug as DBG
 
 # internationalization
 satdir  = os.path.dirname(os.path.realpath(__file__))
@@ -351,10 +352,11 @@ class ConfigManager:
         cfg.PATHS["ARCHIVEPATH"].append(cfg.LOCAL.archive_dir, "")
 
         # Loop over the projects in order to complete the PATHS variables
+        # as /data/tmpsalome/salome/prerequis/archives for example ARCHIVEPATH
         for project in cfg.PROJECTS.projects:
             for PATH in ["APPLICATIONPATH",
                          "PRODUCTPATH",
-                         "ARCHIVEPATH",
+                         "ARCHIVEPATH", #comment this for default archive      #8646
                          "JOBPATH",
                          "MACHINEPATH"]:
                 if PATH not in cfg.PROJECTS.projects[project]:
index 82c19cec342184560517f7ef84955325399a8715..09fef8f8f552f94a563498f3fc6b9c1d1d3f5598 100644 (file)
@@ -753,8 +753,7 @@ def get_archives_vcs(l_pinfo_vcs, sat, config, logger, tmp_working_dir):
     # clean the source directory of all the vcs products, then use the source 
     # command and thus construct an archive that will not contain the patches
     l_prod_names = [pn for pn, __ in l_pinfo_vcs]
-    if False:
-      # clean
+    if False: # clean is dangerous in user/SOURCES, fixed in tmp_working_dir
       logger.write(_("\nclean sources\n"))
       args_clean = config.VARS.application
       args_clean += " --sources --products "
@@ -770,7 +769,7 @@ def get_archives_vcs(l_pinfo_vcs, sat, config, logger, tmp_working_dir):
       svgDir = sat.cfg.APPLICATION.workdir
       sat.cfg.APPLICATION.workdir = tmp_working_dir
       # DBG.write("SSS sat config.APPLICATION.workdir", sat.cfg.APPLICATION, True)
-      DBG.write("sat config id", id(sat.cfg), True)
+      DBG.write("sat config id", id(sat.cfg), True)
       # shit as config is not same id() as for sat.source()
       # sat.source(args_source, batch=True, verbose=5, logger_add_link = logger)
       import source
index a616c7768272e66bd2d773a508d8cbd3e4d05138..c8d34f13bdd5af965c18ae15950827610a31c26c 100644 (file)
@@ -123,7 +123,7 @@ def get_source_from_archive(product_info, source_dir, logger):
     '''
     # check archive exists
     if not os.path.exists(product_info.archive_info.archive_name):
-        raise src.SatException(_("Archive not found: '%s'") % 
+        raise src.SatException(_("Archive not found in config.PATHS.ARCHIVEPATH: '%s'") % 
                                product_info.archive_info.archive_name)
 
     logger.write('arc:%s ... ' % 
@@ -397,7 +397,6 @@ def get_all_product_sources(config, products, logger):
     # The loop on all the products from which to get the sources
     # DBG.write("source.get_all_product_sources config id", id(config), True)
     for product_name, product_info in products:
-        print "get_all_product_sources", product_name #, product_info
         # get product name, product informations and the directory where to put
         # the sources
         if (not (src.product.product_is_fixed(product_info) or 
@@ -501,7 +500,7 @@ def description():
 def run(args, runner, logger):
     '''method that is called when salomeTools is called with source parameter.
     '''
-    DBG.write("source.run()", args, True)
+    DBG.write("source.run()", args)
     # Parse the options
     (options, args) = parser.parse_args(args)
     
index 81ad048a261fc04f14236e95b431a40b0b7298bc..a7acab6ca4b1426332d10c2a228d59d3f1b2732d 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+$"
@@ -175,10 +176,13 @@ Please add a section in it.""") % {"1" : vv, "2" : prod_pyconf_path}
             arch_path = src.find_file_in_lpath(arch_name,
                                                config.PATHS.ARCHIVEPATH)
             if not arch_path:
-                msg = _("Archive %(1)s for %(2)s not found.\n") % \
+                msg = _("Archive %(1)s for %(2)s not found in config.PATHS.ARCHIVEPATH") % \
                        {"1" : arch_name, "2" : prod_info.name}
-                raise src.SatException(msg)
-            prod_info.archive_info.archive_name = arch_path
+                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):
@@ -187,9 +191,11 @@ Please add a section in it.""") % {"1" : vv, "2" : prod_pyconf_path}
                                             arch_name,
                                             config.PATHS.ARCHIVEPATH)
                 if not arch_path:
-                    msg = _("Archive %(1)s for %(2)s not found:\n") % \
+                    msg = _("Archive %(1)s for %(2)s not found in config.PATHS.ARCHIVEPATH") % \
                            {"1" : arch_name, "2" : prod_info.name}
-                    raise src.SatException(msg)
+                    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
                 prod_info.archive_info.archive_name = arch_path
         
     # If the product compiles with a script, check the script existence
@@ -222,7 +228,7 @@ Please provide a 'compil_script' key in its definition.""") % product_name
             #raise src.SatException(
             #        _("Compilation script cannot be executed: %s") % 
             #        prod_info.compil_script)
-            print("WARNING: Compilation script cannot be executed:\n         %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):
@@ -538,6 +544,26 @@ def check_installation(product_info):
                 return False
     return True
 
+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 it is well installed
+    :rtype: boolean
+    '''
+    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_sample(product_info):
     '''Know if a product has the sample type