[yum-git] docs/yum-debug-dump.1 Makefile yum-debug-dump.py yum-utils.spec

Seth Vidal skvidal at linux.duke.edu
Mon Apr 28 22:10:14 UTC 2008


 Makefile              |    2 
 docs/yum-debug-dump.1 |   47 +++++++++++++++
 yum-debug-dump.py     |  149 ++++++++++++++++++++++++++++++++++++++++++++++++++
 yum-utils.spec        |    4 +
 4 files changed, 200 insertions(+), 2 deletions(-)

New commits:
commit ab1a3eceb9b8b4f8377c0f7b3f05d6d599089027
Author: Seth Vidal <skvidal at fedoraproject.org>
Date:   Mon Apr 28 18:09:32 2008 -0400

    yum-debug-dump app, man page, Makefile and spec file edits

diff --git a/Makefile b/Makefile
index 06b17d3..fdbd490 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
 SUBDIRS = docs
 PKGNAME = yum-utils
-UTILS = package-cleanup debuginfo-install repoclosure repomanage repoquery repo-graph repo-rss yumdownloader yum-builddep repotrack reposync repodiff
+UTILS = package-cleanup debuginfo-install repoclosure repomanage repoquery repo-graph repo-rss yumdownloader yum-builddep repotrack reposync repodiff yum-debug-dump
 UTILSROOT = yum-complete-transaction 
 VERSION=$(shell awk '/Version:/ { print $$2 }' ${PKGNAME}.spec)
 RELEASE=$(shell awk '/Release:/ { print $$2 }' ${PKGNAME}.spec)
