X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2Fproduct.py;h=211c0b648933204053f1310600c06a7f1d6ea298;hb=4d36de2692d0f6f724cdc10a248a0af86f9f2dcc;hp=d19a5e52629727953782ec51e88fd6688ae57611;hpb=3a40135f59bc0f252d5ecc04151a70173fba0d01;p=tools%2Fsat.git diff --git a/src/product.py b/src/product.py index d19a5e5..211c0b6 100644 --- a/src/product.py +++ b/src/product.py @@ -45,6 +45,7 @@ def get_product_config(config, product_name): # current product debug = 'no' dev = 'no' + base = 'maybe' if isinstance(version, src.pyconf.Mapping): dic_version = version # Get the version/tag @@ -60,55 +61,61 @@ def get_product_config(config, product_name): # Get the dev if any if 'dev' in dic_version: dev = dic_version.dev + + # Get the dev if any + if 'base' in dic_version: + base = dic_version.base vv = version # substitute some character with _ in order to get the correct definition # in config.PRODUCTS. This is done because the pyconf tool does not handle # the . and - characters for c in ".-": vv = vv.replace(c, "_") - full_product_name = product_name + '_' + vv - - prod_info = None - # If it exists, get the information of the product_version - if full_product_name in config.PRODUCTS: - # returns specific information for the given version - prod_info = config.PRODUCTS[full_product_name] - # Get the standard informations - elif product_name in config.PRODUCTS: - # returns the generic information (given version not found) - prod_info = config.PRODUCTS[product_name] - - # merge opt_depend in depend - if prod_info is not None and 'opt_depend' in prod_info: - for depend in prod_info.opt_depend: - if depend in config.PRODUCTS: - prod_info.depend.append(depend,'') - # In case of a product get with a vcs, put the tag (equal to the version) - if prod_info is not None and prod_info.get_source in AVAILABLE_VCS: + prod_info = None + if product_name in config.PRODUCTS: + # If it exists, get the information of the product_version + if "version_" + vv in config.PRODUCTS[product_name]: + # returns specific information for the given version + prod_info = config.PRODUCTS[product_name]["version_" + vv] + # Get the standard informations + elif "default" in config.PRODUCTS[product_name]: + # returns the generic information (given version not found) + prod_info = config.PRODUCTS[product_name].default - if prod_info.get_source == 'git': - prod_info.git_info.tag = version + # merge opt_depend in depend + if prod_info is not None and 'opt_depend' in prod_info: + for depend in prod_info.opt_depend: + if depend in config.PRODUCTS: + prod_info.depend.append(depend,'') - if prod_info.get_source == 'svn': - prod_info.svn_info.tag = version + # In case of a product get with a vcs, + # put the tag (equal to the version) + if prod_info is not None and prod_info.get_source in AVAILABLE_VCS: + + if prod_info.get_source == 'git': + prod_info.git_info.tag = version + + if prod_info.get_source == 'svn': + prod_info.svn_info.tag = version + + if prod_info.get_source == 'cvs': + prod_info.cvs_info.tag = version - if prod_info.get_source == 'cvs': - prod_info.cvs_info.tag = version - - # In case of a fixed product, define the install_dir (equal to the version) - if prod_info is not None and prod_info.get_source=="fixed": - prod_info.install_dir = version - - # Check if the product is defined as native in the application - if prod_info is not None: - if version == "native": - prod_info.get_source = "native" - elif prod_info.get_source == "native": - msg = _("The product %(prod)s has version %(ver)s but is declared" - " as native in its definition" % - { 'prod': prod_info.name, 'ver': version}) - raise src.SatException(msg) + # In case of a fixed product, + # define the install_dir (equal to the version) + if prod_info is not None and prod_info.get_source=="fixed": + prod_info.install_dir = version + + # Check if the product is defined as native in the application + if prod_info is not None: + if version == "native": + prod_info.get_source = "native" + elif prod_info.get_source == "native": + msg = _("The product %(prod)s has version %(ver)s but is " + "declared as native in its definition" % + { 'prod': prod_info.name, 'ver': version}) + raise src.SatException(msg) # If there is no definition but the product is declared as native, # construct a new definition containing only the get_source key @@ -135,23 +142,50 @@ def get_product_config(config, product_name): prod_info.addMapping("archive_info", src.pyconf.Mapping(prod_info), "") - if "archive_name" not in prod_info.archive_info: - arch_name = os.path.join(config.SITE.prepare.archive_dir, - product_name + "-" + version + ".tar.gz") - prod_info.archive_info.archive_name = arch_name + if "archive_name" not in prod_info.archive_info: + arch_name = product_name + "-" + version + ".tar.gz" + 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 + else: + if (os.path.basename(prod_info.archive_info.archive_name) == + prod_info.archive_info.archive_name): + + arch_path = src.find_file_in_lpath( + prod_info.archive_info.archive_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 # Set the install_dir key - if "install_dir" not in prod_info: + if "no_base" in config.APPLICATION and config.APPLICATION.no_base == "yes": # Set it to the default value (in application directory) prod_info.install_dir = os.path.join(config.APPLICATION.workdir, "INSTALL", prod_info.name) else: - if prod_info.install_dir == "base": - # Get the product base of the application - base_path = src.get_base_path(config) - prod_info.install_dir = os.path.join(base_path, - prod_info.name + "-" + version) + if base == "yes": + prod_info.install_dir = "base" + if "install_dir" not in prod_info: + # Set it to the default value (in application directory) + prod_info.install_dir = os.path.join(config.APPLICATION.workdir, + "INSTALL", + prod_info.name) + else: + if prod_info.install_dir == "base": + # Get the product base of the application + base_path = src.get_base_path(config) + prod_info.install_dir = os.path.join(base_path, + prod_info.name + "-" + version) # If the product compiles with a script, check the script existence # and if it is executable @@ -168,21 +202,58 @@ def get_product_config(config, product_name): script_name = os.path.basename(script) if script == script_name: # Only a name is given. Search in the default directory - script_path = os.path.join( - config.INTERNAL.compile.default_script_dir, script_name) + script_path = src.find_file_in_lpath(script_name, + config.PATHS.PRODUCTPATH, + "compil_scripts") + if not script_path: + raise src.SatException(_("Compilation script not found: %s") % + script_name) prod_info.compil_script = script_path - - # Check script existence - if not os.path.exists(prod_info.compil_script): - raise src.SatException(_("Compilation script not found: %s") % - prod_info.compil_script) - + # 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) - + + # Get the full paths of all the patches + if "patches" in 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) + prod_info.patches = patches + + # Get the full paths of the environment scripts + if "environ" in prod_info and "env_script" in prod_info.environ: + env_script_path = prod_info.environ.env_script + # If only a filename, then search for the environment script + # in the PRODUCTPATH/env_scripts + if os.path.basename(env_script_path) == env_script_path: + # Search in the PRODUCTPATH/env_scripts + env_script_path = src.find_file_in_lpath( + prod_info.environ.env_script, + config.PATHS.PRODUCTPATH, + "env_scripts") + if not env_script_path: + msg = _("Environment script %(env_name)s for %(prod_name)s not " + "found.\n" % {"env_name" : env_script_path, + "prod_name" : prod_info.name}) + raise src.SatException(msg) + + prod_info.environ.env_script = env_script_path + return prod_info def get_products_infos(lproducts, config):