[yum-commits] Branch 'yum-3_2_X' - yum/__init__.py yum/rpmsack.py

skvidal at osuosl.org skvidal at osuosl.org
Fri May 1 18:48:14 UTC 2009


 yum/__init__.py |   39 ++++++++++++++++++++++++++++++++-------
 yum/rpmsack.py  |    6 ++++++
 2 files changed, 38 insertions(+), 7 deletions(-)

New commits:
commit 657a0eccdf21b132000dd70051a29dc21b95a0d4
Author: Seth Vidal <skvidal at fedoraproject.org>
Date:   Fri May 1 14:46:10 2009 -0400

    - add in verifyTransaction() completely and populate some fields in yumdb on install

diff --git a/yum/__init__.py b/yum/__init__.py
index 0973203..1aab227 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -1002,16 +1002,41 @@ class YumBase(depsolve.Depsolve):
         
         # for each pkg in the tsInfo
         # if it is an install - see that the pkg is installed
-        # if it is an update - see that the pkg is installed and the old version
-        #   has been removed
         # if it is a remove - see that the pkg is no longer installed, provided
         #    that there is not also an install of this pkg in the tsInfo (reinstall)
-        # if it is an obsolete - see that the pkg is installed and the obsoleted pkg
-        # has been removed
-        # for any kind of install add from_repo to the yumdb
+        # for any kind of install add from_repo to the yumdb, and the cmdline
+        # and the install reason
+
+        for txmbr in self.tsInfo:
+            if txmbr.output_state in TS_INSTALL_STATES:
+                if not self.rpmdb.contains(po=txmbr.po):
+                    # maybe a file log here, too
+                    # but raising an exception is not going to do any good
+                    self.logger.critical(_('%s was supposed to be installed' \
+                                           ' but is not!' % txmbr.po))
+                    continue
+                po = self.rpmdb.searchPkgTuple(txmbr.pkgtup)[0]
+                po.yumdb_info.from_repo = txmbr.po.repoid
+                po.yumdb_info.reason = txmbr.reason
+                if hasattr(self, 'cmds') and self.cmds:
+                    po.yumdb_info.command_line = ' '.join(self.cmds)
+            
+            elif txmbr.output_state in TS_REMOVE_STATES:
+                if self.rpmdb.contains(po=txmbr.po):
+                    if not self.tsInfo.getMembersWithState(pkgtup=txmbr.pkgtup,
+                                output_states=TS_INSTALL_STATES):
+                        # maybe a file log here, too
+                        # but raising an exception is not going to do any good
+                        self.logger.critical(_('%s was supposed to be removed' \
+                                               ' but is not!' % txmbr.po))
+                        continue
+                yumdb_item = self.rpmdb.yumdb.get_package(po=txmbr.po)
+                yumdb_item.clean()
+            else:
+                self.verbose_logger.log(logginglevels.DEBUG_2, 'What is this? %s' % txmbr.po)
+
+
 
-        pass
-        
     def costExcludePackages(self):
         """exclude packages if they have an identical package in another repo
         and their repo.cost value is the greater one"""
diff --git a/yum/rpmsack.py b/yum/rpmsack.py
index ccdc310..ccef1f0 100644
--- a/yum/rpmsack.py
+++ b/yum/rpmsack.py
@@ -785,6 +785,12 @@ class RPMDBAdditionalDataPackage(object):
                 continue
             yield item
 
+    def clean(self):
+        # purge out everything
+        for item in self:
+            self._delete(item)
+        os.rmdir(self._mydir)
+
 #    def __dir__(self): # for 2.6 and beyond, apparently
 #        return list(self.__iter__()) + self.__dict__.keys()
 


More information about the Yum-commits mailing list