]> SALOME platform Git repositories - tools/sat.git/commitdiff
Salome HOME
sat #19109 : choix plus robuste du gestionnaire de paquets, et utilisation de platfor...
authorNicolas CROUZET - SFME/LGLS <crouzet@is228840.intra.cea.fr>
Thu, 14 May 2020 09:02:45 +0000 (11:02 +0200)
committerNicolas CROUZET - SFME/LGLS <crouzet@is228840.intra.cea.fr>
Thu, 14 May 2020 09:02:45 +0000 (11:02 +0200)
commands/config.py
commands/source.py
src/architecture.py
src/product.py
src/system.py

index 927a889ddc44e285bd60f1b4c455f39eceef736f..f5e539c2a0223af6fbb13a034335087a372d4643 100644 (file)
@@ -794,7 +794,7 @@ def check_install_system(config, logger):
   '''
   # get the command to use for checking the system dependencies
   # (either rmp or apt)
-  check_cmd=src.system.get_pkg_check_cmd()
+  check_cmd=src.system.get_pkg_check_cmd(config.VARS.dist_name)
   logger.write("\nCheck the system dependencies declared in the application\n",1)
   pkgmgr=check_cmd[0]
   run_dep_ko=[] # list of missing run time dependencies
index 0f744a5c976ad2094ece55ecb2353f7538196f33..85ed4bee6f89cbb42d38bf7953ee2dba2f6c3362 100644 (file)
@@ -401,7 +401,7 @@ def get_product_sources(config,
     if product_info.get_source == "native":
         # for native products we check the corresponding system packages are installed
         logger.write("Native : Checking system packages are installed\n" , 3)
-        check_cmd=src.system.get_pkg_check_cmd() # (either rmp or apt)
+        check_cmd=src.system.get_pkg_check_cmd(config.VARS.dist_name) # (either rmp or apt)
         run_pkg,build_pkg=src.product.check_system_dep(check_cmd, product_info)
         result=True
         for pkg in run_pkg:
index 7d66a03d96c31fca332b525691f28987e1561ecc..7ca34e809343d2aff16670b0b4a424dd4b907e91 100644 (file)
@@ -59,7 +59,7 @@ def get_distribution(codes):
         return "W"
 
     # else get linux distribution description from platform, and encode it with code
-    lin_distrib = platform.dist()[0].lower()
+    lin_distrib = platform.linux_distribution()[0].lower()
     distrib="not found"
     for dist in codes:
         if dist in lin_distrib:
@@ -76,9 +76,9 @@ def get_version_XY():
     """
     Return major and minor version of the distribution
     from a CentOS example, returns '7.6'
-    extracted from platform.dist()
+    extracted from platform.linux_distribution()
     """
-    dist_version=platform.dist()[1].split('.')
+    dist_version=platform.linux_distribution()[1].split('.')
     if len(dist_version)==1:
         version = dist_version[0]
     else:
@@ -102,7 +102,7 @@ def get_distrib_version(distrib):
         return platform.release()
 
     # get version from platform
-    dist_version=platform.dist()[1].split('.')
+    dist_version=platform.linux_distribution()[1].split('.')
 
     # encode it (conform to src/internal_config/distrib.pyconf VERSIONS dist
     if distrib == "CO":
index 7323a283afbd8ab6513b2855d2b02ba9f44210d5..32af95964dddbc89b09562d50dc7dcee5be7a045 100644 (file)
@@ -839,7 +839,7 @@ def check_installation(config, product_info):
 
     if product_is_native(product_info):
         # check a system product
-        check_cmd=src.system.get_pkg_check_cmd()
+        check_cmd=src.system.get_pkg_check_cmd(config.VARS.dist_name)
         run_pkg,build_pkg=src.product.check_system_dep(check_cmd, product_info)
         build_dep_ko=[]
         for pkg in build_pkg:
index 3a87433f6b01dd0f79aba20a3ee867cfa4ba1d31..33608074be29fcece617cfd57b81976518b4890b 100644 (file)
@@ -324,24 +324,32 @@ def svn_extract(user,
                           stderr=subprocess.STDOUT)
     return (res == 0)
 
-def get_pkg_check_cmd():
+def get_pkg_check_cmd(dist_name):
     '''Build the command to use for checking if a linux package is installed or not.'''
+
+    if dist_name in ["CO","FD","MG","MD","CO","OS"]: # linux using rpm
+        linux="RH"  
+        manager_msg_err="Error : command failed because sat was not able to find apt command"
+    else:
+        linux="DB"
+        manager_msg_err="Error : command failed because sat was not able to find rpm command"
+
     # 1- search for an installed package manager (rpm on rh, apt on db)
     cmd_which_rpm=["which", "rpm"]
     cmd_which_apt=["which", "apt"]
     with open(os.devnull, 'w') as devnull:
         # 1) we search for apt (debian based systems)
         completed=subprocess.call(cmd_which_apt,stdout=devnull, stderr=subprocess.STDOUT)
-        if completed==0:
+        if completed==0 and linux=="DB":
             cmd_is_package_installed=["apt", "list", "--installed"]
         else:
             # 2) if apt not found search for rpm (redhat)
             completed=subprocess.call(cmd_which_rpm,stdout=devnull, stderr=subprocess.STDOUT) # only 3.8! ,capture_output=True)
-            if completed==0:
+            if completed==0 and linux=="RH":
                 cmd_is_package_installed=["rpm", "-q"]
             else:
-                # no package manager was found
-                raise src.SatException("Error : command failed because sat was not able to find apt or rpm")
+                # no package manager was found corresponding to dist_name
+                raise src.SatException(manager_msg_err)
     return cmd_is_package_installed
 
 def check_system_pkg(check_cmd,pkg):