]> SALOME platform Git repositories - tools/sat.git/commitdiff
Salome HOME
spns #40779: support multi repositories
authorNabil Ghodbane <nabil.ghodbane@cea.fr>
Sat, 4 May 2024 12:49:05 +0000 (14:49 +0200)
committerNabil Ghodbane <nabil.ghodbane@cea.fr>
Sat, 4 May 2024 12:49:05 +0000 (14:49 +0200)
commands/compile.py
commands/config.py
commands/package.py
commands/prepare.py
commands/source.py
data/local.pyconf
src/__init__.py
src/environment.py
src/internal_config/git_repo_servers.pyconf [new file with mode: 0644]
src/product.py

index afdad9b70f0373cc8ec628881a1d385767faf3e8..545a502b492dbc4bc6f726814baba18ab34c256b 100644 (file)
@@ -168,7 +168,7 @@ def compile_all_products(sat, config, options, products_infos, all_products_dict
         if src.product.product_is_salome(p_info):
             check_salome_configuration=True
         
-        if config.APPLICATION.properties.github == 'yes' and src.product.product_test_property(p_info,"is_opensource", "no"):
+        if src.product.product_test_property(p_info,"is_opensource", "no") and not src.check_git_repository_has_non_opensource(config, config.APPLICATION.properties.git_server):
             continue
         # nothing to clean for native or fixed products
         if (not src.product.product_compiles(p_info)) or\
@@ -277,7 +277,7 @@ def compile_all_products(sat, config, options, products_infos, all_products_dict
             log_step(logger, header, "ignored")
             logger.write("\n", 3, False)
             continue
-        if config.APPLICATION.properties.github == 'yes' and src.product.product_test_property(p_info,"is_opensource", "no"):
+        if src.product.product_test_property(p_info,"is_opensource", "no") and not src.check_git_repository_has_non_opensource(config, config.APPLICATION.properties.git_server):
             log_step(logger, header, "ignored")
             logger.write("\n", 3, False)
             continue
index a5997bb7814fcc265dbeef9d3df3413f44d0eb58..fa6a8097846df2c7468f324545e788dfeedffdcc 100644 (file)
@@ -201,7 +201,13 @@ class ConfigManager:
         # particular win case 
         if src.architecture.is_windows() : 
             var['tmp_root'] =  os.path.expanduser('~') + os.sep + 'tmp'
-        
+        repositories_cfg = src.pyconf.Config( osJoin(var['srcDir'], 'internal_config', 'git_repo_servers.pyconf'))
+        var['repositories_servers'] = []
+        var['opensource_repositories_servers'] =[]
+        for repo_server in repositories_cfg.REPOSITORIES_SERVERS:
+          var['repositories_servers']+=[repo_server]
+          if repositories_cfg.REPOSITORIES_SERVERS[repo_server] == 'opensource':
+            var['opensource_repositories_servers']+=[repo_server]
         return var
 
     def get_command_line_overrides(self, options, sections):
@@ -381,7 +387,6 @@ class ConfigManager:
         cfg.addMapping("PATHS", src.pyconf.Mapping(cfg), "The paths\n")
         cfg.PATHS["APPLICATIONPATH"] = src.pyconf.Sequence(cfg.PATHS)
         cfg.PATHS.APPLICATIONPATH.append(cfg.VARS.personal_applications_dir, "")
-
         
         cfg.PATHS["PRODUCTPATH"] = src.pyconf.Sequence(cfg.PATHS)
         cfg.PATHS.PRODUCTPATH.append(cfg.VARS.personal_products_dir, "")
index 9ee70334c1396134273bbc7c48dacfd04163469e..1eb702b0122b91de376b0a69169730150b535969 100644 (file)
@@ -678,6 +678,7 @@ def binary_package(config, logger, options, tmp_working_dir):
         config.APPLICATION.properties.mesa_launcher_in_package == "yes") :
             generate_mesa_launcher=True
 
+    has_properties  = "APPLICATION" in config and "properties" in config.APPLICATION
     # first loop on products : filter products, analyse properties,
     # and store the information that will be used to create the archive in the second loop
     for prod_name, prod_info in l_product_info:
@@ -685,8 +686,7 @@ def binary_package(config, logger, options, tmp_working_dir):
         if src.get_property_in_product_cfg(prod_info, "not_in_package") == "yes":
             continue
 
-        # skip product if github and product is not opensource
-        if config.APPLICATION.properties.github == "yes" and src.get_property_in_product_cfg(prod_info, "is_opensource") == "no":
+        if src.product.product_is_not_opensource(prod_info) and src.check_git_repository_has_non_opensource( cfg, git_server):
             continue
 
         # Add the sources of the products that have the property
@@ -997,8 +997,12 @@ def get_archives(config, logger):
                 or src.product.product_is_fixed(p_info)):
             continue
 
