diff options
-rw-r--r-- | sos/policies/distros/redhat.py | 14 | ||||
-rw-r--r-- | sos/policies/distros/suse.py | 5 | ||||
-rw-r--r-- | sos/policies/package_managers/__init__.py | 9 | ||||
-rw-r--r-- | sos/policies/package_managers/rpm.py | 24 |
4 files changed, 32 insertions, 20 deletions
diff --git a/sos/policies/distros/redhat.py b/sos/policies/distros/redhat.py index 32e8d6d2..ee250c0b 100644 --- a/sos/policies/distros/redhat.py +++ b/sos/policies/distros/redhat.py @@ -17,7 +17,7 @@ from sos.presets.redhat import (RHEL_PRESETS, ATOMIC_PRESETS, RHV, RHEL, CB, RHOSP, RHOCP, RH_CFME, RH_SATELLITE, ATOMIC) from sos.policies.distros import LinuxPolicy -from sos.policies.package_managers import PackageManager +from sos.policies.package_managers.rpm import RpmPackageManager from sos import _sos as _ @@ -35,10 +35,6 @@ class RedHatPolicy(LinuxPolicy): ] _redhat_release = '/etc/redhat-release' _tmp_dir = "/var/tmp" - _rpmq_cmd = 'rpm -qa --queryformat "%{NAME}|%{VERSION}|%{RELEASE}\\n"' - _rpmql_cmd = 'rpm -qal' - _rpmv_cmd = 'rpm -V' - _rpmv_filter = ["debuginfo", "-devel"] _in_container = False _host_sysroot = '/' default_scl_prefix = '/opt/rh' @@ -63,12 +59,8 @@ class RedHatPolicy(LinuxPolicy): else: sysroot = self._container_init() - self.package_manager = PackageManager(query_command=self._rpmq_cmd, - verify_command=self._rpmv_cmd, - verify_filter=self._rpmv_filter, - files_command=self._rpmql_cmd, - chroot=sysroot, - remote_exec=remote_exec) + self.package_manager = RpmPackageManager(chroot=sysroot, + remote_exec=remote_exec) self.valid_subclasses += [RedHatPlugin] diff --git a/sos/policies/distros/suse.py b/sos/policies/distros/suse.py index 928f4abb..fe4c71b5 100644 --- a/sos/policies/distros/suse.py +++ b/sos/policies/distros/suse.py @@ -12,7 +12,6 @@ import sys from sos.report.plugins import RedHatPlugin, SuSEPlugin from sos.policies.distros import LinuxPolicy -from sos.policies.package_managers import PackageManager from sos import _sos as _ @@ -21,16 +20,12 @@ class SuSEPolicy(LinuxPolicy): vendor = "SuSE" vendor_urls = [('Distribution Website', 'https://www.suse.com/')] _tmp_dir = "/var/tmp" - _rpmq_cmd = 'rpm -qa --queryformat "%{NAME}|%{VERSION}\\n"' def __init__(self, sysroot=None, init=None, probe_runtime=True, remote_exec=None): super(SuSEPolicy, self).__init__(sysroot=sysroot, init=init, probe_runtime=probe_runtime) self.ticket_number = "" - self.package_manager = PackageManager( - query_command=self._rpmq_cmd, - remote_exec=remote_exec) self.valid_subclasses += [SuSEPlugin, RedHatPlugin] pkgs = self.package_manager.all_pkgs() diff --git a/sos/policies/package_managers/__init__.py b/sos/policies/package_managers/__init__.py index f9ce2a09..42eb9447 100644 --- a/sos/policies/package_managers/__init__.py +++ b/sos/policies/package_managers/__init__.py @@ -49,6 +49,7 @@ class PackageManager(): query_command = None verify_command = None verify_filter = None + files_command = None chroot = None files = None @@ -58,10 +59,10 @@ class PackageManager(): self.packages = {} self.files = [] - self.query_command = query_command if query_command else None - self.verify_command = verify_command if verify_command else None - self.verify_filter = verify_filter if verify_filter else None - self.files_command = files_command if files_command else None + self.query_command = query_command or self.query_command + self.verify_command = verify_command or self.verify_command + self.verify_filter = verify_filter or self.verify_filter + self.files_command = files_command or self.files_command # if needed, append the remote command to these so that this returns # the remote package details, not local diff --git a/sos/policies/package_managers/rpm.py b/sos/policies/package_managers/rpm.py new file mode 100644 index 00000000..5150e1e0 --- /dev/null +++ b/sos/policies/package_managers/rpm.py @@ -0,0 +1,24 @@ +# Copyright 2020 Red Hat, Inc. Jake Hunsaker <jhunsake@redhat.com> + +# This file is part of the sos project: https://github.com/sosreport/sos +# +# This copyrighted material is made available to anyone wishing to use, +# modify, copy, or redistribute it subject to the terms and conditions of +# version 2 of the GNU General Public License. +# +# See the LICENSE file in the source distribution for further information. + +from sos.policies.package_managers import PackageManager + + +class RpmPackageManager(PackageManager): + """Package Manager for RPM-based distributions + """ + + query_command = 'rpm -qa --queryformat "%{NAME}|%{VERSION}|%{RELEASE}\\n"' + files_command = 'rpm -qal' + verify_command = 'rpm -V' + verify_filter = ["debuginfo", "-devel"] + + +# vim: set et ts=4 sw=4 : |