'''
# 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
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:
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:
"""
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:
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":
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):