[yum-git] docs/yum-changelog.1 plugins/changelog

James Antill james at linux.duke.edu
Mon Feb 18 23:23:01 UTC 2008


 docs/yum-changelog.1           |   30 +++++++++++++-
 plugins/changelog/changelog.py |   84 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 112 insertions(+), 2 deletions(-)

New commits:
commit db0a8bf94f1eec68b2ef1244896675e3e6138fe6
Author: James Antill <james at and.org>
Date:   Mon Feb 18 18:22:51 2008 -0500

    Add changelog command to yum-changelog

diff --git a/docs/yum-changelog.1 b/docs/yum-changelog.1
index 5f2f86d..0f121d7 100644
--- a/docs/yum-changelog.1
+++ b/docs/yum-changelog.1
@@ -15,10 +15,15 @@ yum will invoke
 .BR yum-changelog(1)
 plugin if the
 .B --changelog
-option is used with yum.
+option or the
+.B changelog
+command is used with yum.
 .SH OPTIONS
 .IP --changelog
 Show changelog delta of updated packages
+.SH COMMANDS
+.IP changelog
+Show changelog data of packages since a specified point in time
 .SH FILES
 .I /etc/yum/pluginconf.d/changelog.conf
 .RS
@@ -27,6 +32,23 @@ The system wide configuration file. See
 for more information.
 .RE
 .SH EXAMPLES
+# yum
+.B changelog
+2008-Jan yum\*
+.br
+Listing changelogs since: 2008-01-18
+.br
+.br
+yum-versionlock-1.1.11-1.fc8.noarch      installed
+.br
+* Wed Jan 30 17:00:00 2008 Tim Lauridsen <timlau at fedoraproject.org>
+.br
+- mark as 1.1.11
+.br
+.br
+changelog stats. 33 pkgs, 12 source pkgs, 1 changelog
+.br
+.br
 # yum update ktechlab
 .B --changelog
 .br
@@ -71,8 +93,12 @@ yum-changelog is available via:
 .nf
 # yum install yum-changelog
 .fi
-.SH AUTHOR
+.SH AUTHORS
 .RS
 Chitlesh Goorah <chitlesh at fedoraproject.org>
+.br
+Panu Matilainen <pmatilai at laiskiainen.org>
+.br
+James Antill <james at and.org>
 .SH "SEE ALSO"
 .BR yum(1)
diff --git a/plugins/changelog/changelog.py b/plugins/changelog/changelog.py
index 71be1ce..e5e3299 100644
--- a/plugins/changelog/changelog.py
+++ b/plugins/changelog/changelog.py
@@ -13,6 +13,7 @@
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 #
 # by Panu Matilainen <pmatilai at laiskiainen.org>
+#    James Antill    <james at and.org>
 #
 # TODO: 
 # - In 'pre' mode we could get the changelogs from rpmdb thus avoiding
@@ -22,6 +23,11 @@ import time
 from rpmUtils.miscutils import splitFilename
 from yum.plugins import TYPE_INTERACTIVE
 
+from yum import logginglevels
+import logging
+
+import dateutil.parser
+
 requires_api_version = '2.5'
 plugin_type = (TYPE_INTERACTIVE,)
 
@@ -63,7 +69,85 @@ def show_changes(conduit, msg):
             for line in changelog_delta(srpms[name][0], origpkgs[name]):
                 conduit.info(2, "%s\n" % line)
 
+class ChangeLogCommand:
+
+    def getNames(self):
+        return ['changelog', 'ChangeLog']
+
+    def getUsage(self):
+        return "<date>|forever [PACKAGE|all|installed|updates|extras|obsoletes|recent]"
+
+    def getSummary(self):
+        return """\
+Display changelog data, since a specified time, on a group of packages"""
+
+    def doCheck(self, base, basecmd, extcmds):
+        pass
+
+    def show_data(self, msg, pkgs, name):
+        for pkg in pkgs:
+            self._pkgs += 1
+            if pkg.sourcerpm in self._done:
+                continue
+
+            self._spkgs += 1
+
+            for line in changelog_delta(pkg, self._since):
+                if pkg.sourcerpm not in self._done:
+                    if not self._done:
+                        msg('')
+                        if not self._since:
+                            msg('Listing all changelogs')
+                        else:
+                            msg('Listing changelogs since: ' +
+                                str(self._since_dto.date()))
+                    msg('')
+
+                    self._done[pkg.sourcerpm] = True
+                    msg('%-40.40s %s' % (pkg, pkg.repoid))
+                self._changelogs += 1
+                msg(line)
+                msg('')
+
+    def doCommand(self, base, basecmd, extcmds):
+        logger = logging.getLogger("yum.verbose.main")
+        def msg(x):
+            logger.log(logginglevels.INFO_2, x)
+        def msg_warn(x):
+            logger.warn(x)
+
+        self._done = {}
+        self._pkgs = 0
+        self._spkgs = 0
+        self._changelogs = 0
+        self._since = 0
+        self._since_dto = None
+        if len(extcmds):
+            since = extcmds[0]
+            extcmds = extcmds[1:]
+
+            if since != 'forever':
+                self._since_dto = dateutil.parser.parse(since, fuzzy=True)
+                tt = self._since_dto.timetuple()
+                self._since = time.mktime(tt)
+
+        ypl = base.returnPkgLists(extcmds)
+        self.show_data(msg, ypl.installed, 'Installed Packages')
+        self.show_data(msg, ypl.available, 'Available Packages')
+        self.show_data(msg, ypl.extras,    'Extra Packages')
+        self.show_data(msg, ypl.updates,   'Updated Packages')
+        self.show_data(msg, ypl.obsoletes, 'Obsoleting Packages')
+
+        ps = sps = cs = ""
+        if self._pkgs       != 1: ps  = "s"
+        if self._spkgs      != 1: sps = "s"
+        if self._changelogs != 1: cs  = "s"
+        return 0, [basecmd +
+                   ' stats. %d pkg%s, %d source pkg%s, %d changelog%s' %
+                   (self._pkgs, ps, self._spkgs, sps, self._changelogs, cs)]
+
 def config_hook(conduit):
+    conduit.registerCommand(ChangeLogCommand())
     parser = conduit.getOptParser()
     if parser:
         parser.add_option('--changelog', action='store_true', 



More information about the Yum-cvs-commits mailing list