Salome HOME
sat jobs: remove empty lines from the boards.
[tools/sat.git] / commands / patch.py
index 30b7332d69a5a89b76ba28b81813da367eea28b6..f9e88e52e2b469891df35642750972a3f3a3a4c7 100644 (file)
@@ -25,7 +25,7 @@ import prepare
 # Define all possible option for patch command :  sat patch <options>
 parser = src.options.Options()
 parser.add_option('p', 'products', 'list2', 'products',
-    _('products to get the sources. This option can be'
+    _('Optional: products to get the sources. This option can be'
     ' passed several time to get the sources of several products.'))
 
 def apply_patch(config, product_info, max_product_name_len, logger):
@@ -39,6 +39,18 @@ def apply_patch(config, product_info, max_product_name_len, logger):
     :rtype: (boolean, str)
     '''
 
+    # if the product is native, do not apply patch
+    if src.product.product_is_native(product_info):
+        # display and log
+        logger.write('%s: ' % src.printcolors.printcLabel(product_info.name), 4)
+        logger.write(' ' * (max_product_name_len - len(product_info.name)), 4, False)
+        logger.write("\n", 4, False)
+        msg = _("The %s product is native. Do not apply "
+                "any patch.") % product_info.name
+        logger.write(msg, 4)
+        logger.write("\n", 4)
+        return True, ""       
+
     if not "patches" in product_info or len(product_info.patches) == 0:
         # display and log
         logger.write('%s: ' % src.printcolors.printcLabel(product_info.name), 4)
@@ -68,10 +80,8 @@ def apply_patch(config, product_info, max_product_name_len, logger):
         
         # Check the existence and apply the patch
         if os.path.isfile(patch):
-            #patch_exe = "patch" # old patch command (now replace by patching.py)
-            patch_exe = os.path.join(config.VARS.srcDir, "patching.py")
-            patch_cmd = "python %s -p1 -- < %s" % (patch_exe, patch)
-
+            patch_cmd = "patch -p1 < %s" % patch
+            
             # Write the command in the terminal if verbose level is at 5
             logger.write(("    >%s\n" % patch_cmd),5)
             
@@ -118,7 +128,8 @@ def description():
     :rtype: str
     '''
     return _("The patch command apply the patches on the sources of "
-             "the application products if there is any")
+             "the application products if there is any.\n\nexample:\nsat "
+             "patch SALOME-master --products qt,boost")
   
 def run(args, runner, logger):
     '''method that is called when salomeTools is called with patch parameter.
@@ -149,7 +160,10 @@ def run(args, runner, logger):
     good_result = 0
     for __, product_info in products_infos:
         # Apply the patch
-        return_code, patch_res = apply_patch(runner.cfg, product_info, max_product_name_len, logger)
+        return_code, patch_res = apply_patch(runner.cfg,
+                                             product_info,
+                                             max_product_name_len,
+                                             logger)
         logger.write(patch_res, 1, False)
         if return_code:
             good_result += 1