From 4fe321f1c371bca5d56063a800c6da8404c7dc23 Mon Sep 17 00:00:00 2001 From: Christian Van Wambeke Date: Tue, 20 Mar 2018 10:44:05 +0100 Subject: [PATCH] fix #8576 #8646 --- commands/check.py | 6 +++--- commands/compile.py | 27 +++++++++++++++------------ commands/config.py | 4 +++- commands/package.py | 5 ++--- commands/source.py | 5 ++--- src/product.py | 38 ++++++++++++++++++++++++++++++++------ 6 files changed, 57 insertions(+), 28 deletions(-) diff --git a/commands/check.py b/commands/check.py index cfa2c82..4a490a4 100644 --- a/commands/check.py +++ b/commands/check.py @@ -23,8 +23,8 @@ import src # Define all possible option for the check command : sat check 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 diff --git a/commands/compile.py b/commands/compile.py index 5f15b83..2859abd 100644 --- a/commands/compile.py +++ b/commands/compile.py @@ -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 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) diff --git a/commands/config.py b/commands/config.py index 5d48be5..f048db3 100644 --- a/commands/config.py +++ b/commands/config.py @@ -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]: diff --git a/commands/package.py b/commands/package.py index 82c19ce..09fef8f 100644 --- a/commands/package.py +++ b/commands/package.py @@ -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 diff --git a/commands/source.py b/commands/source.py index a616c77..c8d34f1 100644 --- a/commands/source.py +++ b/commands/source.py @@ -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) diff --git a/src/product.py b/src/product.py index 81ad048..a7acab6 100644 --- a/src/product.py +++ b/src/product.py @@ -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 -- 2.39.2