-        # skip product if github and product is not opensource
-        if config.APPLICATION.properties.github == "yes" and src.get_property_in_product_cfg(p_info, "is_opensource") == "no":
+        # skip product if git server misses non opensource products
+        is_not_prod_opensource       = src.product.product_is_not_opensource(p_info)
+        git_server = src.get_git_server(config,logger)
+        has_git_server_non_opensource = src.check_git_repository_has_non_opensource( config, git_server)
+        if has_git_server_non_opensource and is_not_prod_opensource:
+            logger.warning("%s is a closed-source software and is not available on %s" % (product, git_server))
             continue
 
         if p_info.get_source == "archive":
index d147699addb5a1e0b76555c47f7eb0a5fce23573..c86f76902ebfde2652cf0572192c0e79ba2ec838 100644 (file)
@@ -97,7 +97,10 @@ def run(args, runner, logger):
         listProd = list(options.products)
     else: # no product interpeted as all products
         listProd = [name for name, tmp in products_infos]
-    if runner.cfg.APPLICATION.properties.github == 'yes':
+
+    git_server = src.get_git_server(runner.cfg,logger)
+
+    if src.check_git_repository_has_non_opensource( runner.cfg, git_server):
         not_opensource_products = [p for p in products_infos if src.product.product_is_not_opensource(p[1])]
         listProd = [p for p in listProd if p not in [name for name, tmp in not_opensource_products]]
 
