diff options
author | Arif Ali <arif.ali@canonical.com> | 2023-05-09 19:21:31 +0100 |
---|---|---|
committer | Jake Hunsaker <jhunsake@redhat.com> | 2023-05-16 09:47:44 -0400 |
commit | 621fca33e592309da40d526a1e99755d521e64c9 (patch) | |
tree | f91f198a43c8366b729fb583e8578fe9d57b9a00 | |
parent | 22abe05dd0d8fe19522f69d6a5edd75d2e4b863e (diff) | |
download | sos-621fca33e592309da40d526a1e99755d521e64c9.tar.gz |
[ubuntu] update policy to use MultiPackageManager
This change allows it to use the default deb as the primary package
manager and the snap as a fallback package manager
This change also ensures that the sosreport, if installed via snap
for sos collect is detected if the deb doesn't exist
Closes: #3214
Signed-off-by: Arif Ali <arif.ali@canonical.com>
-rw-r--r-- | sos/policies/distros/ubuntu.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/sos/policies/distros/ubuntu.py b/sos/policies/distros/ubuntu.py index a6bf7260..f87ace69 100644 --- a/sos/policies/distros/ubuntu.py +++ b/sos/policies/distros/ubuntu.py @@ -9,6 +9,10 @@ from sos.report.plugins import UbuntuPlugin from sos.policies.distros.debian import DebianPolicy +from sos.policies.package_managers.snap import SnapPackageManager +from sos.policies.package_managers.dpkg import DpkgPackageManager +from sos.policies.package_managers import MultiPackageManager + import os @@ -31,6 +35,17 @@ class UbuntuPolicy(DebianPolicy): super(UbuntuPolicy, self).__init__(sysroot=sysroot, init=init, probe_runtime=probe_runtime, remote_exec=remote_exec) + + self.package_manager = MultiPackageManager( + primary=DpkgPackageManager, + fallbacks=[SnapPackageManager], + chroot=self.sysroot, + remote_exec=remote_exec) + + if self.package_manager.pkg_by_name( + 'sosreport')['pkg_manager'] == 'snap': + self.sos_bin_path = '/snap/bin' + self.valid_subclasses += [UbuntuPlugin] @classmethod |