]> SALOME platform Git repositories - tools/sat.git/blob - src/product.py
Salome HOME
merge cvw/sprint_180319 for doc alabaster
[tools/sat.git] / src / product.py
1 #!/usr/bin/env python
2 #-*- coding:utf-8 -*-
3 #  Copyright (C) 2010-2012  CEA/DEN
4 #
5 #  This library is free software; you can redistribute it and/or
6 #  modify it under the terms of the GNU Lesser General Public
7 #  License as published by the Free Software Foundation; either
8 #  version 2.1 of the License.
9 #
10 #  This library is distributed in the hope that it will be useful,
11 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
12 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 #  Lesser General Public License for more details.
14 #
15 #  You should have received a copy of the GNU Lesser General Public
16 #  License along with this library; if not, write to the Free Software
17 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
18
19 """\
20 In this file are implemented the methods 
21 relative to the product notion of salomeTools
22 """
23
24 import os
25 import re
26
27 import src
28 import src.debug as DBG
29
30 AVAILABLE_VCS = ['git', 'svn', 'cvs']
31 config_expression = "^config-\d+$"
32 VERSION_DELIMITER = "_to_"
33
34 def get_product_config(config, product_name, with_install_dir=True):
35     """Get the specific configuration of a product from the global configuration
36     
37     :param config Config: The global configuration
38     :param product_name str: The name of the product
39     :param with_install_dir boolean: If false, do not provide an install 
40                                      directory (at false only for internal use 
41                                      of the function check_config_exists)
42     :return: the specific configuration of the product
43     :rtype: Config
44     """
45     
46     # Get the version of the product from the application definition
47     version = config.APPLICATION.products[product_name]
48     # if no version, then take the default one defined in the application
49     if isinstance(version, bool): 
50         version = config.APPLICATION.tag      
51     
52     # Define debug and dev modes
53     # Get the tag if a dictionary is given in APPLICATION.products for the
54     # current product 
55     debug = 'no'
56     dev = 'no'
57     base = 'maybe'
58     section = None
59     if isinstance(version, src.pyconf.Mapping):
60         dic_version = version
61         # Get the version/tag
62         if not 'tag' in dic_version:
63             version = config.APPLICATION.tag
64         else:
65             version = dic_version.tag
66         
67         # Get the debug if any
68         if 'debug' in dic_version:
69             debug = dic_version.debug
70         
71         # Get the dev if any
72         if 'dev' in dic_version:
73             dev = dic_version.dev
74         
75         # Get the base if any
76         if 'base' in dic_version:
77             base = dic_version.base
78
79         # Get the section if any
80         if 'section' in dic_version:
81             section = dic_version.section
82     
83     vv = version
84     # substitute some character with _ in order to get the correct definition
85     # in config.PRODUCTS. This is done because the pyconf tool does not handle
86     # the . and - characters 
87     for c in ".-": vv = vv.replace(c, "_")
88     
89     prod_info = None
90     if product_name in config.PRODUCTS:
91         # Search for the product description in the configuration
92         prod_info = get_product_section(config, product_name, vv, section)
93         
94         # merge opt_depend in depend
95         if prod_info is not None and 'opt_depend' in prod_info:
96             for depend in prod_info.opt_depend:
97                 if depend in config.APPLICATION.products:
98                     prod_info.depend.append(depend,'')
99         
100         # In case of a product get with a vcs, 
101         # put the tag (equal to the version)
102         if prod_info is not None and prod_info.get_source in AVAILABLE_VCS:
103             
104             if prod_info.get_source == 'git':
105                 prod_info.git_info.tag = version
106             
107             if prod_info.get_source == 'svn':
108                 prod_info.svn_info.tag = version
109             
110             if prod_info.get_source == 'cvs':
111                 prod_info.cvs_info.tag = version
112         
113         # In case of a fixed product, 
114         # define the install_dir (equal to the version)
115         if prod_info is not None and os.path.isdir(version):
116             prod_info.install_dir = version
117             prod_info.get_source = "fixed"
118         
119         # Check if the product is defined as native in the application
120         if prod_info is not None:
121             if version == "native":
122                 prod_info.get_source = "native"
123             elif prod_info.get_source == "native":
124                 msg = _("The product %(prod)s has version %(ver)s but is "
125                         "declared as native in its definition" %
126                         { 'prod': prod_info.name, 'ver': version})
127                 raise src.SatException(msg)
128
129     # If there is no definition but the product is declared as native,
130     # construct a new definition containing only the get_source key
131     if prod_info is None and version == "native":
132         prod_info = src.pyconf.Config()
133         prod_info.name = product_name
134         prod_info.get_source = "native"
135
136     # If there is no definition but the product is fixed,
137     # construct a new definition containing only the product name
138     if prod_info is None and os.path.isdir(version):
139         prod_info = src.pyconf.Config()
140         prod_info.name = product_name
141         prod_info.get_source = "fixed"
142         prod_info.addMapping("environ", src.pyconf.Mapping(prod_info), "")
143
144
145     # If prod_info is still None, it means that there is no product definition
146     # in the config. The user has to provide it.
147     if prod_info is None:
148         prod_pyconf_path = src.find_file_in_lpath(product_name + ".pyconf",
149                                                   config.PATHS.PRODUCTPATH)
150         if not prod_pyconf_path:
151             msg = _("""\
152 No definition found for the product %(1)s.
153 Please create a %(2)s.pyconf file somewhere in:
154 %(3)s""") % {
155   "1": product_name, 
156   "2": product_name,
157   "3": config.PATHS.PRODUCTPATH }
158         else:
159             msg = _("""\
160 No definition corresponding to the version %(1)s was found in the file:
161   %(2)s.
162 Please add a section in it.""") % {"1" : vv, "2" : prod_pyconf_path}
163         raise src.SatException(msg)
164     
165     # Set the debug, dev and version keys
166     prod_info.debug = debug
167     prod_info.dev = dev
168     prod_info.version = version
169     
170     # Set the archive_info if the product is get in archive mode
171     if prod_info.get_source == "archive":
172         if not "archive_info" in prod_info:
173             prod_info.addMapping("archive_info",
174                                  src.pyconf.Mapping(prod_info),
175                                  "")
176         if "archive_name" not in prod_info.archive_info: 
177             arch_name = product_name + "-" + version + ".tar.gz"
178             arch_path = src.find_file_in_lpath(arch_name,
179                                                config.PATHS.ARCHIVEPATH)
180             if not arch_path:
181                 msg = _("Archive %(1)s for %(2)s not found in config.PATHS.ARCHIVEPATH") % \
182                        {"1" : arch_name, "2" : prod_info.name}
183                 DBG.tofix(msg, config.PATHS.ARCHIVEPATH)
184                 prod_info.archive_info.archive_name = arch_name #without path
185                 # raise src.SatException(msg) #may be a warning, continue #8646
186             else:
187                 prod_info.archive_info.archive_name = arch_path
188         else:
189             if (os.path.basename(prod_info.archive_info.archive_name) == 
190                                         prod_info.archive_info.archive_name):
191                 arch_name = prod_info.archive_info.archive_name
192                 arch_path = src.find_file_in_lpath(
193                                             arch_name,
194                                             config.PATHS.ARCHIVEPATH)
195                 if not arch_path:
196                     msg = _("Archive %(1)s for %(2)s not found in config.PATHS.ARCHIVEPATH") % \
197                            {"1" : arch_name, "2" : prod_info.name}
198                     DBG.tofix(msg, config.PATHS.ARCHIVEPATH) #avoid 2 messages in compile
199                     prod_info.archive_info.archive_name = arch_name #without path
200                     # raise src.SatException(msg) #may be a warning, continue #8646
201                 prod_info.archive_info.archive_name = arch_path
202         
203     # If the product compiles with a script, check the script existence
204     # and if it is executable
205     if product_has_script(prod_info):
206         # Check the compil_script key existence
207         if "compil_script" not in prod_info:
208             msg = _("""\
209 No compilation script found for the product %s.
210 Please provide a 'compil_script' key in its definition.""") % product_name
211             raise src.SatException(msg)
212         
213         # Get the path of the script
214         script = prod_info.compil_script
215         script_name = os.path.basename(script)
216         if script == script_name:
217             # Only a name is given. Search in the default directory
218             script_path = src.find_file_in_lpath(script_name,
219                                                  config.PATHS.PRODUCTPATH,
220                                                  "compil_scripts")
221             if not script_path:
222                 raise src.SatException(
223                     _("Compilation script not found: %s") % script_name)
224             prod_info.compil_script = script_path
225             if src.architecture.is_windows():
226                 prod_info.compil_script = prod_info.compil_script[:-len(".sh")] + ".bat"
227        
228         # Check that the script is executable
229         if not os.access(prod_info.compil_script, os.X_OK):
230             #raise src.SatException(
231             #        _("Compilation script cannot be executed: %s") % 
232             #        prod_info.compil_script)
233             DBG.tofix("Compilation script cannot be executed:", prod_info.compil_script)
234     
235     # Get the full paths of all the patches
236     if product_has_patches(prod_info):
237         patches = []
238         try:
239           for patch in prod_info.patches:
240               patch_path = patch
241               # If only a filename, then search for the patch in the PRODUCTPATH
242               if os.path.basename(patch_path) == patch_path:
243                   # Search in the PRODUCTPATH/patches
244                   patch_path = src.find_file_in_lpath(patch,
245                                                       config.PATHS.PRODUCTPATH,
246                                                       "patches")
247                   if not patch_path:
248                       msg = _("Patch %(patch_name)s for %(prod_name)s not found:"
249                               "\n" % {"patch_name" : patch,
250                                        "prod_name" : prod_info.name}) 
251                       raise src.SatException(msg)
252               patches.append(patch_path)
253         except:
254           DBG.tofix("problem in prod_info.patches", prod_info)
255         prod_info.patches = patches
256
257     # Get the full paths of the environment scripts
258     if product_has_env_script(prod_info):
259         env_script_path = prod_info.environ.env_script
260         # If only a filename, then search for the environment script 
261         # in the PRODUCTPATH/env_scripts
262         if os.path.basename(env_script_path) == env_script_path:
263             # Search in the PRODUCTPATH/env_scripts
264             env_script_path = src.find_file_in_lpath(
265                                             prod_info.environ.env_script,
266                                             config.PATHS.PRODUCTPATH,
267                                             "env_scripts")
268             if not env_script_path:
269                 msg = _("Environment script %(env_name)s for %(prod_name)s not "
270                         "found.\n" % {"env_name" : env_script_path,
271                                        "prod_name" : prod_info.name}) 
272                 raise src.SatException(msg)
273
274         prod_info.environ.env_script = env_script_path
275     
276     if with_install_dir: 
277         # The variable with_install_dir is at false only for internal use 
278         # of the function get_install_dir
279         
280         # Save the install_dir key if there is any
281         if "install_dir" in prod_info and not "install_dir_save" in prod_info:
282             prod_info.install_dir_save = prod_info.install_dir
283         
284         # if it is not the first time the install_dir is computed, it means
285         # that install_dir_save exists and it has to be taken into account.
286         if "install_dir_save" in prod_info:
287             prod_info.install_dir = prod_info.install_dir_save
288         
289         # Set the install_dir key
290         prod_info.install_dir = get_install_dir(config, base, version, prod_info)
291                 
292     return prod_info
293
294 def get_product_section(config, product_name, version, section=None):
295     """Get the product description from the configuration
296     
297     :param config Config: The global configuration
298     :param product_name str: The product name
299     :param version str: The version of the product
300     :param section str: The searched section (if not None, the section is 
301                         explicitly given
302     :return: The product description
303     :rtype: Config
304     """
305
306     # if section is not None, try to get the corresponding section
307     if section:
308         if section not in config.PRODUCTS[product_name]:
309             return None
310         # returns specific information for the given version
311         prod_info = config.PRODUCTS[product_name][section]
312         prod_info.section = section
313         prod_info.from_file = config.PRODUCTS[product_name].from_file
314         return prod_info
315
316     # If it exists, get the information of the product_version
317     if "version_" + version in config.PRODUCTS[product_name]:
318         # returns specific information for the given version
319         prod_info = config.PRODUCTS[product_name]["version_" + version]
320         prod_info.section = "version_" + version
321         prod_info.from_file = config.PRODUCTS[product_name].from_file
322         return prod_info
323     
324     # Else, check if there is a description for multiple versions
325     l_section_name = config.PRODUCTS[product_name].keys()
326     l_section_ranges = [section_name for section_name in l_section_name 
327                         if VERSION_DELIMITER in section_name]
328     for section_range in l_section_ranges:
329         minimum, maximum = section_range.split(VERSION_DELIMITER)
330         if (src.only_numbers(version) >= src.only_numbers(minimum)
331                     and src.only_numbers(version) <= src.only_numbers(maximum)):
332             # returns specific information for the versions
333             prod_info = config.PRODUCTS[product_name][section_range]
334             prod_info.section = section_range
335             prod_info.from_file = config.PRODUCTS[product_name].from_file
336             return prod_info
337     
338     # Else, get the standard informations
339     if "default" in config.PRODUCTS[product_name]:
340         # returns the generic information (given version not found)
341         prod_info = config.PRODUCTS[product_name].default
342         prod_info.section = "default"
343         prod_info.from_file = config.PRODUCTS[product_name].from_file
344         return prod_info
345     
346     # if noting was found, return None
347     return None
348     
349 def get_install_dir(config, base, version, prod_info):
350     """Compute the installation directory of a given product 
351     
352     :param config Config: The global configuration
353     :param base str: This corresponds to the value given by user in its 
354                      application.pyconf for the specific product. If "yes", the
355                      user wants the product to be in base. If "no", he wants the
356                      product to be in the application workdir
357     :param version str: The version of the product
358     :param product_info Config: The configuration specific to 
359                                the product
360     
361     :return: The path of the product installation
362     :rtype: str
363     """
364     install_dir = ""
365     in_base = False
366     if (("install_dir" in prod_info and prod_info.install_dir == "base") 
367                                                             or base == "yes"):
368         in_base = True
369     if (base == "no" or ("no_base" in config.APPLICATION 
370                          and config.APPLICATION.no_base == "yes")):
371         in_base = False
372     
373     if in_base:
374         install_dir = get_base_install_dir(config, prod_info, version)
375     else:
376         if "install_dir" not in prod_info or prod_info.install_dir == "base":
377             # Set it to the default value (in application directory)
378             install_dir = os.path.join(config.APPLICATION.workdir,
379                                                 "INSTALL",
380                                                 prod_info.name)
381         else:
382             install_dir = prod_info.install_dir
383
384     return install_dir
385
386 def get_base_install_dir(config, prod_info, version):
387     """Compute the installation directory of a product in base 
388     
389     :param config Config: The global configuration
390     :param product_info Config: The configuration specific to 
391                                the product
392     :param version str: The version of the product    
393     :return: The path of the product installation
394     :rtype: str
395     """    
396     base_path = src.get_base_path(config) 
397     prod_dir = os.path.join(base_path, prod_info.name + "-" + version)
398     if not os.path.exists(prod_dir):
399         return os.path.join(prod_dir, "config-1")
400     
401     exists, install_dir = check_config_exists(config, prod_dir, prod_info)
402     if exists:
403         return install_dir
404     
405     # Find the first config-<i> directory that is available in the product
406     # directory
407     found = False 
408     label = 1
409     while not found:
410         install_dir = os.path.join(prod_dir, "config-%i" % label)
411         if os.path.exists(install_dir):
412             label+=1
413         else:
414             found = True
415             
416     return install_dir
417
418 def check_config_exists(config, prod_dir, prod_info):
419     """\
420     Verify that the installation directory of a product in a base exists
421     Check all the config-<i> directory and verify the sat-config.pyconf file
422     that is in it 
423     
424     :param config Config: The global configuration
425     :param prod_dir str: The product installation directory path 
426                          (without config-<i>)
427     :param product_info Config: The configuration specific to 
428                                the product
429     :return: True or false is the installation is found or not 
430              and if it is found, the path of the found installation
431     :rtype: (boolean, str)
432     """   
433     # check if the directories or files of the directory corresponds to the 
434     # directory installation of the product
435     l_dir_and_files = os.listdir(prod_dir)
436     for dir_or_file in l_dir_and_files:
437         oExpr = re.compile(config_expression)
438         if not(oExpr.search(dir_or_file)):
439             # not config-<i>, not interesting
440             continue
441         # check if there is the file sat-config.pyconf file in the installation
442         # directory    
443         config_file = os.path.join(prod_dir, dir_or_file, src.CONFIG_FILENAME)
444         if not os.path.exists(config_file):
445             continue
446         
447         # If there is no dependency, it is the right path
448         if len(prod_info.depend)==0:
449             compile_cfg = src.pyconf.Config(config_file)
450             if len(compile_cfg) == 0:
451                 return True, os.path.join(prod_dir, dir_or_file)
452             continue
453         
454         # check if there is the config described in the file corresponds the 
455         # dependencies of the product
456         config_corresponds = True    
457         compile_cfg = src.pyconf.Config(config_file)
458         for prod_dep in prod_info.depend:
459             # if the dependency is not in the config, 
460             # the config does not correspond
461             if prod_dep not in compile_cfg:
462                 config_corresponds = False
463                 break
464             else:
465                 prod_dep_info = get_product_config(config, prod_dep, False)
466                 # If the version of the dependency does not correspond, 
467                 # the config does not correspond
468                 if prod_dep_info.version != compile_cfg[prod_dep]:
469                     config_corresponds = False
470                     break
471         
472         for prod_name in compile_cfg:
473             if prod_name not in prod_info.depend:
474                 config_corresponds = False
475                 break
476         
477         if config_corresponds:
478             return True, os.path.join(prod_dir, dir_or_file)
479     
480     return False, None
481             
482             
483     
484 def get_products_infos(lproducts, config):
485     """Get the specific configuration of a list of products
486     
487     :param lproducts List: The list of product names
488     :param config Config: The global configuration
489     :return: the list of tuples 
490              (product name, specific configuration of the product)
491     :rtype: [(str, Config)]
492     """
493     products_infos = []
494     # Loop on product names
495     for prod in lproducts:       
496         # Get the specific configuration of the product
497         prod_info = get_product_config(config, prod)
498         if prod_info is not None:
499             products_infos.append((prod, prod_info))
500         else:
501             msg = _("The %s product has no definition "
502                     "in the configuration.") % prod
503             raise src.SatException(msg)
504     return products_infos
505
506 def get_product_dependencies(config, product_info):
507     """\
508     Get recursively the list of products that are 
509     in the product_info dependencies
510     
511     :param config Config: The global configuration
512     :param product_info Config: The configuration specific to 
513                                the product
514     :return: the list of products in dependence
515     :rtype: list
516     """
517     if "depend" not in product_info or product_info.depend == []:
518         return []
519     res = []
520     for prod in product_info.depend:
521         if prod == product_info.name:
522             continue
523         if prod not in res:
524             res.append(prod)
525         prod_info = get_product_config(config, prod)
526         dep_prod = get_product_dependencies(config, prod_info)
527         for prod_in_dep in dep_prod:
528             if prod_in_dep not in res:
529                 res.append(prod_in_dep)
530     return res
531
532 def check_installation(product_info):
533     """\
534     Verify if a product is well installed. Checks install directory presence
535     and some additional files if it is defined in the config 
536     
537     :param product_info Config: The configuration specific to 
538                                the product
539     :return: True if it is well installed
540     :rtype: boolean
541     """
542     if not product_compiles(product_info):
543         return True
544     install_dir = product_info.install_dir
545     if not os.path.exists(install_dir):
546         return False
547     if ("present_files" in product_info and 
548         "install" in product_info.present_files):
549         for file_relative_path in product_info.present_files.install:
550             file_path = os.path.join(install_dir, file_relative_path)
551             if not os.path.exists(file_path):
552                 return False
553     return True
554
555 def check_source(product_info):
556     """Verify if a sources of product is preset. Checks source directory presence
557     
558     :param product_info Config: The configuration specific to 
559                                the product
560     :return: True if it is well installed
561     :rtype: boolean
562     """
563     DBG.write("check_source product_info", product_info)
564     source_dir = product_info.source_dir
565     if not os.path.exists(source_dir):
566         return False
567     if ("present_files" in product_info and 
568         "source" in product_info.present_files):
569         for file_relative_path in product_info.present_files.source:
570             file_path = os.path.join(source_dir, file_relative_path)
571             if not os.path.exists(file_path):
572                 return False
573     return True
574
575 def product_is_sample(product_info):
576     """Know if a product has the sample type
577     
578     :param product_info Config: The configuration specific to 
579                                the product
580     :return: True if the product has the sample type, else False
581     :rtype: boolean
582     """
583     if 'type' in product_info:
584         ptype = product_info.type
585         return ptype.lower() == 'sample'
586     else:
587         return False
588
589 def product_is_salome(product_info):
590     """Know if a product is a SALOME module
591     
592     :param product_info Config: The configuration specific to 
593                                the product
594     :return: True if the product is a SALOME module, else False
595     :rtype: boolean
596     """
597     return ("properties" in product_info and
598             "is_SALOME_module" in product_info.properties and
599             product_info.properties.is_SALOME_module == "yes")
600
601 def product_is_fixed(product_info):
602     """Know if a product is fixed
603     
604     :param product_info Config: The configuration specific to 
605                                the product
606     :return: True if the product is fixed, else False
607     :rtype: boolean
608     """
609     get_src = product_info.get_source
610     return get_src.lower() == 'fixed'
611
612 def product_is_native(product_info):
613     """Know if a product is native
614     
615     :param product_info Config: The configuration specific to 
616                                the product
617     :return: True if the product is native, else False
618     :rtype: boolean
619     """
620     get_src = product_info.get_source
621     return get_src.lower() == 'native'
622
623 def product_is_dev(product_info):
624     """Know if a product is in dev mode
625     
626     :param product_info Config: The configuration specific to 
627                                the product
628     :return: True if the product is in dev mode, else False
629     :rtype: boolean
630     """
631     dev = product_info.dev
632     res = (dev.lower() == 'yes')
633     DBG.write('product_is_dev %s' % product_info.name, res)
634     # if product_info.name == "XDATA": return True #test #10569
635     return res
636
637 def product_is_debug(product_info):
638     """Know if a product is in debug mode
639     
640     :param product_info Config: The configuration specific to 
641                                the product
642     :return: True if the product is in debug mode, else False
643     :rtype: boolean
644     """
645     debug = product_info.debug
646     return debug.lower() == 'yes'
647
648 def product_is_autotools(product_info):
649     """Know if a product is compiled using the autotools
650     
651     :param product_info Config: The configuration specific to 
652                                the product
653     :return: True if the product is autotools, else False
654     :rtype: boolean
655     """
656     build_src = product_info.build_source
657     return build_src.lower() == 'autotools'
658
659 def product_is_cmake(product_info):
660     """Know if a product is compiled using the cmake
661     
662     :param product_info Config: The configuration specific to 
663                                the product
664     :return: True if the product is cmake, else False
665     :rtype: boolean
666     """
667     build_src = product_info.build_source
668     return build_src.lower() == 'cmake'
669
670 def product_is_vcs(product_info):
671     """Know if a product is download using git, svn or cvs (not archive)
672     
673     :param product_info Config: The configuration specific to 
674                                the product
675     :return: True if the product is vcs, else False
676     :rtype: boolean
677     """
678     return product_info.get_source in AVAILABLE_VCS
679
680 def product_is_smesh_plugin(product_info):
681     """Know if a product is a SMESH plugin
682     
683     :param product_info Config: The configuration specific to 
684                                the product
685     :return: True if the product is a SMESH plugin, else False
686     :rtype: boolean
687     """
688     return ("properties" in product_info and
689             "smesh_plugin" in product_info.properties and
690             product_info.properties.smesh_plugin == "yes")
691
692 def product_is_cpp(product_info):
693     """Know if a product is cpp
694     
695     :param product_info Config: The configuration specific to 
696                                the product
697     :return: True if the product is a cpp, else False
698     :rtype: boolean
699     """
700     return ("properties" in product_info and
701             "cpp" in product_info.properties and
702             product_info.properties.cpp == "yes")
703
704 def product_compiles(product_info):
705     """\
706     Know if a product compiles or not 
707     (some products do not have a compilation procedure)
708     
709     :param product_info Config: The configuration specific to 
710                                the product
711     :return: True if the product compiles, else False
712     :rtype: boolean
713     """
714     return not("properties" in product_info and
715             "compilation" in product_info.properties and
716             product_info.properties.compilation == "no")
717
718 def product_has_script(product_info):
719     """Know if a product has a compilation script
720     
721     :param product_info Config: The configuration specific to 
722                                the product
723     :return: True if the product it has a compilation script, else False
724     :rtype: boolean
725     """
726     if "build_source" not in product_info:
727         # Native case
728         return False
729     build_src = product_info.build_source
730     return build_src.lower() == 'script'
731
732 def product_has_env_script(product_info):
733     """Know if a product has an environment script
734     
735     :param product_info Config: The configuration specific to 
736                                the product
737     :return: True if the product it has an environment script, else False
738     :rtype: boolean
739     """
740     return "environ" in product_info and "env_script" in product_info.environ
741
742 def product_has_patches(product_info):
743     """Know if a product has one or more patches
744     
745     :param product_info Config: The configuration specific to 
746                                the product
747     :return: True if the product has one or more patches
748     :rtype: boolean
749     """   
750     res = ( "patches" in product_info and len(product_info.patches) > 0 )
751     DBG.write('product_has_patches %s' % product_info.name, res)
752     # if product_info.name == "XDATA": return True #test #10569
753     return res
754
755 def product_has_logo(product_info):
756     """Know if a product has a logo (YACSGEN generate)
757     
758     :param product_info Config: The configuration specific to 
759                                the product
760     :return: The path of the logo if the product has a logo, else False
761     :rtype: Str
762     """
763     if ("properties" in product_info and
764             "logo" in product_info.properties):
765         return product_info.properties.logo
766     else:
767         return False
768
769 def product_has_salome_gui(product_info):
770     """Know if a product has a SALOME gui
771     
772     :param product_info Config: The configuration specific to 
773                                the product
774     :return: True if the product has a SALOME gui, else False
775     :rtype: Boolean
776     """
777     return ("properties" in product_info and
778             "has_salome_gui" in product_info.properties and
779             product_info.properties.has_salome_gui == "yes")
780
781 def product_is_mpi(product_info):
782     """Know if a product has openmpi in its dependencies
783     
784     :param product_info Config: The configuration specific to 
785                                the product
786     :return: True if the product has openmpi inits dependencies
787     :rtype: boolean
788     """
789     return "openmpi" in product_info.depend
790
791 def product_is_generated(product_info):
792     """Know if a product is generated (YACSGEN)
793     
794     :param product_info Config: The configuration specific to 
795                                the product
796     :return: True if the product is generated
797     :rtype: boolean
798     """
799     return ("properties" in product_info and
800             "generate" in product_info.properties and
801             product_info.properties.generate == "yes")
802
803 def get_product_components(product_info):
804     """Get the component list to generate with the product
805     
806     :param product_info Config: The configuration specific to 
807                                the product
808     :return: The list of names of the components
809     :rtype: List
810     
811     """
812     if not product_is_generated(product_info):
813         return []
814     
815     compo_list = []
816     if "component_name" in product_info:
817         compo_list = product_info.component_name
818     
819         if isinstance(compo_list, str):
820             compo_list = [ compo_list ]
821
822     return compo_list