index 9ed87eddead89c1ad9ee8ce14794ea2c5898fa63..b8b8da51b556db7d22d1c0f4d5a2eb25c948ae14 100644 (file)
@@ -85,25 +85,41 @@ def get_source_from_git(config,
     '''
     # The str to display
     coflag = 'git'
-
-    use_repo_dev = "APPLICATION" in config and "properties" in config.APPLICATION and "github" in config.APPLICATION.properties and not config.APPLICATION.properties.github == "yes"
-    if ("APPLICATION" in config  and
-            "properties"  in config.APPLICATION  and
-            "repo_dev"    in config.APPLICATION.properties  and
-            config.APPLICATION.properties.repo_dev == "yes" and
-            use_repo_dev == True ) :
-                use_repo_dev=True
-
     # Get the repository address.
     # If the application has the repo_dev property
     # Or if the product is in dev mode
     # Then we use repo_dev if the key exists
-    if (is_dev or use_repo_dev) and 'repo_dev' in product_info.git_info:
-        coflag = src.printcolors.printcHighlight(coflag.upper())
-        repo_git = product_info.git_info.repo_dev    
+    coflag = src.printcolors.printcHighlight(coflag.upper())
+    repo_git = None
+    git_server = src.get_git_server(config,logger)
+    product_file = product_info.from_file.split('/').pop()
+    if 'git_info' in  product_info and 'repo_name' in product_info.git_info:
+        if git_server in product_info.git_info.repo_name.keys():
+            repo_git = product_info.git_info.repo_name[git_server]
+        elif 'properties' in product_info and 'is_opensource' in product_info.properties and product_info.properties.is_opensource == 'yes' :
+            for git_server in product_info.git_info.repo_name.keys():
+                if git_server in config.VARS.opensource_repositories_servers:
+                    repo_git =  product_info.git_info.repo_name[git_server]
+                    break
+        elif 'properties' in product_info and not 'is_opensource' in product_info.properties:
+            for git_server in product_info.git_info.repo_name.keys():
+                if git_server in config.VARS.opensource_repositories_servers:
+                    repo_git =  product_info.git_info.repo_name[git_server]
+                    logger.warning("Using opensource repository ({}) for product {}".format(git_server, product_info.name))
+                    break
+        else:
+            logger.error("Error in configuration file: define git repository for product: {} in file {}".format(product_info.name, product_file))
+            return False
+
+    elif 'repo_dev' in product_info.git_info:
+        repo_git = product_info.git_info.repo_dev
     else:
-        repo_git = product_info.git_info.repo    
+        logger.error("Error in configuration file: define git repository for product: {}".format(product_info.name))
+        return False
 
+    if repo_git is None:
+        logger.error("Error in configuration file: define git repository for product: {} in file {}.".format(product_info.name, product_file))
+        return False
 
     # Display informations
     logger.write('%s:%s' % (coflag, src.printcolors.printcInfo(repo_git)), 3, 
index 24ee9ebec4a3ac1a969c9399cd81270e5efed655..8096362777e1f6e5cc65684558761ffcff0be0d8 100644 (file)
@@ -1,4 +1,3 @@
-
   LOCAL :
   {
     base : 'default'
@@ -12,5 +11,7 @@
   {
     project_file_paths :
     [
+      '../SAT_SALOME/salome.pyconf'
+      '../SAT_SALOMEAPP/salomeapp.pyconf'
     ]
   }
index 9f3e8d1e7a2fc26019dbee57d82f3ecee2954470..af2ef896150716c276468dc84cd3c3049da02bb7 100644 (file)
@@ -622,3 +622,30 @@ def activate_mesa_property(config):
     if not 'properties' in config.APPLICATION:
         config.APPLICATION.addMapping( 'properties', pyconf.Mapping(), None )
     config.APPLICATION.properties.use_mesa="yes"
+
+def check_git_repository_has_non_opensource( config, the_git_server):
+    """check that the git repository contains non public repositories
+    :param config class 'common.pyconf.Config': The config.
+    :param logger Logger: The logging instance to use for the prints.
+    """
+    if 'opensource_repositories_servers' in config.VARS:
+        for git_server in config.VARS.opensource_repositories_servers:
+            if git_server == the_git_server:
+                return True
+    return False
+    return
+
+def get_git_server(config, logger):
+    git_server= None
+    has_properties =  'properties' in config.APPLICATION
+    if has_properties and "git_server" in config.APPLICATION.properties:
+        git_server =  config.APPLICATION.properties.git_server
+    elif has_properties and "repo_dev" in config.APPLICATION.properties:
+        # Fall back to deprecated approach but issue a warning that this approach is deprecated
+        logger.warning("repo_dev is deprecated and will be removed from future SAT releases!")
+        logger.warning("Please upgrade your application configuration file and the product description file!")
+        if config.APPLICATION.properties.repo_dev == 'yes':
+            git_server = [ repositories_server for repositories_server in config.VARS.repositories_servers if repositories_server not in config.VARS.opensource_repositories_servers][0]
+        else:
+            git_server =  [ repositories_server for repositories_server in config.VARS.repositories_servers if repositories_server in config.VARS.opensource_repositories_servers][0]
+    return git_server
index b928f937427cd65367c5deef6f437a96b351a6b0..525c4c5ed089e90224a302a7ec0e550efd365474 100644 (file)
@@ -604,8 +604,12 @@ class SalomeEnviron:
         #    src.appli_test_property(self.cfg,"pip_install_dir", "python") ):
         #        return
 
-        # skip product if github and product is not opensource
-        if self.cfg.APPLICATION.properties.github == "yes" and src.get_property_in_product_cfg(pi, "is_opensource") == "no":
+        # skip product if git server misses non opensource products
+        is_not_prod_opensource       = src.product.product_is_not_opensource(pi)
+        git_server= get_fit_server(self.cfg, logger)
+        has_git_server_non_opensource = src.check_git_repository_has_non_opensource( self.cfg, git_server)
+        if has_git_server_non_opensource and is_not_prod_opensource:
+            logger.warning("%s is a closed-source software and is not available on %s" % (pi.name, git_server))
             return
 
         # skip mesa products (if any) at run time, 
diff --git a/src/internal_config/git_repo_servers.pyconf b/src/internal_config/git_repo_servers.pyconf
new file mode 100644 (file)
index 0000000..3d7213e
--- /dev/null
@@ -0,0 +1,10 @@
+#!/usr/bin/env python
+#-*- coding:utf-8 -*-
+
+REPOSITORIES_SERVERS :
+{
+    "tuleap" : "all"
+    "github" : "opensource"
+    "gitpub" : "opensource"
+}
+
index 8bce492692caf74673d7cc9190659333e3a1d2e3..a2f80f7035e0e45f0b2dbbd82b1ecaf5dc878d4e 100644 (file)
@@ -393,7 +393,6 @@ Please provide a 'compil_script' key in its definition.""") % product_name
         
         # Set the install_dir key
         prod_info.install_dir,prod_info.install_mode = get_install_dir(config, version, prod_info)
-                
     return prod_info
 
 def get_product_section(config, product_name, version, section=None):
@@ -798,7 +797,34 @@ def get_products_list(options, cfg, logger):
     # Get the products to be prepared, regarding the options
     if options.products is None:
         # No options, get all products sources
-        products = cfg.APPLICATION.products
+        products=[]
+        for product in cfg.APPLICATION.products.keys():
+            prod_info = get_product_config(cfg, product)
+            print(prod_info.name)
+            if prod_info is None:
+                logger.error("%s does not have associated information" % (product))
+                continue
+            if 'get_source' in prod_info and prod_info.get_source == 'git':
+                is_prod_opensource = not src.product.product_is_not_opensource(prod_info)
+                git_server= None
+                if not 'git_server' in cfg.APPLICATION.properties:
+                    if 'repo_dev' in cfg.APPLICATION.properties:
+                        # Fall back to deprecated approach but issue a warning that this approach is deprecated
+                        warning_msg ="repo_dev is deprecated and will be removed from future SAT releases!\n"
+                        warning_msg+="Please upgrade your application configuration file and the product description file!"
+                        if cfg.APPLICATION.properties.repo_dev == 'yes':
+                            git_server = [ repositories_server for repositories_server in cfg.VARS.repositories_servers if repositories_server not in cfg.VARS.opensource_repositories_servers][0]
+                        else:
+                            git_server =  [ repositories_server for repositories_server in cfg.VARS.repositories_servers if repositories_server in cfg.VARS.opensource_repositories_servers][0]
+                else:
+                    git_server =  cfg.APPLICATION.properties.git_server
+
+                has_git_server_non_opensource = src.check_git_repository_has_non_opensource( cfg, git_server)
+                if has_git_server_non_opensource and not is_prod_opensource:
+                    logger.warning("%s is a closed-source software and is not available on %s" % (product, git_server))
+                    continue
+            products+=[product]
+        products = src.getProductNames(cfg, products, logger)
     else:
         # if option --products, check that all products of the command line
         # are present in the application.
@@ -810,7 +836,6 @@ def get_products_list(options, cfg, logger):
                         { 'product': p, 'application': cfg.VARS.application} )"""
 
         products = src.getProductNames(cfg, options.products, logger)
-
     # Construct the list of tuple containing
     # the products name and their definition
     resAll = src.product.get_products_infos(products, cfg)
@@ -1098,11 +1123,11 @@ def product_is_cpp(product_info):
             product_info.properties.cpp == "yes")
 
 def product_is_not_opensource(product_info):
-    """Check if a given product is not open
+    """Check if a given product is closed-source
     
     :param product_info Config: The configuration specific to 
                                the product
-    :return: True if the product is an opensource, False otherwise
+    :return: True if the product is an closed-source, False otherwise
     :rtype: boolean
     """
     return ("properties" in product_info and