Skip to content

Commit

Permalink
fixup! Fixes #18999: when we install a plugin, if the dependency (pac…
Browse files Browse the repository at this point in the history
…kage manager) is not met, it still tries to install it and fails

Fixes #18999: when we install a plugin, if the dependency (package manager) is not met, it still tries to install it and fails
  • Loading branch information
ncharles committed Mar 22, 2021
1 parent cc975b3 commit f2801a8
Showing 1 changed file with 27 additions and 25 deletions.
52 changes: 27 additions & 25 deletions relay/sources/rudder-pkg/lib/rudder-pkg/rudderPkgUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,35 +318,37 @@ def install_dependencies(metadata):
logger.warning("The binary " + executable + " was not found on the system, you must install it before installing " + metadata['name'])
return False
else:
# detect the distribution type
is_apt = False
is_rpm = False
if distutils.spawn.find_executable("apt") is not None:
is_apt = True
if distutils.spawn.find_executable("rpm") is not None:
is_rpm = True
dependencyToCheck = False
packageManagerQueried = False
try:
if is_apt:
cache = apt.Cache()
for package in metadata["depends"]["apt"]:
if not cache[package].is_installed:
logger.warning("The apt package " + package + " was not found on the system, you must install it before installing " + metadata['name'])
return False

if is_rpm:
ts = rpm.TransactionSet()
for package in metadata["depends"]["rpm"]:
mi = ts.dbMatch( 'name', package)
try :
h = mi.next()
except StopIteration:
logger.warning("The rpm package " + package + " was not found on the system, you must install it before installing " + metadata['name'])
return False
if system == "rpm":
dependencyToCheck = True
if distutils.spawn.find_executable("rpm") is not None:
# this is an rpm system
ts = rpm.TransactionSet()
for package in metadata["depends"]["rpm"]:
mi = ts.dbMatch('name', package)
packageManagerQueried = True
try :
h = mi.next()
except StopIteration:
logger.warning("The rpm package " + package + " was not found on the system, you must install it before installing " + metadata['name'])
return False
if system == "apt":
dependencyToCheck = True
if distutils.spawn.find_executable("apt") is not None:
cache = apt.Cache()
packageManagerQueried = True
for package in metadata["depends"]["apt"]:
if not cache[package].is_installed:
logger.warning("The apt package " + package + " was not found on the system, you must install it before installing " + metadata['name'])
return False
except Exception:
logger.error("Could not query rpm or apt package repository to check dependencies for this plugin.")

if not is_apt and not is_rpm:
logger.warning("Neither rpm nor apt are detected on this sytem - cannot check the dependencies for this plugin. ")
# dependency check failed
if dependencyToCheck and not packageManagerQueried:
logger.warning("Neither rpm nor apt could be queried successfully - cannot check the dependencies for this plugin.")

if not depends_printed:
logger.info("This package depends on the following")
Expand Down

0 comments on commit f2801a8

Please sign in to comment.