diff options
-rw-r--r-- | sos/plugins/apt.py | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/sos/plugins/apt.py b/sos/plugins/apt.py index 6063bf9d..a5ed14d4 100644 --- a/sos/plugins/apt.py +++ b/sos/plugins/apt.py @@ -15,6 +15,7 @@ # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. from sos.plugins import Plugin, UbuntuPlugin, DebianPlugin +import pdb class Apt(Plugin, DebianPlugin, UbuntuPlugin): @@ -29,17 +30,17 @@ class Apt(Plugin, DebianPlugin, UbuntuPlugin): "/etc/apt", "/var/log/apt" ]) - apt_cache_policy_ext = "sh -c '%s'" % ( - "dpkg -l | grep ^ii |" - "cut -d \" \" -f3 |" - "xargs apt-cache policy" - ) + dpkg_result = self.call_ext_prog( + "dpkg-query -W -f='${binary:Package}\t${status}\n'") + dpkg_output = dpkg_result['output'].splitlines() + pkg_list = ' '.join( + [v.split('\t')[0] for v in dpkg_output if 'ok installed' in v]) self.add_cmd_outputs([ "apt-get check", "apt-config dump", "apt-cache stats", "apt-cache policy", - apt_cache_policy_ext + "apt-cache policy {}".format(pkg_list) ]) # vim: et ts=4 sw=4 |