From e0a6862bc05cccca44212471d97abdc7df8fe9d7 Mon Sep 17 00:00:00 2001
From: David Lehman <dlehman@redhat.com>
Date: Wed, 29 Feb 2012 18:01:47 -0600
Subject: [PATCH 1/7] Fix a bunch of typos in the rpm callback.

---
 pyanaconda/packaging/yumpayload.py |   34 +++++++++++++++++-----------------
 1 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/pyanaconda/packaging/yumpayload.py b/pyanaconda/packaging/yumpayload.py
index 6b14e6f..9eec94d 100644
--- a/pyanaconda/packaging/yumpayload.py
+++ b/pyanaconda/packaging/yumpayload.py
@@ -524,7 +524,7 @@ reposdir=/etc/yum.repos.d,/etc/anaconda.repos.d,/tmp/updates/anaconda.repos.d,/t
 
         # set up rpm logging to go to our log
         self._yum.ts.ts.scriptFd = self.install_log.fileno()
-        _rpm.setLogFile(self.install_log)
+        rpm.setLogFile(self.install_log)
 
         # create the install callback
         rpmcb = RPMCallback(self._yum, self.install_log,
@@ -595,7 +595,7 @@ class RPMCallback(object):
         """ Return a (name, TransactionMember) tuple from cb key. """
         if hasattr(key, "po"):
             # New-style callback, key is a TransactionMember
-            txmbr = key.po
+            txmbr = key
             name = key.name
         else:
             # cleanup/remove error
@@ -606,15 +606,15 @@ class RPMCallback(object):
 
     def callback(self, event, amount, total, key, userdata):
         """ Yum install callback. """
-        if event == _rpm.RPMCALLBACK_TRANS_START:
+        if event == rpm.RPMCALLBACK_TRANS_START:
             pass
-        elif event == _rpm.RPMCALLBACK_TRANS_PROGRESS:
+        elif event == rpm.RPMCALLBACK_TRANS_PROGRESS:
             # amount / total complete
             pass
-        elif event == _rpm.RPMCALLBACK_TRANS_STOP:
+        elif event == rpm.RPMCALLBACK_TRANS_STOP:
             # we are done
             pass
-        elif event == _rpm.RPMCALLBACK_INST_OPEN_FILE:
+        elif event == rpm.RPMCALLBACK_INST_OPEN_FILE:
             # update status that we're installing/upgrading %h
             # return an open fd to the file
             txmbr = self._get_txmbr(key)[1]
@@ -624,19 +624,19 @@ class RPMCallback(object):
             else:
                 mode = _("Installing")
 
-            self.install_log.write("%s %s %s" % (time.strftime("%H:%M:%S"),
-                                                 mode,                                                                           txmbr.po))
+            self.install_log.write("%s %s %s\n" % (time.strftime("%H:%M:%S"),
+                                                   mode,                                                                           txmbr.po))
             self.install_log.flush()
 
             self.package_file = None
-            repo = self._yum.repos.getRepo(po.repoid)
+            repo = self._yum.repos.getRepo(txmbr.po.repoid)
 
             while self.package_file is None:
                 try:
-                    package_path = repo.getPackage(po)
+                    package_path = repo.getPackage(txmbr.po)
                 except (yum.Errors.NoMoreMirrorsRepoError, IOError):
                     exn = PayloadInstallError("failed to open package")
-                    if errorHandler(exn, po) == ERROR_RAISE:
+                    if errorHandler(exn, txmbr.po) == ERROR_RAISE:
                         raise exn
                 except yum.Errors.RepoError:
                     continue
@@ -644,7 +644,7 @@ class RPMCallback(object):
                 self.package_file = open(package_path)
 
             return self.package_file.fileno()
-        elif event == _rpm.RPMCALLBACK_INST_CLOSE_FILE:
+        elif event == rpm.RPMCALLBACK_INST_CLOSE_FILE:
             # close and remove the last opened file
             # update count of installed/upgraded packages
             package_path = self.package_file.name
@@ -656,19 +656,19 @@ class RPMCallback(object):
                     os.unlink(package_file)
                 except OSError as e:
                     log.debug("unable to remove file %s" % e.strerror)
-        elif event == _rpm.RPMCALLBACK_UNINST_START:
+        elif event == rpm.RPMCALLBACK_UNINST_START:
             # update status that we're cleaning up %key
             #progress.set_text(_("Cleaning up %s" % key))
             pass
-        elif event in (_rpm.RPMCALLBACK_CPIO_ERROR,
-                       _rpm.RPMCALLBACK_UNPACK_ERROR,
-                       _rpm.RPMCALLBACK_SCRIPT_ERROR):
+        elif event in (rpm.RPMCALLBACK_CPIO_ERROR,
+                       rpm.RPMCALLBACK_UNPACK_ERROR,
+                       rpm.RPMCALLBACK_SCRIPT_ERROR):
             name = self._get_txmbr(key)[0]
 
             # Script errors store whether or not they're fatal in "total".  So,
             # we should only error out for fatal script errors or the cpio and
             # unpack problems.
-            if event != _rpm.RPMCALLBACK_SCRIPT_ERROR or total:
+            if event != rpm.RPMCALLBACK_SCRIPT_ERROR or total:
                 exn = PayloadInstallError("cpio, unpack, or fatal script error")
                 if errorHandler(exn, name) == ERROR_RAISE:
                     raise exn
-- 
1.7.9.1

