From 6a9ffd67fe2f69f473226f746bfb154803d863a1 Mon Sep 17 00:00:00 2001 From: Pavel Moravec Date: Mon, 18 Jun 2018 11:40:57 +0200 Subject: [policies] add auxiliary function _get_pkg_name_for_binary In some cases, we need to determine what package provides given binary. This auxiliary function implements it - so far it works for and will be used by archive methods. Related to: #1196 Signed-off-by: Pavel Moravec --- sos/policies/__init__.py | 6 ++++++ sos/policies/debian.py | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/sos/policies/__init__.py b/sos/policies/__init__.py index b5cfc819..047b646f 100644 --- a/sos/policies/__init__.py +++ b/sos/policies/__init__.py @@ -321,6 +321,12 @@ No changes will be made to system configuration. ) return time.strftime(nstr) + # for some specific binaries like "xz", we need to determine package + # providing it; that is policy specific. By default return the binary + # name itself until particular policy overwrites it + def _get_pkg_name_for_binary(self, binary): + return binary + def get_tmp_dir(self, opt_tmp_dir): if not opt_tmp_dir: return tempfile.gettempdir() diff --git a/sos/policies/debian.py b/sos/policies/debian.py index 15648d5d..358e831b 100644 --- a/sos/policies/debian.py +++ b/sos/policies/debian.py @@ -26,6 +26,12 @@ class DebianPolicy(LinuxPolicy): self.valid_subclasses = [DebianPlugin] + def _get_pkg_name_for_binary(self, binary): + # for binary not specified inside {..}, return binary itself + return { + "xz": "xz-utils" + }.get(binary, binary) + @classmethod def check(cls): """This method checks to see if we are running on Debian. -- cgit