diff --git a/docs/yum-debug-dump.1 b/docs/yum-debug-dump.1
new file mode 100644
index 0000000..b888c66
--- /dev/null
+++ b/docs/yum-debug-dump.1
@@ -0,0 +1,47 @@
+.\" yum-debug-dump
+.TH "yum-debug-dump" "1" "2008 Apr 28" "Seth Vidal" ""
+.SH "NAME"
+yum-debug-dump
+.SH "SYNOPSIS"
+\fByum-debug-dump\fP
+.SH "DESCRIPTION"
+.PP 
+\fByum-debug-dump\fP is a program which creates a gzipped file containing a
+lot of information useful to developers trying to debug a problem.
+.PP
+By default it will output a file to the current working directory named
+yum_debug_dump.txt.gz. This file contains no private information but does
+contain a complete list of all packages you have installed, all packages
+available in any repository, important configuration and system information.
+You can view this file using the 'zless' command.
+.PP 
+.SH "FILES"
+As yum-debug-dump uses YUM libraries for retrieving all the information, it
+relies on YUM configuration for its default values like which repositories
+to use. Consult YUM documentation for details:
+.PP
+.nf 
+/etc/yum.conf
+/etc/yum/repos.d/
+/var/cache/yum/
+.fi 
+
+.PP 
+.SH "SEE ALSO"
+.nf
+.I yum.conf (5)
+.\"http://linux.duke.edu/yum-utils/
+http://linux.duke.edu/yum/
+.fi 
+
+.PP 
+.SH "AUTHORS"
+.nf 
+See the Authors file included with this program.
+.fi 
+
+.PP 
+.SH "BUGS"
+There of course aren't any bugs, but if you find any, they should be sent
+to the mailing list: yum at lists.linux.duke.edu or filed in bugzilla.
+.fi
diff --git a/yum-debug-dump.py b/yum-debug-dump.py
new file mode 100644
index 0000000..b22cf8a
--- /dev/null
+++ b/yum-debug-dump.py
@@ -0,0 +1,149 @@
+#!/usr/bin/python -tt
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Library General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+## (c) 2008 Red Hat. Written by skvidal at fedoraproject.org
+
+import os
+import subprocess
+import sys
+import yum
+from rpmUtils import miscutils
+import gzip
+import rpm
+
+# maybe use YumQuiet?
+
+class YumDebugDump(yum.YumBase):
+
+    def __init__(self):
+        self.file_version = '1'      
+        yum.YumBase.__init__(self)
+    
+    def dump_rpmdb(self):
+        msg = "%%%%RPMDB\n"
+        for po in self.rpmdb:
+            msg += '  %s:%s-%s-%s.%s\n' % (po.epoch, po.name, po.ver,po.rel, po.arch)
+        
+        return msg
+
+    def dump_repos(self):
+        msg = "%%%%REPOS\n"
+        for repo in self.repos.listEnabled():
+            msg += '%%%s - %s\n' % (repo.id, repo.urls[0])
+            msg += "  excludes: %s\n" % ",".join(repo.exclude)
+            for po in self.pkgSack.returnPackages(repo.id):
+                msg += '  %s:%s-%s-%s.%s\n' % (po.epoch, po.name, po.ver,po.rel, po.arch)
+        return msg
+
+    def dump_system_info(self):
+        msg = "%%%%SYSTEM INFO\n"
+        msg += "  uname: %s, %s\n" % (os.uname()[2], os.uname()[4])
+        msg += "  rpm ver: %s\n" % subprocess.Popen(["rpm", "--version"], stdout=subprocess.PIPE).communicate()[0].strip()
+        msg += "  python ver: %s\n" % sys.version.replace('\n', '')
+        return msg
+        
+    def dump_yum_config_info(self):
+        msg = "%%%%YUM INFO\n"
+        msg += "  arch: %s\n" % self.conf.yumvar['arch']
+        msg += "  basearch: %s\n" % self.conf.yumvar['basearch']        
+        msg += "  releasever: %s\n" % self.conf.yumvar['releasever']
+        msg += "  yum ver: %s\n" % yum.__version__
+        msg += "  enabled plugins: %s\n" % ",".join(self.plugins._plugins.keys())
+        msg += "  global excludes: %s\n" % ",".join(self.conf.exclude)
+        return msg
+    
+    def dump_rpm_problems(self):
+
+        pkgs = {}
+        for po in self.rpmdb.returnPackages():
+            tup = po.pkgtup
+            header= po.hdr
+            requires = zip(
+                header[rpm.RPMTAG_REQUIRENAME],
+                header[rpm.RPMTAG_REQUIREFLAGS],
+                header[rpm.RPMTAG_REQUIREVERSION],
+                )
+            pkgs[tup] = requires
+
+
+        errors = []
+        providers = {} # To speed depsolving, don't recheck deps that have 
+                       # already been checked
+        provsomething = {}
+        for (pkg,reqs) in pkgs.items():
+            for (req,flags,ver)  in reqs:
+                if ver == '':
+                    ver = None
+                rflags = flags & 15
+                if req.startswith('rpmlib'): continue # ignore rpmlib deps
+                
+                if not providers.has_key((req,rflags,ver)):
+                    resolve_sack = self.rpmdb.whatProvides(req,rflags,ver)
+                else:
+                    resolve_sack = providers[(req,rflags,ver)]
+                    
+                if len(resolve_sack) < 1:
+                    errors.append("Package %s requires %s" % (pkg[0],
+                      miscutils.formatRequire(req,ver,rflags)))
+                else:
+                    for rpkg in resolve_sack:
+                        # Skip packages that provide something for themselves
+                        # as these can still be leaves
+                        if rpkg != pkg:
+                            provsomething[rpkg] = 1
+                    # Store the resolve_sack so that we can re-use it if another
+                    # package has the same requirement
+                    providers[(req,rflags,ver)] = resolve_sack
+
+
+        msg = "%%%%RPMDB PROBLEMS\n"
+        for error in errors:
+            msg += "%s\n" % error
+
+        # possibly list all verify failures, too
+        return msg
+
+
+    
+    def create_debug_file(self, fn=None):
+        """create debug txt file and compress it, place it at yum_debug_dump.txt.gz
+           unless fn is specified"""
+        if not fn:
+            fn = 'yum_debug_dump.txt.gz'
+        
+        if not fn.startswith('/'):
+            fn = '%s/%s' % (os.getcwd(), fn)
+        
+        fo = gzip.GzipFile(fn, 'w')
+        
+        msg = "yum-debug-dump version %s\n" % self.file_version
+        fo.write(msg)
+        fo.write(self.dump_system_info())
+        fo.write(self.dump_yum_config_info())
+        fo.write(self.dump_rpm_problems())
+        fo.write(self.dump_rpmdb())
+        fo.write(self.dump_repos())
+        fo.close()
+        return fn
+        
+def main():
+    my = YumDebugDump()
+    fn = my.create_debug_file()
+    print "Output written to: %s" % fn
+    
+if __name__ == "__main__":
+    main()
+
+
diff --git a/yum-utils.spec b/yum-utils.spec
index 2ad7425..401085f 100644
--- a/yum-utils.spec
+++ b/yum-utils.spec
@@ -15,7 +15,7 @@ yum-utils is a collection of utilities and examples for the yum package
 manager. It includes utilities by different authors that make yum easier and 
 more powerful to use. These tools include: debuginfo-install, package-cleanup,
 repoclosure, repodiff, repo-graph, repomanage, repoquery, repo-rss, reposync,
-repotrack, yum-builddep, yum-complete-transaction, yumdownloader.
+repotrack, yum-builddep, yum-complete-transaction, yumdownloader, yum-debug-dump
 
 %package -n yum-updateonboot
 Summary: Run yum update on system boot
@@ -309,6 +309,7 @@ fi
 %{_bindir}/repo-rss
 %{_bindir}/yumdownloader
 %{_bindir}/yum-builddep
+%{_bindir}/yum-debug-dump
 %{_sbindir}/yum-complete-transaction
 %{_mandir}/man1/yum-utils.1.*
 %{_mandir}/man1/package-cleanup.1.*
@@ -316,6 +317,7 @@ fi
 %{_mandir}/man1/repoquery.1.*
 %{_mandir}/man1/reposync.1.*
 %{_mandir}/man1/yum-builddep.1.*
+%{_mandir}/man1/yum-debug-dump.1.*
 %{_mandir}/man8/yum-complete-transaction.8.*
 %{_mandir}/man1/yumdownloader.1.*
 



More information about the Yum-cvs-commits mailing list