ovs-bugtool: Dump dpkg-related information as well as RPM-related info.
[openvswitch] / utilities / ovs-bugtool
index 4f0038e4ed04082496af3e7f9f5ef10fe62cfeca..c730e373c6281ec055a57dc3fe7c25f46554b60a 100755 (executable)
@@ -67,6 +67,8 @@ OS_RELEASE = platform.release()
 # Files & directories
 #
 
+APT_SOURCES_LIST = "/etc/apt/sources.list"
+APT_SOURCES_LIST_D = "/etc/apt/sources.list.d"
 BUG_DIR = "/var/log/ovs-bugtool"
 PLUGIN_DIR = "/etc/openvswitch/bugtool"
 GRUB_CONFIG = '/boot/grub/menu.lst'
@@ -143,6 +145,7 @@ DF = 'df'
 DMESG = 'dmesg'
 DMIDECODE = 'dmidecode'
 DMSETUP = 'dmsetup'
+DPKG_QUERY = 'dpkg-query'
 ETHTOOL = 'ethtool'
 FDISK = 'fdisk'
 FIND = 'find'
@@ -633,6 +636,9 @@ exclude those logs from the archive.
     file_output(CAP_YUM, [YUM_LOG])
     tree_output(CAP_YUM, YUM_REPOS_DIR)
     cmd_output(CAP_YUM, [RPM, '-qa'])
+    file_output(CAP_YUM, [APT_SOURCES_LIST])
+    tree_output(CAP_YUM, APT_SOURCES_LIST_D)
+    cmd_output(CAP_YUM, [DPKG_QUERY, '-W', '-f=${Package} ${Version} ${Status}\n'], 'dpkg-packages')
 
     try:
         load_plugins()
@@ -898,7 +904,9 @@ def make_tar(subdir, suffix, output_fd, output_file):
             filename = "%s/%s.%s" % (BUG_DIR, subdir, suffix)
         else:
             filename = output_file
+        old_umask = os.umask(0077)
         tf = tarfile.open(filename, mode)
+        os.umask(old_umask)
     else:
         tf = tarfile.open(None, 'w', os.fdopen(output_fd, 'a'))
 
@@ -939,7 +947,9 @@ def make_zip(subdir, output_file):
         filename = "%s/%s.zip" % (BUG_DIR, subdir)
     else:
         filename = output_file
+    old_umask = os.umask(0077)
     zf = zipfile.ZipFile(filename, 'w', zipfile.ZIP_DEFLATED)
+    os.umask(old_umask)
 
     try:
         for (k, v) in data.items():